Hello everyone!
I'm quite new to App development (but have quite a bit of programming experience).
I have reached the point where I would like to Archive my app for release but I'm stumped at an issue where the app compiles, builds and runs just fine in XCode on device and simulator targets however fails when I want to archive the app.
My app ends up using a mix of a lot of things possible:
- Swift and SwiftUI
- Obj-C and some vanilla C, mainly because I use a framework in C
- Very minimal but some UIKit (that bridges with some parts in C)
Here is the stacktrace, would appreciate some insights
1. Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
2. Compiling with the current language version
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for CamHero)
4. While running pass #12497 SILModuleTransform "PerformanceSILLinker".
5. While deserializing SIL function "$s7SwiftUI11EnvironmentV12wrappedValuexvg"
6. While deserializing SIL function "os_log_type_enabled"
7. *** DESERIALIZATION FAILURE ***
*** If any module named here was modified in the SDK, please delete the ***
*** new swiftmodule files from the SDK and keep only swiftinterfaces. ***
module 'SwiftUI', builder version '5.9.2(5.9.2)/Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)', built from swiftinterface, resilient, loaded from '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/prebuilt-modules/17.2/SwiftUI.swiftmodule/arm64-apple-ios.swiftmodule'
result not found (isEnabled)
Cross-reference to module 'os'
... OSLog
... in an extension in module 'os'
... isEnabled
... with type (OSLog) -> (OSLogType) -> Bool
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x0000000103a11abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000106677cb0 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x00000001063e1054 SignalHandler(int) + 352
3 libsystem_platform.dylib 0x00000001895b3a24 _sigtramp + 56
4 libsystem_pthread.dylib 0x0000000189584cc0 pthread_kill + 288
5 libsystem_c.dylib 0x0000000189494a40 abort + 180
6 swift-frontend 0x0000000102bd7c2c (anonymous namespace)::ParsedAttrInfoFallThrough::~ParsedAttrInfoFallThrough() + 0
7 swift-frontend 0x0000000104470db8 std::__1::__function::__func<swift::evaluator::PerRequestReferences swift::evaluator::PerRequestReferences::makeEmpty<swift::LookupPrefixOperatorRequest>()::'lambda'(void*), std::__1::allocator<swift::evaluator::PerRequestReferences swift::evaluator::PerRequestReferences::makeEmpty<swift::LookupPrefixOperatorRequest>()::'lambda'(void*)>, void (void*)>::operator()(void*&&) + 0
8 swift-frontend 0x0000000102b2c534 swift::ModuleFile::fatal(llvm::Error) const + 44
9 swift-frontend 0x00000001044721dc swift::CyclicalRequestError<swift::LookupPrefixOperatorRequest>::~CyclicalRequestError() + 0
10 swift-frontend 0x00000001045bb880 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 1588
11 swift-frontend 0x0000000102bb0f50 swift::SILDeserializer::getFuncForReference(llvm::StringRef, swift::SILType) + 504
12 swift-frontend 0x00000001045cb578 swift::SILDeserializer::readSILInstruction(swift::SILFunction*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 29524
13 swift-frontend 0x00000001045bc554 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 4872
14 swift-frontend 0x00000001045d6934 swift::SILDeserializer::lookupSILFunction(swift::SILFunction*, bool) + 636
15 swift-frontend 0x0000000102c4d990 swift::SILLinkerVisitor::deserializeAndPushToWorklist(swift::SILFunction*) + 88
16 swift-frontend 0x0000000102c4dfb0 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 248
17 swift-frontend 0x0000000103c60fa4 (anonymous namespace)::SILLinker::run() (.llvm.15023899450236721039) + 136
18 swift-frontend 0x0000000106018874 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16276
19 swift-frontend 0x00000001061c21c4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56
20 swift-frontend 0x00000001060646b8 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476
21 swift-frontend 0x000000010607c424 swift::runSILOptimizationPasses(swift::SILModule&) + 472
22 swift-frontend 0x000000010400c3c0 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 572
23 swift-frontend 0x0000000105f59454 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 956
24 swift-frontend 0x0000000105f54f00 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3020
25 swift-frontend 0x0000000105f58854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
26 swift-frontend 0x0000000105fbfd44 swift::mainEntry(int, char const**) + 4408
27 dyld 0x00000001892090e0 start + 2360
Command SwiftCompile failed with a nonzero exit code
After painfully going through my commit log to see at which point the app started failing to archiving, i found out the issues was the use of @Environment
vars.
@Environment(\.scenePhase) private var scenePhase
was the culprit for me, removing that made the Archive succeed.
I'm not quite sure as to why, mostly why the compiler only complains during archiving - but I assume it fails some compatibility matrix.