Hello everyone,
I’m currently developing my first VisionOS app in Xcode, starting with the default "Hello World" code provided when creating a new VisionOS Mixed Reality App. However, I’m facing some issues with performance and previewing that I can’t seem to resolve.
When I load the preview, it takes an extremely long time, and sometimes it doesn’t load at all. Even when I try to run the app in the VisionOS Simulator, the simulator shows an endless black screen and never displays the intended view. I’ve made no changes to the code, so it’s purely the base setup.
Here are my system details:
Xcode version: 16.1, VisionOs 2.0;
macOS version: 15.0.1;
Hardware: MacBook Air 2020 M1
I’ve tried restarting Xcode and my machine, but the issue persists. Has anyone else faced similar problems or have any suggestions for fixing this? Or is my hardware simply too weak? Any help would be greatly appreciated!
Thank you in advance!
Xcode Previews
RSS for tagCreate an app UI and configure almost everything your users see using Xcode Previews.
Posts under Xcode Previews tag
135 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm developing an app which supports for connect with an BLE device. There are some views for showing data from bluetooth. The code below for an example:
@EnvironmentObject var bleManager: BLEManager // a class implemented CBCentralManagerDelegate
var body: some View {
// bleConnected is a CBPeripheral
if let bleConnected = bleManager.bleConnected {
if let services = bleConnected.services {
ForEach(services, id:\.self) { service in
// UI for print uuid, descriptions ...
showServiceDescriptionView(services)
if let characteristics = service.characteristics {
ForEach(characteristics, id:\.self) { characteristic in
// UI for print uuid, data for each characteristic
showCharacteristicsDetailView(characteristic)
}
}
}
}
}
}
}
But it seems that Xcode Preview do not support connect to a real bluetooth device. So the preview window in Xcode will always be a empty view.
I only can see the data on the real device. But it's important for me to design UI on the preview. So are there any method to mock a fake CBPeripheral in the Previewer? Or are there any other way to achieve this?
I'm using Xcode 16 and SwiftUI targeting iOS 18. I'm new to Core Data, and when I create a new project and select to use Core Data as storage, I get boilerplate code for it.
The problem is that when I try to see the preview without any change to the code, I get a Fatal Error:
CrashReportError: Fatal Error in Persistence.swift
Test crashed due to fatalError in Persistence.swift at line 52.
Unresolved error Error Domain=NSSQLiteErrorDomain Code=8 "(null)" UserInfo={NSFilePath=/Users/monni/Library/Developer/Xcode/UserData/Previews/Simulator Devices/D0D98B5B-7E6F-4DC3-B16A-34D6D2958558/data/Containers/Data/Application/A98879A6-46F5-4E29-B2D7-AD294F1EFFD0/Library/Application Support/Test.sqlite, NSSQLiteErrorDomain=8}, ["NSSQLiteErrorDomain": 8, "NSFilePath": /Users/monni/Library/Developer/Xcode/UserData/Previews/Simulator Devices/D0D98B5B-7E6F-4DC3-B16A-34D6D2958558/data/Containers/Data/Application/A98879A6-46F5-4E29-B2D7-AD294F1EFFD0/Library/Application Support/Test.sqlite]
When I try to open the SQLite database there are no entities in it.
I have also tried xcrun simctl --set previews delete all, but with no luck.
My iOS (iPhone/iPad/Mac Catalyst) app has a relatively complex authentication flow, primarily required due to it being an API client. Several of my views have .task modifiers that begin executing code when the views are created.
After moving to iOS 18 and Xcode 16, when running in the Simulator, I began noticing my workflow was breaking as views were being created out of sequence... but not by me 🤯
Here is an example stack when I place a breakpoint inside of this view's .task.
From my logging (and this stack) I can verify I am not creating this view.
This view has no preview associated with it, and there are no previews up the view hierarchy from it either.
This happens in the Simulator only
The only clue I have to go on is this line of text which is present at the top of what looks like ASM when I click on the (5) line in the stack above.
SwiftUI`(1) await resume partial function for dispatch thunk of static SwiftUI.PreviewModifier.makeSharedContext() async throws -> τ_0_0.Context:
If this (or any hierarchical view) used Previews, I'd remove them to see if it had an effect, but they don't! I'm at a loss on what to do here...
I've recently started learning how to make IOS apps, but when trying to load the preview, it just shows the loading animation indefinitely.
I am running xcode 15.2 (because my mac is a bit old and doesn't run the latest version)
I have tried using version 15.1 but it still doesn't work, only works when I go down to version 14.3.1, but that changes the swift code.
Hello! SwiftUI preview does not work. I tried different versions of Xcode, deleting the "Developer" folders, clearing the "Build" folder from the project in Xcode, reinstalling Command Line Tools and Developer Tools. I think that the error appeared after I cleaned Xcode with CleanMyMacX, before that the preview worked.
-MacBook Pro (15-inch, Mid 2012)
-macOS Catalina 10.15.7
-Xcode 12.3
Thanks for the feedback!
Hi everyone,
I’m encountering a strange issue when trying to archive my iOS app for App Store distribution. The project builds and runs fine on “Any iOS Device (arm64)”, but when I try to Product → Archive, I get multiple errors related to preview sections in my SwiftUI view files. The app uses camera for photo and video capture.
Errors:
• Cannot find 'PreviewCameraModel' in scope
• Cannot infer contextual base in reference to member 'video'
• Cannot infer contextual base in reference to member 'classify'
These errors only appear in code sections inside the #Preview blocks in SwiftUI files. Additionally:
When I click on an error in the Issue Navigator, the file shows the error momentarily but it disappears after less than a second.
The total error count decreases temporarily, but then it returns to the original number when clicking on other errors.
Build and Run works fine without any issues on devices and simulators, but these errors block the archiving process.
Workaround:
For now, I’ve resolved the issue by using #if DEBUG to exclude the preview code from release builds, but I’d prefer a cleaner solution if one exists.
System Details:
Xcode: 16.0
iOS Deployment Target: 16+
Swift: 5
Architecture: arm64
Has anyone encountered this issue or found a better way to handle SwiftUI preview code when archiving? Any advice on fixing this or insights into why the errors behave inconsistently during the archiving process would be appreciated.
Thanks in advance!
Hello,
I am currently creating a component in swiftUI and I would like on xcode to be able to select the elements individually with the selector button on the xcode preview on the canva but when I click on an element it selects all the iphone and not the element individually how can I do this please?
Xcode Preview is not working.
Successed to build Preview but error message displays like below:
I think it's maybe related with loader path followed by error details below.
I created xcproj file using tuist 4.19.0.
How can I fix this issue?
Error Details
I just downloaded XCode 16.0 and an iOS 18.0 simulator. This simulator works well, and I am also able to view my apps on my iPhone due to the 'XcodePreviews" app on my phone. However, the preview canvas refuses to load. Normally, it would just show itself upon opening the file up in XCode, but now every time I open a project it says "preview paused". When I refresh the canvas, it just loads. The build succeeds and I can view it in the simulator, but not the canvas. This also happens when creating an entirely new project. I would attach my canvas diagnostics report but I am unable to upload a file bigger than 244.140625Kb, so that's impossible to do.
Hi, I recently updated my Xcode, and I've been experiencing frequent crashes with the preview. Here’s a screenshot of the preview:
https://ibb.co/WnwWMjh
Hello!
My company makes use of SSL interception for its managed laptops (for various information security reasons). We've yet to find a good solution to avoid SSL cert errors in the Xcode Preview app. We've successfully installed/trusted our certs in the Xcode Simulator, but can't find any information on how to do the equivalent for the Xcode Preview. The inability to make use of the Preview App profoundly impacts productivity.
It appears the Xcode Preview doesn't share the same certificate store as the Simulator, nor does it make use of the Mac's system keychain (where the certificates are also installed and trusted). If there’s anyone you can think of who might know a way around this issue it would be greatly appreciated.
Many thanks!
After updated MAC OS I am getting this error in swift version 16.0 and MAC OS VERSION 15.0.1
note: Disabling previews because SWIFT_VERSION is set and SWIFT_OPTIMIZATION_LEVEL=-O, expected -Onone (in target 'Closures' from project 'Pods')
I am working on transitioning an existing UIKit based app to SwiftUI. After adding a first SwiftUI file to the project preview fails with:
Failed to launch app "MyApp.app" in reasonable time
The View code is the default templates, thus definitly not too complex:
import SwiftUI
struct OverviewPageView: View {
var body: some View {
Text("Hello, World!")
}
}
#Preview {
OverviewPageView()
}
Things I have tried:
Cleaning and rebuilding.
Changing the target device.
Using xcrun simctl shutdown all followed by scrub simctl erase all
Clearing the contents of my ~/Library/Developer/Xcode/UserData/Previews folder.
Clearing the contents of my ~/Library/Developer/Xcode/DerivedDatas folder.
Using xcrun simctl --set previews delete all
Restarting macOS and Xcode
The problem seems tpbe related to my project. When creating a fresh new project using "Storyboard" as interface and adding a SwiftUI file, the preview works fine. However, this does not help when working on my existing project...
I generated a preview diagnostics report.
I am using Xcode 16.0 on macOS 15.0
Bonjour,
Je me permet d'écrire un message car je rencontre un souci avec la vue canvas j'ai le message d'erreur suivant " CrashReportError: XCPreviewAgent crashed because Adjust.framework is missing" je ne sais pas trop comment identifié le problème j'utilise pod
En vous remerciant par avance
I’ve noticed a strange bug in Xcode 16 and Swift. When a preview is rendering and hasn’t finished yet and you run an app to debug, Xcode is launching two instances of the app. Has anyone else noticed this issue? If you let the preview finish rendering before running the app, this doesn’t happen. Very odd.
I’ve noticed a strange bug in Xcode 16 and Swift. When a preview is rendering and hasn’t finished yet and you run an app to debug, Xcode is launching two instances of the app. Has anyone else noticed this issue? If you let the preview finish rendering before running the app, this doesn’t happen. Very odd.
I have a project with a single asset image. In the dependency package, I am attempting to preview using the image in the project using Bundle.main. I just get a blank.
How can I get this to work?
Sample project here: https://github.com/AaronBratcher/SwiftUIPreviewProblem
I’ve recently begun learning how to utilize Xcode. I have an app in Xcode that closely resembles the iOS App template. Whenever I initiate a build, it successfully completes, but it never finishes installing views into the iOS Simulator. This issue is also present when I attempt to preview the app within the Xcode editor.
I am currently using a 2020 MacBook Air (M1). Have you encountered a similar problem? If so, how did you resolve it?
[Written using Apple Inteligence Writing Tools]
"Can not preview in this file"
Xcode 16.0
iPhone 14 Pro , iOS 18.0
When I choose to start Preview on my iPhone, the canvas screen keeps showing loading circle animation. The iPhone enters the Xcode Previews App but only displays the default screen (Xcode icon& 'Preview from Xcode')
I uploaded the some of diagnostics files
previews_diagnostics_summary.txt
remote_injection.json