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.
Xcode Previews
RSS for tagCreate an app UI and configure almost everything your users see using Xcode Previews.
Posts under Xcode Previews tag
113 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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
I have updated my firebase with the latest version, but on simulator, apple log in and parsing from firebase server is not working on iOS 18 when working fine on the actual test device. However iOS 17 simulator works perfect as X-Code 15.
And previews are not working as well with my current app coding, which was coded in previous X-code 15.
Is there any API changes? Any help?
Or 18.1 might fix this bug?
Here's a concise post for the Apple Developer Forums:
Title: Swift Macro for SwiftUI Previews Not Recognized in Xcode
Hello everyone,
I've developed a Swift macro swift-inject-preview that generates SwiftUI previews (PreviewProvider or #Preview). However, Xcode seems to ignore the previews generated by the macro, likely because it searches for PreviewProvider/#Preview or similar text in the file before macro expansion.
Has anyone encountered a similar issue or found a workaround for getting Xcode to recognize previews created through Swift macros?
Any help or insight would be greatly appreciated!
Thank you!
Daniil Voidilov
In the latest version of Xcode, breakpoints are not displaying correctly, making it difficult to track code behavior. Previously, Xcode allowed you to step through each function, showing clear execution steps and allowing interaction to debug effectively. However, now it only shows memory addresses without providing meaningful insights, limiting the ability to interact with or test the code as it's being developed. Is anyone else experiencing this issue, or does anyone know of a workaround?
While I am able to use #Preview to preview a Widget, it seems to be not possible to easily preview a Widget placeholder. With a "classic" preview I can use .redacted(reason: .placeholder), but this has limitation e.g. it will ignore .contentMarginsDisabled()
struct MyWidget_Previews: PreviewProvider {
static var previews: some View {
Group {
MyWidgetView(entry: SimpleEntry(date: .now, emoji: "😀"))
MyWidgetView(entry: SimpleEntry(date: .now, emoji: "😀"))
.redacted(reason: .placeholder)
}
.previewContext(WidgetPreviewContext(family: .systemMedium))
.containerBackground(.white, for: .widget)
}
}
If I use #Preview, the .redacted modifier won't work, and I seem to have to put it in the MyWidget implementation.
#Preview(as: .systemMedium) {
MyWidget()
} timeline: {
SimpleEntry(date: .now, emoji: "😀")
SimpleEntry(date: .now, emoji: "🤩")
}
Am I missing something?