Xcode Previews

RSS for tag

Create 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

Xcode 15 preview loads indefinitely
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.
1
1
497
Dec ’24
Failed to preview SwiftUI app for macOS in Xcode 12.(0, 1, 3, 4).
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!
1
0
379
Oct ’24
Errors in SwiftUI Preview Code When Archiving for App Store Distribution in Xcode 16.0
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!
1
0
593
Oct ’24
XCode 16 Canvas Preview Won't Work
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.
5
0
3.1k
Oct ’24
SSL Cert Interception | XCode Preview
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!
1
0
517
Oct ’24
Xcode 16.0 + SwiftUI: Failed to launch app "MyApp.app" in reasonable time
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
3
2
785
Oct ’24
The iOS Simulator and preview in Xcode takes forever to load
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]
1
0
630
Oct ’24
Xcode Canvas preview connected to iPhone error
"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
7
0
729
Oct ’24
Firebase is not working on X-code 16 iOS 18 simulator
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?
1
0
1.2k
Sep ’24
Swift Macro for SwiftUI Previews Not Recognized in Xcode
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
1
0
334
Sep ’24
Xcode do not pause at breakpoints
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?
1
1
497
Sep ’24
#Preview a Widget placeholder?
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?
1
0
549
Sep ’24