I have encounter a problem where my canvas cannot preview but it build successfully and runs in a simulator.
I have tried:
xcrun simctl --set previews delete all
clean build and rebuild
Is there any other suggestion or solution I can solve this issue?
Xcode Version: Version 13.3 (13E113)
Diagnostics:
MessageSendFailure: Message send failure for relaunch
==================================
| 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: 0x6000015316c0>
| ==error-reason: process launch failed
| ==precipitating-error: Error Domain=FBProcessExit Code=4 "The process crashed." UserInfo={NSLocalizedFailureReason=The process crashed., BSErrorCodeDescription=crash, NSUnderlyingError=0x60000224e670 {Error Domain=signal Code=5 "SIGTRAP(5)" UserInfo={NSLocalizedFailureReason=SIGTRAP(5)}}}
Post not yet marked as solved
Currently working on a project these past couple of days but today when I opened Xcode and selected my project it would not display my stimulater phone and would keep refreshing showing the last successful build was sometime yesterday.
Post not yet marked as solved
The widget family obtained via @Environment(\.widgetFamily) is wrong when preview widgets in Xcode 13.3.
The problem can be reproduced by creating a default app project and a widget extension in Xcode 13.3.
Post not yet marked as solved
For some reason, my Xcode previews keep on disappearing, saying that they timeout.
Post not yet marked as solved
I downloaded Xcode, created a new swiftUI project for an iOS app. When I hit the preview button, it appears to be trying to do something, but it never generates the 'Hello World' preview. If I let it sit for half an hour or more, an error is eventually generated:
Timeout Error: Timed out waiting for connection to DTServiceHub ater 15.0 seconds.
Similarly, if I hit the build button, it will take about an hour or more for the iOS simulator to open with the 'Hello World!' app. While Xcode is working, my system becomes sluggish to the point where nothing else can be done, even though the Activity monitor doesn't show heavy CPU or memory usage.
Xcode 13.3 (13E113)
System:
iMac 18,2
Quad-Core i5
3 GHz
8GB
macOS 12.2.1 (21D62)
SwiftUI previews don't seem to work in Xcode 12, beta 5, when using Firebase Analytics. The app builds and runs fine to simulator or device, but fails generating SwiftUI preview for a widget with the following message:
ld: in /Users/../.../Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_e321ed8e3db06efc9803f6c008e67a34.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/.../.../Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It was working fine in beta 4. Anyone else seen this? Any ideas?
Hi! I followed the Apple's SwiftUI Tutorials"LandmarksApp".But When I resume preview at "LandmarkRow.swift", landmarksApp was clashed by unexpected reason.
I couldn't find why this problem was happened.
Please tell me how to solve this problem.
↓My Mac details
MacBookPro 13inch (2020-M1) 16GB memory,512GB SSD
macOS Monterey 12.2.1, Xcode version 13.2.1
Post not yet marked as solved
Hello I'm having a problem with the SwiftUI preview, I created a package, which has resources and I'm trying to run the preview inside the package. But the preview gives the following error:
PreviewUpdateTimedOutError: Updating took more than 5 seconds
Updating a preview from in XCPreviewAgent.app (6693) took more than 5 seconds.
When I generate the diagnosis and see the SerializationErrors.txt it gives the following message:
Error Domain=NSCocoaErrorDomain Code=516 "“resource_bundle_accessor.swift” couldn’t be linked to “Intermediates” because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Users/********/Library/Developer/Xcode/DerivedData/********-glsxbeukhhwappbnunipftxmhjvi/Build/Intermediates.noindex/Previews/********/Intermediates.noindex/***** ***.build/Debug-iphonesimulator/********.build/DerivedSources/resource_bundle_accessor.swift, NSUserStringVariant=(
Link
), NSDestinationFilePath=/var/folders/xt/s6r881rx7bjfcw_mds72nxyw0000gp/T/previews-diagnostics-20220304-114049/Intermediates/resource_bundle_accessor.swift, NSFilePath=/Users/*********/Library/Developer/Xcode/DerivedData /********-glsxbeukhhwappbnunipftxmhjvi/Build/Intermediates.noindex/Previews/********/Intermediates.noindex/********.build/Debug-iphonesimulator/** ******.build/DerivedSources/resource_bundle_accessor.swift, NSUnderlyingError=0x2cb1d2cd0 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}
I've tried clearing the derivated data, clearing the preview cache, restarting the mac, nothing works... Anyone have any ideas?
This package has no external dependencies
Post not yet marked as solved
Any help with preview crash on an App that is building just fine and runs on simulator fine?
Are there logs that I can access somehow?
The previews were working just fine, but then stopped and I have reverted all changes since and the previews are still broken.
Post not yet marked as solved
Due to some previous software issues with Xcode, I had to uninstall and reinstall the app. Currently running Xcode 13.2.1.
When I open any of my previous projects, Xcode gives me the error message, "Failed to build ContentView.swift". It will give me this same message for any of my SwiftUI view files (before the software issues noted above, I never had this issue). I've even attempted starting a brand new project from scratch, and it still gives the same error.
I'm running Xcode on a Mac mini (M1, 2020) with macOS Monterey (V12.0.1), if that helps.
Greatly appreciate any solutions to fix so I can get back to building my project. Thank you.
Post not yet marked as solved
Hello,
while following the SwiftUI tutorial I keep getting this error (MessageSendFailure: Message send failure for update).
I am on Xcode: 13.2.1
Where can I submit the bug report?
Post not yet marked as solved
Curious to know if anyone understands why I'm getting the following error
"Cannot preview in this file" - [appname] crashed"
Running the code on my (wirelessly) attached iPhone XR works, but the in-Xcode Preview window doesn't.
Here's the log produced by the Diagnostics option:
<Well, I tried to attach the zip file created from the previews-diagnostics-##-## folder, but this text field wouldn't accept that file type. Is there a particular file within the folder that I should upload instead?>
Here's the code from the ContentView file for my (very basic) project:
import SwiftUI
struct ContentView: View {
@FocusState private var amountIsFocused: Bool
@State private var checkAmount = 0.0
@State private var numberOfPeople = 0
@State private var tipPercentage = 0
let tipPercentages = [0, 10, 15, 20, 25]
var totalPerPerson: Double {
let peopleCount = Double(numberOfPeople + 2)
let tipSelection = Double(tipPercentage)
let tipValue = tipSelection / 100 * checkAmount
let grandTotal = checkAmount + tipValue
let amountPerPerson = grandTotal / peopleCount
return amountPerPerson
}
var totalAmount: Double {
let tipSelection = Double(tipPercentage)
let tipValue = tipSelection / 100 * checkAmount
let grandTotal = checkAmount + tipValue
return grandTotal
}
var body: some View {
NavigationView {
Form {
Section {
TextField("Amount", value: $checkAmount, format: .currency(code: Locale.current.currencyCode ?? "USD"))
.keyboardType(.decimalPad)
.focused($amountIsFocused)
Picker("Number of people", selection: $numberOfPeople) {
ForEach(2 ..< 100) {
Text("\($0) people")
}
}
}
Section {
Picker("Tip percentage", selection: $tipPercentage) {
ForEach(0 ..< 101) {
Text($0, format: .percent)
}
}
} header: {
Text("Select tip percentage")
}
Section {
Text("Grand total: \(totalAmount, format: .currency(code: Locale.current.currencyCode ?? "USD"))")
}
Section {
Text(totalPerPerson, format: .currency(code: Locale.current.currencyCode ?? "USD"))
} header: {
Text("Amount per person")
}
.navigationTitle("WeSplit")
.navigationBarTitleDisplayMode(.inline)
}
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button("Done") {
amountIsFocused = false
}
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Post not yet marked as solved
SwiftUI Previews are broken for me when one of imported Swift Package has a conditional dependency to another platform.
Steps to reproduce:
Create Xcode Project with 2 targets. One for macOS, another for iOS.
Add a Swift Package that has a conditional dependency - eg. depends on another package but only on iOS.
Example:
targets: [
.target(name: "Components",
dependencies: [
.productItem(name: "FloatingPanel", package: "FloatingPanel", condition: .when(platforms: [.iOS])),
]),
]
Try running SwiftUI preview on macOS. It won’t work.
The error I get is no such module UIKit.
It looks like Xcode is trying to build FloatingPanel dependency even though it's condition specifies iOS platform.
Is there any way to fix this?
While working through Part II the Widget code-along from WWDC, I thought I would add a separate preview for each size, just as an exercise for myself.
static var previews: some View {
Group {
EmojiRangerWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), character: .panda))
.previewContext(WidgetPreviewContext(family: .systemSmall))
EmojiRangerWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), character: .panda)) .previewContext(WidgetPreviewContext(family: .systemMedium))
}
}
}
This works, giving me two previews of the correct size. Unfortunately, the smaller preview is trying to layout the medium's view within its given space.
I'm assuming that this is because the @Environment for the widgetFamily wasn't configured correctly, so I thought I'd add it like this:
.environment(\.widgetFamily, .systemSmall)
I was guessing that something like this might be possible, because I have seen a similar situation where a preview is created for a dark mode like this:
.environment(\.colorScheme, .dark)
Alas, my attempt to set the widgetFamily environment doesn't work. It gives me a this error:
Key path value type 'WritableKeyPath<EnvironmentValues, WidgetFamily>' cannot be converted to contextual type 'KeyPath<EnvironmentValues, WidgetFamily>'
Am I close? Is there some way to inject the widget family environment, or is there a bug that fails to bind the WidgetPreviewContext(family: .systemSmall) that I'm already passing?
Post not yet marked as solved
I wrote short code for the App using camera and that crushed when I tried to display preview.
There is no error code, so where should I fix?
@State var image: Image?
@State var isPicking = false
var body: some View {
ZStack {
VStack {
VStack {
Spacer()
image?
.resizable()
.scaledToFit()
Spacer()
}
HStack {
Spacer()
Button(action: {
self.isPicking = true
}) {
Image(systemName: "camera")
Text("カメラ")
}.padding()
}
}
if isPicking {
ImagePicker()
.edgesIgnoringSafeArea(.all)
.transition(.move(edge: .bottom))
.animation(.easeInOut, value: isPicking)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
ImagePicker↓
struct ImagePicker: UIViewControllerRepresentable{
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: Context) ->
UIImagePickerController{
let picker = UIImagePickerController()
picker.sourceType = .camera
picker.delegate = context.coordinator
return picker
}
func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {
}
}
struct ImagePicker_Previews: PreviewProvider {
static var previews: some View {
ImagePicker()
}
}
Coordinator↓
class Coordinator: NSObject, UINavigationControllerDelegate,
UIImagePickerControllerDelegate{
var parent: ImagePicker
init(_ parent: ImagePicker){
self.parent = parent
}
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info:
[UIImagePickerController.InfoKey: Any]){
let uiImage = info[.originalImage] as! UIImage
UIImageWriteToSavedPhotosAlbum(uiImage, nil, nil, nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController){
}
}
Post not yet marked as solved
Hi there!
I've been messing around in Xcode 12 Beta with SwiftUI and a Core Data Model, and for some reason my ContentView preview in Xcode is failing to load. Here's the error:
"Cannot preview in this file — Connection interrupted: send message to agent"
I've made sure all my target memberships are synchronized, given Xcode 12 Command Line Tools in Preferences>Locations, and tried every other solution I can find out there.
Any ideas?
When the Xcode Previews app opens on the device, this is the error message in Xcode: RemoteHumanReadableError: Failed to update preview.
Error encountered when sending 'display' message to agent.
I tried cleaning the build folder and quitting then reopening Xcode to no avail.
Using Xcode 12.0.1 previewing on iPhone 11.
Post not yet marked as solved
Xcode SwiftUI previews were a godsend, increasing my productivity by 1000x with use cases like this:
Preview a UIViewController (via UIViewControllerRepresentable)
Update view controller code and see changes to previews in real time
Update theme files (colors, styles) and see changes to previews in real time
This all used to work like a charm as long as the updated code was inside functions or computed properties.
But starting with Xcode 13.2, it no longer works:
Updating any file outside of PreviewProvider struct just reloads the canvas, but does not account for changes in these files (e.g. if I change color in a theme file, the old color will be shown in preview until I pause the preview, recompile and reload preview)
Using "Refresh Canvas" does not solve the issue (it just reloads the canvas with stale data)
Any way to fix this?
Post not yet marked as solved
Help for some reason this app called xCode previews and every time I restart it appears on my Home Screen how do I permenently take it off my Home Screen it’s so annoying
For the last 3days, I'm completely stopped my work because my Xcode got an unknown issue. I did several things like delete Xcode, new install Xcode, restore from backup nothing make any change!
Currently, the project is built and run in the simulator but not in the preview window it gives a message:
Cannot preview in this file - Timed out waiting for connection to DTServiceHub after 15.0 seconds.
iMac becomes very slow. Please Help!