Another developer having this problem:
https://developer.apple.com/forums/thread/721678
Post
Replies
Boosts
Views
Activity
I can confirm this issue on a iPhone 12 Pro with iOS 16.0 and iOS iOS 16.2
https://developer.apple.com/forums/thread/721858
It works fine on iPhone X with iOS 15.7
For reference: Got it working with implementing and setting a custom OpenURLAction as documented here:
https://developer.apple.com/documentation/swiftui/openurlaction
Unfortunately, you seem to be right. This is quite an annoying bug in SwiftUI.
To solve, I selected the file from the project file browser in XCode (very left pane) and everything worked OK. This is insane, but it worked for me too. Thank you.
Maybe this problem is connected to the problem I run into with iOS 14, where presenting a sheet sometimes (and if so, only the first time) reloads the (underlying) presenting view - which would
) dismiss the presented sheet (-> onDisappear is called), which would then
) load the view again (-> onAppear is called), which would then
) represent the sheet again (since state in the observed view model hasn't changed of course),
... which can trigger a chain of unexpected behavior.
Note: This had been working solid with iOS 13, and I'm still debugging. It's pretty obvious what's happening, but I have no idea yet why it it happening, why it is happening randomly and how to solve this.
Additional info: When debugging the app (which is pulling the package mentioned above) I do get the same "Cannot create Swift scratch context" message. The app seems to run ok though, only debugging is a bit of a pain.
SwiftASTContext("MyAPP")::CreateInstance() -- Corresponding source not found for /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/clang_compiler_rt/clang-1200.0.22.7/compiler-rt/lib/profile/InstrProfiling.c, loading module is unlikely to succeed
SwiftASTContext("MyAPP")::SetTriple("arm64-apple-ios14.0.0") setting to "arm64-apple-ios14.0.0"
SwiftASTContext("MyAPP")::SetTriple("arm64-apple-ios14.0.0") setting to "arm64-apple-ios14.0.0"
SwiftASTContext("MyAPP")::DeserializeAllCompilerFlags() -- Found 3 AST file data entries.
SwiftASTContext("MyAPP")::DeserializeAllCompilerFlags() -- SDK path from module "MyAPP" is "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk".
SwiftASTContext("MyAPP")::DeserializeAllCompilerFlags() -- SDK path from module "MyLIB" is "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk".
SwiftASTContext("MyAPP")::DeserializeAllCompilerFlags() -- SDK path from module "MyLIB" is "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk".
SwiftASTContext("MyAPP")::DeserializeAllCompilerFlags() -- Picking SDK path "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk".
SwiftASTContext("MyAPP")::CreateInstance() -- Found serialized triple arm64-apple-ios14.0.
SwiftASTContext("MyAPP")::SetTriple("arm64-apple-ios14.0") setting to "arm64-apple-ios14.0"
SwiftASTContext("MyAPP")::CreateInstance() -- Serialized SDK path is /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk.
SwiftASTContext("MyAPP")::CreateInstance() -- Host SDK path is .
SwiftASTContext::GetResourceDir() -- trying toolchain path:
SwiftASTContext::GetResourceDir() -- trying Xcode path: /Applications/Xcode-beta.app/Contents
SwiftASTContext::GetResourceDir() -- trying Xcode-based lib path: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
SwiftASTContext::GetResourceDir() -- found Swift resource dir via Xcode contents path + default toolchain relative dir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
SwiftASTContext("MyAPP")::GetASTContext() -- Using Clang module cache path: /Users/MySELF/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
SwiftASTContext("MyAPP")::GetASTContext() -- Using prebuilt Swift module cache path: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/prebuilt-modules
SwiftASTContext("MyAPP")::RegisterSectionModules("MyAPP") retrieved 3 AST Data blobs from the symbol vendor.
SwiftASTContext("MyAPP")::RegisterSectionModules() -- parsed module "MyAPP" from Swift AST section 1 of 3.
SwiftASTContext("MyAPP")::RegisterSectionModules() -- parsed module "MyLIB" from Swift AST section 2 of 3.
SwiftASTContext("MyAPP")::RegisterSectionModules() -- parsed module "MyLIB" from Swift AST section 3 of 3.
SwiftASTContext("MyAPP")::GetModule("MyAPP")
SwiftASTContext("MyAPP")::GetModule("MyAPP") -- found MyAPP
SwiftASTContext("MyAPP")::GetModule("MyLIB")
SwiftASTContext("MyAPP")::GetModule("MyLIB") -- found MyLIB
SwiftASTContext("MyAPP")::GetModule("MyLIB")
…
Just for the records: I do get the same message ("Cannot create Swift scratch context (couldn't load the Swift stdlib)") when running logic tests for a swift package on an iOS 14.0 simulator, tests using iOS 14 features (i.e. resource copying) will also fail.
Selecting the Mac as target for running the tests solves the problem.
I agree, this is quite disappointing. Apple really needs to make SwiftUI a first class API, otherwise developers won't use it.
However, the good news is: meanwhile you can wrap UITableView in a UIViewRepresentable for yourself and provide UISwipeActions & other features which are not yet exposed by SwiftUI in a custom component. Not nice, but ok.