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 preview crash continuously
Hi. Just update my MacBook Pro M1 with sequoia and Xcode and I got huge problem with preview on simply swiftui pages. This is the full report I got when the preview crash but if I run the app on the device or the simulator it works fine. How can I solve this situation? the crashing thread is number 6 which reports this: Thread 6 Crashed:: Dispatch queue: com.apple.root.user-initiated-qos 0 XOJIT 0x240b899f8 llvm::Error llvm::detail::UniqueFunctionBase<llvm::Error, llvm::jitlink::LinkGraph&>::CallImpl<xojit::ReplacementManager::Plugin::modifyPassConfig(llvm::orc::MaterializationResponsibility&, llvm::jitlink::LinkGraph&, llvm::jitlink::PassConfiguration&)::'lambda'(llvm::jitlink::LinkGraph&)>(void*, llvm::jitlink::LinkGraph&) + 1784 1 XOJIT 0x240c1b46c llvm::jitlink::JITLinkerBase::runPasses(std::__1::vector<llvm::unique_function<llvm::Error (llvm::jitlink::LinkGraph&)>, std::__1::allocator<llvm::unique_function<llvm::Error (llvm::jitlink::LinkGraph&)>>>&) + 76 2 XOJIT 0x240c1ab68 llvm::jitlink::JITLinkerBase::linkPhase1(std::__1::unique_ptr<llvm::jitlink::JITLinkerBase, std::__1::default_delete<llvm::jitlink::JITLinkerBase>>) + 72 3 XOJIT 0x240c2158c llvm::jitlink::link_MachO_arm64(std::__1::unique_ptr<llvm::jitlink::LinkGraph, std::__1::default_delete<llvm::jitlink::LinkGraph>>, std::__1::unique_ptr<llvm::jitlink::JITLinkContext, std::__1::default_delete<llvm::jitlink::JITLinkContext>>) + 3608 4 XOJIT 0x240c20400 llvm::jitlink::link_MachO(std::__1::unique_ptr<llvm::jitlink::LinkGraph, std::__1::default_delete<llvm::jitlink::LinkGraph>>, std::__1::unique_ptr<llvm::jitlink::JITLinkContext, std::__1::default_delete<llvm::jitlink::JITLinkContext>>) + 72 5 XOJIT 0x240c19cc8 llvm::jitlink::link(std::__1::unique_ptr<llvm::jitlink::LinkGraph, std::__1::default_delete<llvm::jitlink::LinkGraph>>, std::__1::unique_ptr<llvm::jitlink::JITLinkContext, std::__1::default_delete<llvm::jitlink::JITLinkContext>>) + 80 6 XOJIT 0x240c0acc0 llvm::orc::ObjectLinkingLayer::emit(std::__1::unique_ptr<llvm::orc::MaterializationResponsibility, std::__1::default_delete<llvm::orc::MaterializationResponsibility>>, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>) + 256 7 XOJIT 0x240bfcbfc llvm::orc::BasicObjectLayerMaterializationUnit::materialize(std::__1::unique_ptr<llvm::orc::MaterializationResponsibility, std::__1::default_delete<llvm::orc::MaterializationResponsibility>>) + 60 8 XOJIT 0x240be3f08 llvm::orc::MaterializationTask::run() + 44 9 XOJIT 0x240b97e1c invocation function for block in (anonymous namespace)::GCDTaskDispatcher::dispatch(std::__1::unique_ptr<llvm::orc::Task, std::__1::default_delete<llvm::orc::Task>>) + 108 10 libdispatch.dylib 0x1801774ec _dispatch_call_block_and_release + 24 11 libdispatch.dylib 0x180178de0 _dispatch_client_callout + 16 12 libdispatch.dylib 0x18018b864 _dispatch_root_queue_drain + 1208 13 libdispatch.dylib 0x18018bf60 _dispatch_worker_thread2 + 232 14 libsystem_pthread.dylib 0x104db7b38 _pthread_wqthread + 224 15 libsystem_pthread.dylib 0x104db6934 start_wqthread + 8 Full Report
5
5
4.3k
Sep ’24
Live Preview fails after adding 3rdParty libraries
With the latest Xcode 16 RC version, the Live Preview on iPhone device problem has been fixed. However, it still fails on the iPhone 16 pro preview emulator even for the simplest hello world view. Apparently in Xcode 16, introducing any 3rdParty package impacts the preview build, even if the package is not referenced in the view. I feel this is an incorrect behaviour. Following are the steps to reproduce the problem: Create a new iOS project in the latest Xcode 16 beta Select ContentView in the project and verify the live preview is working and fast Go the project’s Package Dependencies tab, add gRPC-Swift (https://github.com/grpc/grpc-swift.git) as a 3rdParty library of this project. Go the main project target, select General tab. Under Frameworks, Libraries, and Embedded Content section, add “GRPC” Go back to ContentView and verify its live preview rendering now takes very long time and eventually failed. Select Live Preview Diagnostic, verify error message: Failed to launch app ”PreviewBug.app” in reasonable time… I have also created a feedback to Apple: FB15110765
4
0
518
Sep ’24
Xcode 16 beta 6 LLVMError: LLVMError(description: "file too small to be an archive")
We are using TensorFlowLiteC XCFramework and encountering an issue. Download link: https://dl.google.com/tflite-release/ios/prod/tensorflow/lite/release/ios/release/30/20231002-210715/TensorFlowLiteC/2.14.0/883c6fc838e0354b/TensorFlowLiteC-2.14.0.tar.gz Whenever this framework is linked, Previews fail with the following error: == PREVIEW UPDATE ERROR: FailedToLaunchAppError: Failed to launch cg.Xcode16TensorPreviewsRepro ================================== | [Remote] JITError | | ================================== | | | [Remote] LLVMError | | | | LLVMError: LLVMError(description: "file too small to be an archive") Since Xcode 16 will soon be the IDE for all our devs, it would be great if the community or Xcode Previews team could share any workarounds or solutions for this issue. FB(reproducer + additional diagnostics): https://feedbackassistant.apple.com/feedback/15084788 Thanks
1
1
967
Sep ’24
Can't view SwiftUI previews on Vision Pro because of code signing
Hello! I'm making an app for VisionOS. I can run the app on my Vision Pro, and I can see the SwiftUI previews in the simulator, but for some reason the previews refuse to run on the device. Here's what I'm seeing: == PREVIEW UPDATE ERROR: AppHostMustHaveGetTaskAllowError: Cards.app not code signed properly ”Cards.app” must be code signed in order to use on-device previews. Check your code signing settings for the target. As far as I can tell, the code signing settings are correct because the app itself runs just fine on the device. I'm not sure what to do…
1
0
482
Sep ’24
Xcode 16.0 beta 6: Preview: Permission denied
I'm having two users on my MBP and one user has an issue with Xcode Preview. - I thought this was a known issue and solve in an older beta version, but I still got the issue Xcode 16.0. beta 6 Cannot preview in this file XOJITError: Could not create code file directory for session: Permission denied multiple (admin) users, but one user has the issue, the other user not
2
1
619
Sep ’24
PreviewShell crashes and breaks the preview canvas
Since the first beta of Xcode 16, randomly when editing a SwiftUI view a crash report opens with the message "PreviewShell quit unexpectedly." After that, annoyingly often the canvas fails to reload correctly, and shows this broken thing: The only way to get it working again is to restart Xcode, but it happens so often that it really impacts productivity. Does this happen to anyone else? If so, have you found a solution? I've already filed a report (FB14876223)
9
8
3.2k
Sep ’24
AppStore Preview stuck in "Processing"
Im submitting a new App yesterday and included a video preview file for several size devices (6.7, and a copy of 6.7 for 6.5, 5.5 and 12.9). The iPhone files each took 5-10 minutes of processing (where the file icon shows a cloud image) but each eventually worked. All files uploaded fine, but now many hours later a preview file (video) is still processing - is still showing a cloud icon. All these uploaded preview files are about the same size at about 40M. The AppStore will not allow me to submit the App for review due to: Preview File Still Processing! What is my recourse?
0
0
433
Aug ’24
Xcode Previews broken after setting different bundle identifier for debug/release modes
I wanted to be able to install both an App Store/Release version and a development version of my app on the same device and have them access different persistent stores, so I changed the bundle identifier of my app for the debug build configuration to "com.kevinolmats.Guru.debug", while the release configuration stayed as "com.kevinolmats.Guru". Since then, Xcode previews have completely stopped working. After a long build time, the canvas displays Cannot show preview: check whether the preview is compiled for the current scheme and OS of the device used for previewing. The only things I have changed are: the bundle identifier for the debug configuration the product and bundle names (debug config is now Guru (debug)) added a new entitlements file for the debug configuration Any ideas as to why my previews have stopped working? Enable previews is set to on, and the usual troubleshooting steps (restarting Xcode, my computer, deleting DerivedData) have not helped. The app runs perfectly fine otherwise--it's just previews that are broken.
2
1
646
Aug ’24
Xcode 16 no longer sets ENABLE_PREVIEWS=YES for preview builds
Up until now, it was possible to check in build scripts via the ENABLE_PREVIEWS environment variable whether a build for a SwiftUI preview is being executed. In addition, it was also possible to conditionally compile code for SwiftUI or exclude it from compilation using this variable. This no longer works with Xcode 16 and the new SwiftUI Preview compilation! There is still the option to switch to the old system with the "Use Legacy Previews Execution" setting, but as stated in the release notes, this option will be removed at some point. Which brings us back to the old problem of not being able to exclude build scripts from preview builds and not being able to prevent certain code from being compiled / add special code for SwiftUI previews. This is a terrible situation, especially for more complex projects in which precisely the points mentioned are important for the build process. I seriously hope Apple provides us with another environment variable for SwiftUI preview builds that we can use.
12
15
5.8k
Feb ’25
Xcode Preview says:Cannot preview in this file: Failed to launch (App Name)
When I attempt to preview my code, I encounter an error message stating, “Cannot preview in this file: Failed to launch (App Name).” This issue is specific to this particular app. I attempted creating a new project, and that works fine. This is what it says in the diagnostics: | [Remote] JITError | | ================================== | | | [Remote] LLVMError | | | | LLVMError: LLVMError(description: "The file was not recognized as a valid object file")
12
3
2.6k
Dec ’24
XCode Previews
Hello... for some reason, XCode previews are no longer working for me. It was working fine a week ago, however, now no matter ho many times i reboot or restart my computer, the preview won't load. The preview is stuck on "loading Preview" no matter how long I wait. I ran the same files on swift playgrounds and the preview works fine there, but not on XCode. I ran both my project and a completely new, unedited project and both will not preview- so I know it is not a problem with my file. Also, the second I open the app the preview pauses. Either way, I don't think an app with only one file should take so long to build...
2
1
647
Jul ’24
Vision Pro preview window looks different than on simulator
Hello, I have a simple SwiftUI view that shows this bottom bar in the view and I noticed that in SwiftUI previews the 2D window is squared off while in the simulator it has rounded edges. This effects the bottom bar because as you can see in the simulator the text is cut off. I am using Xcode 16 beta and visionOS 2 beta. Why do the two windows look different? And I am surprised the text is getting cut off in the rounded window. SwiftUI Preview: Vision Pro Simulator
6
0
915
Jul ’24
SwiftUI preview with different @AppStorage values
I have SwiftUI views, which access the user defaults by using the property wrapper @AppStorage. Now I would like to have a preview with multiple variations of the view depending on the same user default with different values. Is there a pure way to do that? Currently I have a solution which is very probably a hack and supports only one variation of the user default. To do that I define the user settings in a sub views onAppear() method: struct MyTestedView_Previews : PreviewProvider { static var previews: some View { VStack { VStack { MyTestedView .previewLayout(.sizeThatFits) } .onAppear{ UserDefaults.standard.set(true, forKey: "myConsumedKey") } //VStack //{ // MyTestedView // .previewLayout(.sizeThatFits) //} //.onAppear{ // UserDefaults.standard.set(false, forKey: "myConsumedKey") //} } } } When I have two VStack for different variations and I set the user defaults to different values in their onAppear(), only one user default value wins and I see one variation of my view twice. What I also don't like on my solution, is that I don't know where this user default is stored. Is it stored temporary in the memory or do I even manipulate Xcode's user defaults? Does anybody know if SwiftUI has already a solution to test different variations of user defaults in the preview?
2
0
1.1k
Jul ’24
How to change the background color of the status bar in SwiftUI when creating a custom NavigationController View
I wanted to experiment a little using UINavigationController with SwiftUI App Lifecycle I created a Custom Navigation Controller named JDNavigationController. It does not do much other than having the @Observable macro public struct NavigationControllerStack<Content: View>: UIViewControllerRepresentable { private let initialView: () -> Content @State private var controller = JDNavigationController() public init(content: @escaping () -> Content) { self.initialView = content } public func makeUIViewController(context: Context) -> JDNavigationController { let viewController = self.initialView() .environment(self.controller) .viewController self.controller.viewControllers = [ viewController ] return controller } public func updateUIViewController(_ uiViewController: JDNavigationController, context: Context) { } public typealias UIViewControllerType = JDNavigationController } when I check, the functionality of the navigation controller works as expected, however, I can't for the life of me to change the background color of the status bar. #Preview { NavigationControllerStack { ZStack { Color.purple .ignoresSafeArea(.all) VStack { Text("somethign") } } } } I have tried Using the appearance functions Creating a Custom View Controller, and in that view controller I tried using a Hosting Controller by adding the hosting controller as a child and setting hostingController.view.insetsLayoutMarginsFromSafeArea = false using the toolbar modifiers from SwiftUI View none seems to work. I opened the View Debugger it looks like the white portion comes from the UIHosting Controller but I am not sure what I can do to fix it
6
0
1.6k
Jul ’24
Xcode 16 Previews: Always crash when compilation mode is WMO
This can be easily reproduced in a vanilla Xcode 16 beta 3 project. Steps Create a new project. By default, previews work fine because default SWIFT_COMPILATION_MODE is Incremental. (aka Batch Mode) Now, change it to WMO, and notice the previews crash with the enclosed crash report. Feedback filed with reproducer + diagnostics + crash report: https://feedbackassistant.apple.com/feedback/14268698 We have observed that enabling Whole Module Optimization (WMO) improves build times in our project. Therefore, if Previews can be compatible with WMO, it would be highly beneficial. Otherwise, it would be helpful to provide a warning or feedback to developers, as many projects are likely utilizing WMO, and identifying issues solely from crash reports can be challenging. Note: This works all fine with the Legacy Previews Engine in Xcode 15/16.
1
0
840
Jul ’24
Xcode 16 Previews: dyld Loader Crash
We have been seeing a dyld loader crash when trying out the new Previews engine in Xcode 16 beta 3. Feedback filed with reproducer + diagnostics: https://feedbackassistant.apple.com/feedback/14323960 Investigation: Running nm -a on the debug dylib reveals duplicate SO entries pointing to SomeStatic.swift. One entry originates from the LibAStatic module, while the other comes from the LibBStatic module. Local workaround - 1 Providing unique file names resolves the issue. However, these files are in different modules, so ideally, this shouldn't be necessary. Our codebase is extensive, and many code-generated modules have the same file names. Therefore, renaming files to ensure uniqueness is not a simple solution for us due to various complexities. Local workaround - 2 Making these dependencies dylibs instead of static libraries also resolves the issue. However, we can't pursue this direction because a significant portion of our pre-build setup, foundations, and vendor linkages are statically linked. Note: The same flow works with "Legacy Preview Engine in Xcode 16/15" but dynamic replacement has other issues, which we are super happy that the new engine doesn't make use of. This issue is currently a blocker for us in trying out the new Previews in our project, it would be highly beneficial if this problem could be resolved soon.
1
0
677
Jul ’24