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.
Xcode Previews
RSS for tagCreate an app UI and configure almost everything your users see using Xcode Previews.
Posts under Xcode Previews tag
139 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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?
In XCode 16, there's the Canvas section within Editor.
This is XCode 16.1 beta. "Canvas" subitem appears in Search but does not appear under Editor section
Previews do not work for me without using Legacy Previews Extension, so I can no longer use Previews at all with XCode 16.1 Beta.
Why was Canvas subsection under Editor removed?c
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
I want to add SwiftUI to an existing package. Super simple to get started. It previews with Xcode 15.4, but gives an error on Xcode 16.0: JITError: Runtime linking failure
Anyone have an idea on what may be failing?
Full SwiftUI code:
import SwiftUI
struct Dashboard: View {
var body: some View {
Text("hello")
}
}
#Preview {
Dashboard()
}
AppLaunchTimeoutError: Failed to launch app ”x.app” in reasonable time
The app ”x.app” did not launch on ”iPhone 15 Pro” in 15 seconds.
it always show that error, when it show i have to apply this command on terminal
xcrun simctl --set previews delete all
but after 30 seconds, i am facing with same issue.
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
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
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…
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
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)
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?
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.