Xcode Previews

Create an app UI and configure almost everything your users see using Xcode Previews.

Xcode Previews Documentation

Posts under Xcode Previews tag

141 results found
Post marked as solved
261 Views

Project can not run in Xcode 12.4

Hello everyone, I faced to an issue that I searched and not found. When I want to run my project in Xcode 12.4 first it take too much time then Xcode force quit and after that my Mac restarted automatically finally I can't run my project.
Asked
Last updated .
Post marked as unsolved
115 Views

Rendering an application on multiple device sizes

Hey guys, I'm pretty new to Swift and I'm currently working on an iOS project with Swift 4.2. I'm having issues with rendering my application on multiple devices. I started the application with an iPhone 11 and it looks perfect on this iPhone, however when i switch devices to and iPhone 8 or iPhone 12 some elements go off the screen or look way too small. Any tips for this? And should i be editing this directly in the main.storyboard? Thanks for the help!
Asked
by evan790.
Last updated .
Post marked as unsolved
195 Views

Automatic ToolbarItem placement hides the Add Button in XCode's App project template

Here is the default code of the SwiftUI project template in XCode 12.0.1    var body: some View {     List {       ForEach(items) { item in         Text("Item at \(item.timestamp!, formatter: itemFormatter)")       }       .onDelete(perform: deleteItems)     }     .toolbar {       #if os(iOS)       EditButton()       #endif       Button(action: addItem) {         Label("Add Item", systemImage: "plus")       }     }   } By default, the Edit button and the Add Item button don't appear on the preview. I have to wrap the List in a NavigationView before the Edit button appears.    var body: some View {     NavigationView {       List {         ForEach(items) { item in           Text("Item at \(item.timestamp!, formatter: itemFormatter)")         }         .onDelete(perform: deleteItems)       }       .toolbar {         #if os(iOS)         ToolbarItem(placement: .automatic) {           EditButton()         }         #endif         ToolbarItem(placement: .automatic) {           Button(action: addItem) {             Label("Add Item", systemImage: "plus")           }         }       }       .navigationTitle("Main List")     }   } I've wrapped the buttons in ToolbarItems so that they can be positioned. At this point, the Add Item button is still not visible on the screen. It's only if I change it to something like ToolbarItem(placement: .principal) that it would be visible. Any leads as to why the automatic positioning is hiding the Add Item button?
Asked
by bzarzuela.
Last updated .
Post marked as unsolved
85 Views

IOS simulator error

Anyone getting "Error returned in reply: Connection interrupted" "Software caused connection abort" When trying to run a project. The live preview mode is also not working. This is for Xcode 12 using both catalina and big sur. I've deleted the Derived Data folder. Quit and restarted Xcode. Deleted Xcode from my computer and reinstalled it. I even upgraded my OS from Catalina to Big Sur hoping that this would fix the problem. No luck. I can build and run projects on my iOS device. Does anyone know what the problem is?
Asked
by RJC1980.
Last updated .
Post marked as unsolved
461 Views

Error when previewing on device

When the Xcode Previews app opens on the device, this is the error message in Xcode: RemoteHumanReadableError: Failed to update preview. Error encountered when sending 'display' message to agent. I tried cleaning the build folder and quitting then reopening Xcode to no avail. Using Xcode 12.0.1 previewing on iPhone 11.
Asked
by BabyJ.
Last updated .
Post marked as unsolved
98 Views

Cannot Preview View When Target is IOS And Watch Extension

When adding a swift view as a target to both IOS and Apple Watch, preview fails. If the scheme is IOS, there's no problem. If the target is only watch, there's no problem. But if the scheme is Apple Watch, and the target is both IOS and the Apple Watch extension, then preview fails: HumanReadableNSError: The run destination iPhone 12 Pro Max is not valid for Running the scheme 'WatchYakTrack (Complication)'. IDEFoundationErrorDomain (1)
Asked
by redtaped.
Last updated .
Post marked as unsolved
758 Views

Swift UI Preview Crash

Any help with preview crash on an App that is building just fine and runs on simulator fine? Are there logs that I can access somehow? The previews were working just fine, but then stopped and I have reverted all changes since and the previews are still broken.
Asked
by brendenk1.
Last updated .
Post marked as unsolved
240 Views

SwiftUI previews stopped working: build error with @main

I've been working for the past day or so to add a very minor feature to one of our UIKit based apps using SwiftUI, as an experiment. Suddenly, this morning, previews stopped working, citing a build error that only occurs when building for preview: Compiling failed: 'main' attribute cannot be used in a module that contains top-level code I was editing the view when this started happening, but no fiddling I've done with it since has fixed the issue. I have tried: Reverting all changes in Git Cleaning the build folder (repeatedly) Touching both the file with the SwiftUI view, and the AppDelegate that's annotated with @main Closing the project, and Xcode The project builds and runs just fine: this error only occurs with previews. I had been working in Xcode 12.5 beta 2 when the problem started, but it persists when I open the project in Xcode 12.3. Is there some extra build cache that I can go purge?
Asked
by 610.
Last updated .
Post marked as unsolved
106 Views

Need to add iPhone 8 to xcode View As

I have been unable to find a way to add the iPhone 8 device to the view as at the bottom of the preview in xcode storyboards. There has to be a way, especially since apple requires us to still support the device through 9/22. Any suggestions or help would be greatly appreciated.
Asked
by dpalme.
Last updated .
Post marked as unsolved
505 Views

Widget SwiftUI previews failure when adding a dependency

Repro steps: Create new project Create WidgetKit extension (verify that previews work) Create dummy framework (verify that previews still work) Link dummy framework to the widget extension At that point, preview stops working with the following error: "RemoteHumanReadableError ProcessError: Failed to launch widget extension: The operation couldn’t be completed. (CHSErrorDomain error 1050.)" What can I do to make this work?
Asked
Last updated .
Post marked as unsolved
88 Views

Xcode Crackling/Popping noise

Is anyone experiencing Crackling/Popping noise when running the preview or simulator. I had this issue before and it went away with an update but now it's back. It's very annoying.
Asked
Last updated .
Post marked as unsolved
163 Views

SwiftUI - Debug Preview not working

I'm having an issue getting the debug preview working. I've tried it on several projects and I seem to be getting the same error: attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.) When I check the console.app I only see SIGKILL logs, nothing that can really show me where I'm going wrong. My team has the same problem on different devices, so I'm doubtful that this is hardware related. And I've had the issue on brand-new projects as well as legacy ones, so that leads me to believe that it's likely not a "code problem" unless I'm missing something on both... Using: MacBook Pro 2015 - Big Sur Xcode 12.2
Asked
by vroma.
Last updated .
Post marked as unsolved
152 Views

Unable to boot device due to insufficient system resources

The current system settings are not sufficient to allow booting additional simulators: maxFiles: 12288, openFiles: 11092, enforcedFilesBuffer: 1868 Please see Simulator Help for information on adjusting resource limits. What is happening??????
Asked
Last updated .