Following the new Xcode update 15.0.1, when my preview loads a process called nsurlsessiond is triggered and it is downloading more data. How do I solve this problem?
Xcode Previews
RSS for tagCreate an app UI and configure almost everything your users see using Xcode Previews.
Posts under Xcode Previews tag
155 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello!
I can't preview the SwiftUI views of watchOS target in Xcode 15 beta 1, when the containing iOS app has a SPM dependency. Reproducing steps:
Create a new watchOS app project (with a companion iOS app) in Xcode 15.
Both iOS and watchOS ContentView can be previewed at this step.
Add a Swift package to the iOS target (the package should be an iOS-specific package, not a watchOS one, for example, https://github.com/siteline/SwiftUI-Introspect)
After you add the static library to iOS target, the watchOS preview no longer work anymore.
If you check the error message, you can find the Xcode preview attempt to build the iOS package against watchOS SDK.
== DATE:
Thursday, October 26, 2023 at 13:06:58 China Standard Time
2023-10-26T05:06:58Z
== PREVIEW UPDATE ERROR:
FailedToLaunchAppError: Failed to launch com.***
==================================
| MessageError: Unexpected message object
|
| Unexpected message object: expected ProcessID, got Optional(6872)
Hi,
I am getting an error in the preview section for the watchOS application. But it works when I build it. I get the like following errors in Preview. How can I solve it?
no such module 'QuartzCore'
Compile RoundedCorners.swift (arm64):
/Users/msy/Library/Developer/Xcode/DerivedData/TestApp-gkorwbacqzvxvgcmrpdkaxfxnnmu/SourcePackages/checkouts/lottie-ios/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift:4:8: error: no such module 'QuartzCore'
import QuartzCore
^
Compile Shape.swift (arm64):
/Users/msy/Library/Developer/Xcode/DerivedData/TestApp-gkorwbacqzvxvgcmrpdkaxfxnnmu/SourcePackages/checkouts/lottie-ios/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift:4:8: error: no such module 'QuartzCore'
import QuartzCore
^
Compile LottieAnimationView.swift (arm64):
/Users/msy/Library/Developer/Xcode/DerivedData/TestApp-gkorwbacqzvxvgcmrpdkaxfxnnmu/SourcePackages/checkouts/lottie-ios/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift:4:8: error: no such module 'QuartzCore'
import QuartzCore
^
Copy FirebaseAnalyticsSwift.swiftmodule (arm64):
error: /Users/msy/Library/Developer/Xcode/DerivedData/TestApp-gkorwbacqzvxvgcmrpdkaxfxnnmu/Build/Intermediates.noindex/Previews/TestApp Mobil Watch App/Intermediates.noindex/Firebase.build/Debug-watchsimulator/FirebaseAnalyticsSwift.build/Objects-normal/arm64/FirebaseAnalyticsSwift.swiftmodule: No such file or directory (in target 'FirebaseAnalyticsSwift' from project 'Firebase')
Is it possible to create one-to-many relationships between optional objects in SwiftData Xcode Previews? The below code I call from #Preview crashes the canvas on the post.authors?.append(tempAuthors.randomElement()!) when I try to append an array to an optional array. I can append the previewAuthors array to the authors array in the simulator or on device, but it crashes in Preview. My running theory is it has something to do with being in memory since this works on device, but I'm not sure that I missed something super obvious.
static func previews(_ count: Int) -> [Post] {
let previewAuthors = [Author(name: "..."), Author(name: "...")]
var posts: [Post] = []
for i in 0..<count {
let post = Post(title: "Title \(i)")
post.authors?.append(previewAuthors.randomElement()!)
posts.append(post)
}
return posts
}
For the PreviewProvider, is it possible to set the ios version which the preview will be made for or the preview will always use the latest ios version (e.g. ios 17)?
Hello
I am in need of help to try and understand what is going on with XCode and Previews when using Swift Data.
I have the following path:
View 1 (Calandar Screen) -> Passes Model -> View 2 (Details Screen)
I have a situation where when working on View 2 it will not run in Preview mode when the Pin is not selected. However if I pin View 1 and then go to work on View 2 preview works fine.
Now I am guessing that this might have something to do with Swift Data and by having View 1 open it generates the Model to be passed but I might be wrong?
I am also struggling to understand and read the error log that excode generates.
I have Preview setup in View 2 as follows
#Preview {
DiaryReadView(diaryModel: DiaryModel())
.environmentObject(NavigationStateManager())
.modelContainer(for: [DiaryModel.self], inMemory: true)
}
Error Log
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: 5C8FAD15-959E-4E0A-AFF4-55A739D54110
CrashReporter Key: CC891733-97EE-34E0-EDB7-394B181A2623
Hardware Model: iMac20,1
Process: Diary [36381]
Path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/78258A6C-0145-4E82-ACCD-1F0539F2148A/data/Containers/Bundle/Application/970BD3F5-925F-47BD-A214-7F7B0226A04F/Diary.app/Diary
Identifier: OR-1
Version: 1.0 (1)
Code Type: X86-64 (Native)
Role: Foreground
Parent Process: launchd_sim [29471]
Coalition: com.apple.CoreSimulator.SimDevice.78258A6C-0145-4E82-ACCD-1F0539F2148A [78195]
Responsible Process: SimulatorTrampoline [48509]
Date/Time: 2023-10-24 10:55:15.3444 +0100
Launch Time: 2023-10-24 10:55:14.7909 +0100
OS Version: macOS 14.0 (23A344)
Release Type: User
Report Version: 104
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: SIGNAL 4 Illegal instruction: 4
Terminating Process: exc handler [36381]
Triggered by Thread: 0
Thread 0 Crashed:
0 libswiftCore.dylib 0x7ff814aa36f2 0x7ff814a76000 + 186098
1 SwiftData 0x7ff84952f7dd 0x7ff849514000 + 112605
2 SwiftData 0x7ff8495b1746 0x7ff849514000 + 644934
3 SwiftData 0x7ff8495b64c9 0x7ff849514000 + 664777
4 SwiftData 0x7ff84956f726 0x7ff849514000 + 374566
5 Diary 0x10a4e9635 DiaryModel.init() + 357 (@__swiftmacro_5Diary0A5Model0B0fMm_.swift:2)
6 Diary 0x10a4e94c2 DiaryModel.__allocating_init() + 34
7 DiaryReadView.1.preview-thunk.dylib 0x10bf15533 closure #1 in static $s025Diary_PreviewReplacement_A10ReadView_133_E76E9AE78936AC4C16C3EA33E995B161Ll0B0fMf_15PreviewRegistryfMu_.makePreview() + 51 (@__swiftmacro_025Diary_PreviewReplacement_A10ReadView_133_E76E9AE78936AC4C16C3EA33E995B161Ll0B0fMf_.swift:9)
8 PreviewsInjection 0x10ac7f386 0x10ac41000 + 254854
9 PreviewsInjection 0x10ac8025d 0x10ac41000 + 258653
10 libswift_Concurrency.dylib 0x7ff85b04c76c 0x7ff85b03b000 + 71532
11 PreviewsInjection 0x10ac7f0e5 0x10ac41000 + 254181
12 PreviewsInjection 0x10ac83108 0x10ac41000 + 270600
13 PreviewsInjection 0x10ac83c1c 0x10ac41000 + 273436
14 PreviewsInjection 0x10ac70a0d 0x10ac41000 + 195085
15 PreviewsInjection 0x10ac7387a 0x10ac41000 + 206970
16 PreviewsInjection 0x10ac5a630 0x10ac41000 + 103984
17 PreviewsInjection 0x10ac5aaf4 0x10ac41000 + 105204
18 PreviewsInjection 0x10ac753f0 0x10ac41000 + 214000
19 PreviewsInjection 0x10ac493f3 0x10ac41000 + 33779
20 PreviewsInjection 0x10ac48a85 0x10ac41000 + 31365
21 PreviewsFoundation 0x10b741df9 0x10b6a1000 + 658937
22 libdispatch.dylib 0x7ff800156a90 0x7ff800155000 + 6800
23 libdispatch.dylib 0x7ff800157d3a 0x7ff800155000 + 11578
24 libdispatch.dylib 0x7ff800166ac0 0x7ff800155000 + 72384
25 libdispatch.dylib 0x7ff800166526 0x7ff800155000 + 70950
26 CoreFoundation 0x7ff8003f5850 0x7ff800368000 + 579664
27 CoreFoundation 0x7ff8003f018b 0x7ff800368000 + 557451
28 CoreFoundation 0x7ff8003ef409 0x7ff800368000 + 553993
29 GraphicsServices 0x7ff80fcdd187 0x7ff80fcda000 + 12679
30 UIKitCore 0x7ff805b703a2 0x7ff804b95000 + 16626594
31 UIKitCore 0x7ff805b74e10 0x7ff804b95000 + 16645648
32 SwiftUI 0x7ff84a61077e 0x7ff8495ce000 + 17049470
33 SwiftUI 0x7ff84a610637 0x7ff8495ce000 + 17049143
34 SwiftUI 0x7ff84a2bcaa5 0x7ff8495ce000 + 13560485
35 Diary 0x10a4ffade static DiaryApp.$main() + 30
36 Diary 0x10a500099 main + 9 (DiaryApp.swift:12)
37 dyld_sim 0x10ab023ee start_sim + 10
38 dyld 0x10cd9c3a6 0x10cd96000 + 25510
In order to submit your app for review you must provide a screenshot for the 5.5 inch iPhone (iPhone 6S Plus, 7 Plus, 8 Plus). The simulator for these phones is not included in the standard set provided in xCode.
After researching there is a method described where you can download simulator sets for previous iOS releases. I downloaded both the iOS 13 and iOS 14 set but still unable to get at one of the mentioned iPhone simulators.
Has anyone solved this problem short of getting an actual iPhone hardware to do the screen shots on.
Thanks,
M2 Air overheating with Xcode 15.0.1
After update my Xcode to 15.0, my SwitUI views stoped to open on Preview Canvas
It runs on Simulator, but I can't previews the UI.
Can someone help or give some tips where should I look for?
Prior to updating to MacOS 14, the Preview code would read main bundle files listed in Preview Content when the target was MacOS. Now, the files are not read.
When the target is iPadOS, the files are read and the preview works.
Does anyone know what is happening? I suspect that this has something to do with the App Sandbox security features.
Hi,
Having various problems with Xcode. Finally got it to load the runtimes and now when I try to preview, either with the old method or #Preview, the preview panel icon spins and the folder view refreshes several times until Xcode finally crashes with a SIGABRT.
I've sent feedback, but not sure if I will hear back. I've tried with public 15.0, 15.0.1 RC and 15.1 Beta. All the same.
The status bar at the top changes between 'Packages | Fetching' and 'Indexing | Processing Files', while the Folder list on the left keeps refreshing. About 10 refreshes later and Xcode crashes.
Running directly in the simulator works, although it does take a long time to start after the app has loaded.
This is with iOS 17.0 as the target or with 16.0.
I cleared out all the previews with:
xcrun simctl --set previews delete all
Which saved some space but didn't help.
Thanks, Darren
I am trying to create a new project in XCode, and my preview won't load. I have deleted and reinstalled, deleted the cache, developer data, etc., and nothing works:
I am having an issue when previewing a UIKit ViewController. I am developing my app inside Pods framework which then I import and use in scene/app delegate. I tried to use UIKit to have SwiftUI previews. I conformed to UIViewRepresentable protocol and made a struct that conforms to PreviewProvider where I returned the current controller as some View. I have many external dependencies like Moya, Alamofire, SnapKit...
I am building my components in Pods project. Which I import than into scene/app delegate to start the app.
I am getting the error: "Cannot preview in this file; Unexpected error occurred". I went online and found some people saying that I need to disable Automatically Refresh Canvas setting. But it still doesn't work. I am then getting an error: "Cannot preview in this file; Update failed". I attached a file with a generated report from the error. I also cleaned the build folder and restarted my Mac. I am using Macbook Pro M2.
If I run UIKit previews in a new project it works. But I need it to be able to run in my current project.
https://www.notion.so/Xcode-Previews-UIKit-Error-Report-ba5ec69080f34cb09c6f93c6cd0131d7?pvs=4
In Xcode 15 Live Previews are available for UIKit view controllers and views. However I noticed they do not work if the deployment target is < 17.0.
If I try to make a live preview for a view controller like so:
#Preview {
let someVC = ViewController()
return someVC
}
It doesn't load.
The error is described below:
== PREVIEW UPDATE ERROR:
CompileDylibError: Failed to build ASwiftViewController.swift
Compiling failed: module 'SwiftUI' has no member named 'VStack'
If I raise the deployment target to iOS 17 it starts working.
Hello, everything worked fine when I packaged my APP with the old version of Xcode, but I started reporting this error when I archived the package with Xcode15. I hope to get your help, thank you.
error:
Build target App of project App with configuration Release
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/wang/Library/Developer/Xcode/DerivedData/App-dcarpmhimruyzxfuqacwgyqbpwsy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target 'App' from project 'App')
cd /Users/wang/Documents/new-bn-app/bn-app/ios/App
/bin/sh -c /Users/wang/Library/Developer/Xcode/DerivedData/App-dcarpmhimruyzxfuqacwgyqbpwsy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh
mkdir -p /Users/wang/Library/Developer/Xcode/DerivedData/App-dcarpmhimruyzxfuqacwgyqbpwsy/Build/Intermediates.noindex/ArchiveIntermediates/App/BuildProductsPath/Release-iphoneos/App.app/Frameworks
Symlinked...
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Capacitor.framework" "/Users/wang/Library/Developer/Xcode/DerivedData/App-dcarpmhimruyzxfuqacwgyqbpwsy/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app/Frameworks"
building file list ... rsync: link_stat "/Users/wang/Documents/new-bn-app/bn-app/ios/App/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Capacitor.framework" failed: No such file or directory (2)
done
sent 29 bytes received 20 bytes 98.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/d9889869-120b-11ee-b796-7a03568b17ac/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
I'm using Xcode 15 15A240d
Similarly to https://developer.apple.com/forums/thread/731732 when I try to run the Xcode previews for watchOS views in a watchOS target I get compilation errors from UIKit code.
This is only valid for Xcode Previews. Building the code normally / Run it on simulator or device works.
I don't understand why Xcode attempts to build iOS code.
my scheme does include the host app for the watch
I made a duplicate of that scheme by unchecking the host app and that makes previews work again.
I'm not sure this is the intended behavior. I double checked and this was not the case with Xcode 14.3.1 I could run the initial target without issues on Xcode previews.
Do you experience the same issue? is this a problem with my scheme settings or an Xcode bug?
When I set the preview mode to selectable the app is restarted at the home screen. However, I want really to look at a secondary screen reached by clicking a navigation link icon on the main screen. In this mode clicking the icon selects it but doesn't activate it. This seems like a catch 22. How could I get to the secondary screen in selectable mode? Is there a key/click combination that does a real click in selectable mode so I can get to it?
I have recently created a very simple Swift Macro that I can attach to a view that will generate the boilerplate we have in the project for passing in the view model instance.
@TPView<CompanyProfileViewModel>
struct CompanyProfileView: View {
...
// expanded code
private (set) var viewModel: CompanyProfileViewModel
init(viewModel: CompanyProfileViewModel) {
self.viewModel = viewModel
}
}
However the issue I'm running into is that whilst this init method is accessible in most of the project, when I try to use it in a #Preview block I get errors:
#Preview("Default") {
CompanyProfileView(viewModel: .mock())
.previewLayout(.fixed(width: 380, height: 2000))
}
Based on the top error it seems like the #Preview block isn't able to see the generated init method. I could go back to just using the standard preview code that doesn't using #Preview, but that seems like I'm taking a step forward and a step back with making the code less verbose.
Any suggestions on how to get this working? This seems like a bug to me.
Hiya,
I am having issues trying to use previews in the xcode 15 beta, i am using an M2 macbook air with 8gb of ram.
I am using MacOS Sonoma and iOS 17.0 Beta 1 and am struggling using previews, the base simulator works but no previews.
I am not receiving any error so am very confused.
Any help would be majorly appreciated.
Thanks,
Gus