Xcode Previews

RSS for tag

Create an app UI and configure almost everything your users see using Xcode Previews.

Xcode Previews Documentation

Posts under Xcode Previews tag

167 Posts
Sort by:
Post not yet marked as solved
5 Replies
1.5k Views
Following article Creating a widget extension on developer.apple.com (https://developer.apple.com/documentation/widgetkit/creating-a-widget-extension) I encountered a problem with XCode preview: it shows an error with message | RemoteHumanReadableError: Failed to launch agent | No plugin is registered to launch the process type widgetExtension. Can someone help me? macOS 13.4 XCode 14.3.1
Posted
by Ratka6.
Last updated
.
Post not yet marked as solved
31 Replies
19k Views
Summary When trying to display SwiftUI previews, building the previews may fail with the following error: Linking failed: linker command failed with exit code 1 (use -v to see invocation) ld: warning: search path '/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator' not found ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found Note that may app does not use CoreAudioTypes. Observation This issue seems to occur when two conditions are met: The SwiftUI view must be located in a Swift Package Somewhere in either the View or the #Preview a type from another package has to be used. Say I have to packages one named Model-package and one named UI-Package. The UI-Package depends on the Model-Package. If I have a SwiftUI view in the UI-Package that uses a type of the Model-Package either in the View itself or in the #Preview, then the described error occurs. If I have a View in the UI-package that does not use a type of the Model-Package anywhere in its View or #Preview then the SwiftUI Preview builds and renders successful. I created a bug report: FB13033812
Posted Last updated
.
Post not yet marked as solved
2 Replies
388 Views
Hello! I'm studying swift in college now, and have encountered a problem previewing my code using canvas. Here's part of the code: struct ContentView: View { ......(omitted) var body: some View{ ScrollView{ cards Spacer() cardsAdjuster } } The canvas panel looks all right with the line "ScrollView", as the image shows, with the only problem that "cardsAdjuster" moves with the cards. But if I remove the line "ScrollView", the panel went wrong: As the image displays, all parts of body are displayed separately, and I can't find any setting options to merge them. (Take a look at the top of the screenshot) The problem is also found on my classmate's Xcode 12 running on macOS Monterey. Looking forward to your reply and thoughts. Thank you all!!
Posted
by RoddySu.
Last updated
.
Post not yet marked as solved
1 Replies
243 Views
I am new to Xcode and trying to learn and having issues with errors it seems. I believe the problem is specifically with my code not being able to be displayed on the example iPhone on the right hand side of the screen. Here are the 2 errors I receive below. The codes at the very bottom are red on my screen so I am guessing those are what is most important out of all of this. Thanks and please let me know if I can answer any additional questions regarding this. Ld /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Products/Debug-iphonesimulator/Playground.app/Playground normal (in target 'Playground' from project 'Playground') cd /Users/tward/Desktop/Playground.swiftpm /Users/tward/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-ios15.2-simulator -isysroot /Users/tward/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -L/Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Products/Debug-iphonesimulator -L/Users/tward/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib -F/Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Products/Debug-iphonesimulator -F/Users/tward/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -iframework /Users/tward/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -iframework /Users/tward/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk/Developer/Library/Frameworks -filelist /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Objects-normal/x86_64/Playground.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../lib -dead_strip -Xlinker -object_path_lto -Xlinker /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Objects-normal/x86_64/Playground_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Users/tward/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Objects-normal/x86_64/Playground.swiftmodule -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Playground.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Playground.app-Simulated.xcent.der -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Intermediates.noindex/Playground.build/Debug-iphonesimulator/Playground.build/Objects-normal/x86_64/Playground_dependency_info.dat -o /Users/tward/Library/Developer/Xcode/DerivedData/Playground-aoepzfpfzcxxqggglpllgxkoywsr/Build/Intermediates.noindex/Previews/Playground/Products/Debug-iphonesimulator/Playground.app/Playground ld: entry point (_main) undefined. for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Posted
by Tybward.
Last updated
.
Post not yet marked as solved
1 Replies
289 Views
Menu > Editor > Canvas > Export Preview Screenshot Got error message: Stream with endpoint 'C5C6DCA4-D146-451F-8BA8-AF83657E4CC7' is invalidated I don't collect diagnostic data.
Posted
by Gong.
Last updated
.
Post not yet marked as solved
7 Replies
884 Views
I have a Swift Package Manager module with some SwiftUI files that I was using Previews without issues in Xcode 15.2. When I upgraded to Xcode 15.3, it fails with “Cannot preview in this file. Unexpected error occurred”. When I click to get more info, this is the error: == PREVIEW UPDATE ERROR: HumanReadableSwiftError BuildError: failedToGenerateThunkInfo(could not generate preview info: noTargetBuildGraph) Is anyone experiencing the same problems? My preview, which lives in a SPM package, works totally fine in Xcode 15.2, but fails in Xcode 15.3. Any ideas for how to fix it? I've tried deleting DerivedData, resetting package caches, clean building. So frustrating seeing these regression issues popping up still. I filed FB13678356 but it was quickly marked as "Investigation Complete - Unable to diagnose with current information" but there was no request for what further information I could provide! I attached a full sysdiagnose and error log! Would also note, that when I revert back to Xcode 15.2, the previews go back to working...
Posted Last updated
.
Post not yet marked as solved
2 Replies
292 Views
I keep getting the error: "Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's." I don't know why. The only thing I can think of is that my iPhone is signed into a different Apple ID than the one I'm using for my Xcode signing. But I'm not sure because I can't find any info about it online.
Posted
by jjtrejo.
Last updated
.
Post not yet marked as solved
0 Replies
363 Views
The preview or editor canvas is not working in my xcode app. I have updated my computer, updated the app, deleted and reinstalled the app, done cmd+shift+k, turned off automatically refresh canvas, tried previewing it on an older model iphone, but havent found a solution. Message me for my feedback id and disagnostic report, because it is not leeting me add it without being flagged for sensitive content
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.5k Views
I'm trying to preview a SwiftUI view that resides in a local Swift package. I have the Swift package selected as the current scheme, so all the proper dependencies are available and the build succeeds. But I see this message in the Preview window: Cannot show preview: check whether the preview is compiled for the current scheme and OS of the device used for previewing How do I ensure the preview is compiled for a particular scheme and device OS? I updated MacOS to 14.3.1 and Xcode to 15.3 in the hopes that that might fix this issue, but it did not.
Posted Last updated
.
Post marked as solved
4 Replies
482 Views
Building in visionOS and one of my Swift UI views keeps causing Xcode to crash. The root issue is within the preview code, stuck on updating the preview code to prevent Xcode from crashing. When I run the simulator the app works perfectly, no bugs or issues. Any advice on how to update the preview code would be very helpful :) import RealityKit import RealityKitContent struct BrandImage: View { @State private var currentIndex: Int = 0 @Environment(\.openWindow) private var openWindow @EnvironmentObject var sharedAppState: SharedAppState var brand: [BrandEcommData] var initialBrand: BrandEcommData init(brand: [BrandEcommData], initialBrand: BrandEcommData) { self.brand = brand self.initialBrand = initialBrand if let initialIndex = brand.firstIndex(where: { $0.id == initialBrand.id}) { _currentIndex = State(initialValue: initialIndex) } } var body: some View { HStack(spacing: 0) { ZStack { ForEach(0..<brand.count, id: \.self) { index in if index == currentIndex { VStack { Text(brand[index].brand) .padding(.top, 5) brand[index].image .resizable() .scaledToFit() } .transition(.scale) } } HStack { Button(action: { withAnimation { self.currentIndex = (self.currentIndex - 1 + brand.count) % brand.count sharedAppState.currentModelId = brand[currentIndex].id } }) { Image(systemName: "arrow.left.circle.fill") .font(.largeTitle) .foregroundStyle(.linearGradient( colors: [.black, .gray], startPoint: .top, endPoint: .bottom)) } .padding(.leading, 20) Spacer() Button(action: { withAnimation { self.currentIndex = (self.currentIndex + 1) % brand.count sharedAppState.currentModelId = brand[currentIndex].id } }) { Image(systemName: "arrow.right.circle.fill") .font(.largeTitle) .foregroundStyle(.linearGradient( colors: [.black, .gray], startPoint: .top, endPoint: .bottom)) } .padding(.trailing, 20) } VStack { HStack { Spacer() Button(action: { openWindow(id: "volumetric") }) { Image(systemName: "cube.transparent") .font(.title) .padding() .foregroundStyle(.linearGradient( colors: [.black, .gray], startPoint: .top, endPoint: .bottom)) } } Spacer() } } .frame(maxWidth: .infinity) Rectangle() .frame(width: 2) .foregroundStyle(.linearGradient( colors: [.black, .gray], startPoint: .top, endPoint: .bottom)) VStack { Text(brand[currentIndex].name) .font(.title2) Text(brand[currentIndex].itemDetail) .font(.subheadline) Text(brand[currentIndex].itemDescription) .padding() Text(brand[currentIndex].price) } } .onAppear { sharedAppState.currentModelId = initialBrand.id } } } #Preview { if let initialBrand = ecommdata?.first { BrandImage(brand: ecommdata!, initialBrand: initialBrand) } else { Text("Unable to load 3D Asset") } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
262 Views
I am working on a 2018 Macbook Air. Here is the diagnostic that is generated. previews_diagnostics_summary.txt
Posted
by ilyba.
Last updated
.
Post not yet marked as solved
2 Replies
516 Views
Anyone else having issues in Xcode preview where when you tap on a button to open a volume window nothing appears in the Xcode preview window? For example, if you download the Hello World Xcode project and try to open the globe volume after tapping the toggle button, the globe volume window never opens. Running the latest version of Xcode 15.3 beta.
Posted Last updated
.
Post not yet marked as solved
3 Replies
384 Views
I'm new to Xcode, and I'm learning using the apple swiftUI tutorial: https://developer.apple.com/tutorials/swiftui/creating-and-combining-views I did the first few steps, but I can't get the simulator preview to work. My mac and Xcode are updated, but I can't it to load. Everything works fine when I do a mac project. Thanks in advance.
Posted
by ncote.
Last updated
.
Post marked as solved
1 Replies
380 Views
Does an 'archive build' require 'preview content'? I've put swift source files into 'Preview Content' directories - one directory for the top-level App and one for an embedded framework. An 'archive build' fails, complaining about the code in a #Preview block. #Preview { // the archive build fails to find this `default` ?? let controller = PersistenceControllerTopLevelPreview.default let user = controller.user ... The framework has its 'Preview Context' specified in the Development Assets; same with the top-level App.
Posted
by GoZoner.
Last updated
.
Post not yet marked as solved
1 Replies
562 Views
Is the preview set to read-only mode in Xcode 15? Drag and drop of any library items to preview canvas doesn't work. Is this feature removed in Xcode 15? (I don't want to believe that it was so helpful)
Posted
by alexey3m.
Last updated
.
Post not yet marked as solved
8 Replies
2.5k Views
SwiftUI preview hangs on "Preparing iPhone Simulator for Previews". Also simulator hangs when trying to build and run. This occurred after I installed iOS 17 simulator. I tried reverting back to an iOS 16 version of the simulator, but haven't figured out how to do that. Build and run to an iPhone device works fine. Any ideas would be appreciated. Thanks.
Posted
by dekyte.
Last updated
.
Post not yet marked as solved
3 Replies
454 Views
Hello, I am a UIKit developer and I would like to try out SwiftUI. Unfortunately, my previews don't load. My situation is like the one described in this blog post: https://forums.developer.apple.com/forums/thread/704036. Unfortunately I can't update Xcode like that developer did. What I've tried: quitting and restarting Xcode, restarting my computer, resetting the simulator, deleting the derived data folder, creating new projects without storage options, test bundles or source control, editing the content view of the initial Hello World file. To be clear, I've just started learning about SwiftUI, just yesterday evening, and the previews have never loaded. Is the problem solvable? If so, how?
Posted
by Filippo02.
Last updated
.