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

166 Posts
Sort by:
Post not yet marked as solved
1 Replies
583 Views
Have a fairly large project in production and after updating Xcode from 14.x to 15.x the previews are no longer working. Devs in our team are using various Apple silicon machines. Error: == PREVIEW UPDATE ERROR: FailedToLaunchAppError: Failed to launch com.utr.utrplay ================================== | RemoteHumanReadableError: The operation couldn’t be completed. Transaction failed. Process failed to launch. (process launch failed) | | BSTransactionError (1): | ==error-description: Process failed to launch. | ==NSLocalizedFailureReason: Transaction failed. Process failed to launch. (process launch failed) | ==transaction: <FBApplicationProcessLaunchTransaction: 0x600003b240e0> | ==precipitating-error: Error Domain=FBProcessExit Code=64 "The process failed to launch." UserInfo={NSLocalizedFailureReason=The process failed to launch., BSErrorCodeDescription=launch-failed, NSUnderlyingError=0x600000c2fb40 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600000c2ea90 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}} | ==error-reason: process launch failed
Posted
by
Post not yet marked as solved
2 Replies
471 Views
https://developer.apple.com/forums/thread/731732 Possibly linked to the above issue The app compiles just fine, but SwiftUI Previews cannot build if there any any packages that lack support for visionOS I made sure that filters were enabled so that the package is only linked to iOS In a project that literally NEVER imports or uses an iOS only package, it fails completely == PREVIEW UPDATE ERROR: SchemeBuildError: Failed to build the scheme ”VisionHelloWorld” 'tracks(withMediaType:)' is unavailable in visionOS Compile LightCompressor.swift (arm64): /Users/bryananderson/Library/Developer/Xcode/DerivedData/VisionHelloWorld-dviwzruidaouzeeafminiifghzfe/SourcePackages/checkouts/LightCompressor_iOS/Sources/LightCompressor/LightCompressor.swift:123:47: error: 'tracks(withMediaType:)' is unavailable in visionOS guard let videoTrack = videoAsset.tracks(withMediaType: AVMediaType.video).first else { ^~~~~~ AVFoundation.AVAsset:17:15: note: 'tracks(withMediaType:)' has been explicitly marked unavailable here open func tracks(withMediaType mediaType: AVMediaType) -> [AVAssetTrack]
Posted
by
Post not yet marked as solved
1 Replies
414 Views
I've encountered while attempting to integrate SwiftUI into an existing UIKit project. Specifically, I have experienced recurring view crashes when creating new SwiftUI views within the project. My Feedback id is FB13509337 I would appreciate your assistance in resolving this matter promptly, as it is critical to the development of our application. Your prompt attention to this issue would be greatly appreciated
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
I am having issues trying to use previews in the xcode 15.1. I am using MacOS Sonoma and iOS 17.2 and am struggling using previews. the preview never loads.it keeps on saying cannot preview in this file. previews_diagnostics_summary.txt
Posted
by
Post not yet marked as solved
2 Replies
515 Views
I have same code in Xcode and Playground. But Xcode is not previewing the View the right way. Here is a screenshot of Xcode: and here is the screen of Playground: when i run the code (command + R) it's working fine and i get the true preview in the app (just like what i get in Playground). Am I doing something wrong or is it a bug?
Posted
by
Post not yet marked as solved
0 Replies
391 Views
I'm using iXGuard for my Unity Project and need to build on XCode with iXGuard Toolchains (Xcode menu -> Toolchains -> select iXGuard Toolchains, and also need to add a new script for Post Action (Product -> Scheme -> Edit Scheme -> Archive -> Post-actions ) The question is how can I setup/add in Unity to configure for it instead of manual configure on Xcode?
Posted
by
Post not yet marked as solved
1 Replies
347 Views
Hi, I just learn swiftUI and trying to preview it on my device (iPhone 15 Pro Max), however the app is failed to launch on my device. I haven't change anything on the code yet. Here's the error message from diagnostic == PREVIEW UPDATE ERROR: FailedToLaunchAppError: Failed to launch swplayground.MQ ================================== | MessageError: Connection interrupted | | ================================== | | | MessageSendFailure: Message send failure for &lt;ServiceMessage 28: relaunch&gt;
Posted
by
Post not yet marked as solved
1 Replies
1.5k Views
I work on my project on two computers. One of them is older and stuck at Xcode 13. My project targets iOS 15+. Previously I was able to bounce back and forth between the two, checking code into source control in between. After doing a bunch of work on one of them over an extended period, I've returned to my older one and checked out the code... only to be unable to build because Xcode balks at every use of #Preview. I didn't change any project settings in the meantime, so I have no idea why this is suddenly a problem... Edit: It turns out that this is because previous versions of the SDK did not use this macro. Because I created a couple of new SwiftUI files on the newer OS and Xcode/SDK, it plopped #Preview into the new files instead of the previous implementation, PreviewProvider. I'll leave this post up for anyone who searches on this problem, since I found zero other references in a general Web search.
Posted
by
Post marked as solved
2 Replies
370 Views
I am getting Preview Crash. If I remove line 30 below. then the Preview Crash does not occur. I have Restarted XCode, I have done a Project Clean, Then did a project rebuild. I have also Created a new Project from scratch Named the project Debug, Add one new View File named MaskBootCamp once I select MaskBootCamp The Preview willl Crash with an Circle with a Red X in the center With Preview Crashed. If I remove line 22 all is resolved and no exception occurs Is this a Swift Bug or some error in the coding? Excepition Report listed below the code. report Below: ** MaskBootCamp .swift ** import SwiftUI struct MaskBootCamp: View { @State var rating: Int = 0 var body: some View { ZStack{ starsView .overlay(overlayView.mask(starsView)) } } private var overlayView: some View { GeometryReader { geometry in ZStack(alignment: .leading) { Rectangle() .foregroundColor(.yellow) .frame(width: CGFloat(rating) / 5 * geometry.size.width) } //allowsHitTesting(false) } } private var starsView: some View { HStack{ ForEach(1..&lt;6) {index in Image(systemName: "star.fill") .font(.largeTitle) .foregroundColor(.gray) .onTapGesture { rating = index } } } } } #Preview { MaskBootCamp() }
Posted
by
Post not yet marked as solved
2 Replies
512 Views
Hello! Being a beginner in creating and editing views using swiftUI, I am unsure of the current situation that I am presently in, and would be grateful for any advice or suggestions for the below problem. For some context, I have recently begun exploring the "Capturing depth using the LiDAR camera" Documentation using AVFoundation and intend to change its ContentView file which is currently written in swiftUI. The problem: I am unable to preview the SwiftUI code. When I try to resume the Preview Pane on the right
Posted
by
Post not yet marked as solved
1 Replies
315 Views
I'm working on a horizontally scrollable header view. I'd like to implement the following behavior: when users tap on the left/rightmost header items, the header would scroll so they become fully visible. I am using a custom PreferenceKey to report the selected index: struct SelectedTabPreference: PreferenceKey { static var defaultValue: Int = 0 static func reduce(value: inout Int, nextValue: () -> Int) {} } Then in my view, I wrap my content inside a ScrollViewReader to scroll to the selected header: struct ContentView: View { let tabs: [DrawerTab] @State private var selectedIndex: Int = 0 var body: some View { ScrollViewReader { scrollProxy in ScrollView(.horizontal, showsIndicators: false) { TopTabView(options: tabs, selectedIndex: $selectedIndex) .padding(32) .background(Color.clear.preference(key: SelectedTabPreference.self, value: selectedIndex)) } .onPreferenceChange(SelectedTabPreference.self) { value in let firstTabSelected = value == 0 let lastTabSelected = value == tabs.count - 1 guard firstTabSelected || lastTabSelected else { return } withAnimation { let anchor: UnitPoint = firstTabSelected ? UnitPoint(x: 0.1, y: 0) : UnitPoint(x: 0.9, y: 0) scrollProxy.scrollTo(tabs[value], anchor: anchor) } } } } } This works well when I run the app, but the Xcode Preview only shows a white screen. In fact, if I include this view as a subview in other views, their previews also break. The Preview only returns to life if I remove the programmatic scrolling: scrollProxy.scrollTo(tabs[value], anchor: anchor) I'm pretty sure this has to do with the ScrollViewProxy as my other Preference-based layouts work with Previews, but I don't know how to resolve the issue. Xcode Previews are an integral part of my workflow, and I'd like to avoid losing them if there's a chance.
Posted
by
Post not yet marked as solved
8 Replies
1.8k Views
Hi, I am trying to use SwiftUI in my project where I was using UIKit only, until now. The problem is that Preview in Xcode is not working even for very simple View with Text("Hello World"). Code is correct and project is possible to build and run. Even when I try to select real device (real iPhone) I can see Preview in my device. But preview in simulator is not working. Can someone help me with this? I am attaching diagnostic from Xcode and file from ~/Library/Logs/DiagnosticReports/ Thanks for help xcode_preview.txt findmylocated-2023-11-08-133122.ips.txt
Posted
by
Post not yet marked as solved
1 Replies
546 Views
Hello, SwiftUI previews are not working in my project : when I try to display the preview in Xcode, I got this error : And if I click on the help icon, here is the complete error message : RemoteHumanReadableError: Invalid preview service message on ServiceHub channel ================================== | RemoteHumanReadableError | | PropertyListError: Property list missing value for required key ”binaryType” | Property list: ["agentRole": previews, "environment": { | "DYLD_FRAMEWORK_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator"; | "DYLD_LIBRARY_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator"; | "OS_ACTIVITY_DT_MODE" = YES; | "PACKAGE_RESOURCE_BUNDLE_URL" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphoneos"; | "SQLITE_ENABLE_THREAD_ASSERTIONS" = 1; | "XCODE_RUNNING_FOR_PREVIEWS" = 1; | "__XCODE_BUILT_PRODUCTS_DIR_PATHS" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator"; | "__XPC_DYLD_FRAMEWORK_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator"; | "__XPC_DYLD_LIBRARY_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator"; | }, "__unique_service_message_identifier": 4, "deviceEnvironment": { | "SIMULATOR_CAPABILITIES" = "/Applications/Xcode 14.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone 14 Pro Max.simdevicetype/Contents/Resources/capabilities.plist"; | "SIMULATOR_DEVICE_NAME" = iPhone4Simulator; | "SIMULATOR_LEGACY_ASSET_SUFFIX" = iphone; | "SIMULATOR_MAINSCREEN_HEIGHT" = 2796; | "SIMULATOR_MAINSCREEN_PITCH" = "460.000000"; | "SIMULATOR_MAINSCREEN_SCALE" = "3.000000"; | "SIMULATOR_MAINSCREEN_WIDTH" = 1290; | "SIMULATOR_MODEL_IDENTIFIER" = "iPhone15,3"; | "SIMULATOR_PRODUCT_CLASS" = D74; | }, "agentIdentifier": { | bundleID = "com.apple.dt.XCPreviewAgent"; | discriminant = bundleID; | }, "displaySize": { | height = 932; | width = 430; | }, "deviceIdentifier": com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro-Max, "processType": application, "arguments": <__NSArray0 0x1b9e04f48>( | | ) | , "workspaceID": E4CEE565-58C6-4EB5-94F1-7A9F48791515, "deviceType": simulated, "payloadUsedAgentIdentifier": 1, "frameBufferMaskPath": /Applications/Xcode 14.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone 14 Pro Max.simdevicetype/Contents/Resources/framebuffer.pdf, "displayScale": 3, "bundleID": com.apple.dt.XCPreviewAgent] ================================== | MessageSendFailure: Message send failure for <ServiceMessage 4: relaunch> Is there anyone who already encountered this error message? Or maybe anyone who have any idea how to solve it? Thanks, Alexandre
Posted
by
Post not yet marked as solved
2 Replies
396 Views
Ich bin neu bei Xcode und habe einen Fehler gemacht, bei dem ich nicht weiß, wie ich ihn beheben soll. Das war mein Code zuerst: #Preview { AddLektionView().modelContainer(for: Lektion.self) } und dann habe ich bemerkt, dass er so aussehen sollte: #Preview { AddLektionView().modelContainer(for: Lektion.self, inMemory: true) } Nun stehe ich vor dem Problem, dass die Preview die Daten auf Dauer gespeichert hat und ich beim ändern vom Aufbau der Daten, die gespeichert werden sollen, einen Fehler erhalte, da die neue App eine veraltete Datenstruktur von SwiftData lädt, was der App nicht passt. Daraufhin erhalte ich dann einen Fehler, dass die Daten wegen der unbekannten neuen Variable nicht geladen werden können. Wie kann ich die, von SwiftData geladenen Daten entfernen, sodass die Preview (Canvas) wieder funktioniert? (Eine Neuinstallation von Xcode habe ich schon probiert) Ich danke für jede Hilfe! Mit freundlichen Grüßen Tobias
Posted
by