My App build and run on actual device and simulator but fails to archive

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:

  1. Swift and SwiftUI
  2. Obj-C and some vanilla C, mainly because I use a framework in C
  3. 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
Answered by borarak in 777481022

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.

Well, that’s not good. It looks like the Swift compiler is crashing during the archive process.

It’d be interesting to see whether this is related to your bug configuration. Try this:

  1. In Xcode, open your project and choose Product > Clean Build Folder.

  2. Then choose Product > Scheme > Edit Scheme and, in the Info tab of the Run action, change the Build Configuration popup from Debug to Release.

  3. Click Close.

  4. Choose Product > Build.

Does is still crash?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hey @eskimo , thank you for helping out!

I followed your instructions and yes, it crashes still (on changing the config from Build to Release)


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 GStreamerSwiftUIAppStore)

4.	While running pass #4859 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           0x0000000104ca1abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56

1  swift-frontend           0x0000000107907cb0 llvm::sys::RunSignalHandlers() + 112

2  swift-frontend           0x0000000107671054 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           0x0000000103e67c2c (anonymous namespace)::ParsedAttrInfoFallThrough::~ParsedAttrInfoFallThrough() + 0

7  swift-frontend           0x0000000105700db8 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           0x0000000103dbc534 swift::ModuleFile::fatal(llvm::Error) const + 44

9  swift-frontend           0x00000001057021dc swift::CyclicalRequestError<swift::LookupPrefixOperatorRequest>::~CyclicalRequestError() + 0

10 swift-frontend           0x000000010584b880 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 1588

11 swift-frontend           0x0000000103e40f50 swift::SILDeserializer::getFuncForReference(llvm::StringRef, swift::SILType) + 504

12 swift-frontend           0x000000010585b578 swift::SILDeserializer::readSILInstruction(swift::SILFunction*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 29524

13 swift-frontend           0x000000010584c554 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 4872

14 swift-frontend           0x0000000105866934 swift::SILDeserializer::lookupSILFunction(swift::SILFunction*, bool) + 636

15 swift-frontend           0x0000000103edd990 swift::SILLinkerVisitor::deserializeAndPushToWorklist(swift::SILFunction*) + 88

16 swift-frontend           0x0000000103eddfb0 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 248

17 swift-frontend           0x0000000104ef0fa4 (anonymous namespace)::SILLinker::run() (.llvm.15023899450236721039) + 136

18 swift-frontend           0x00000001072a8874 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16276

19 swift-frontend           0x00000001074521c4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56

20 swift-frontend           0x00000001072f46b8 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476

21 swift-frontend           0x000000010730c424 swift::runSILOptimizationPasses(swift::SILModule&) + 472

22 swift-frontend           0x000000010529c3c0 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 572

23 swift-frontend           0x00000001071e9454 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           0x00000001071e4f00 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3020

25 swift-frontend           0x00000001071e8854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568

26 swift-frontend           0x000000010724fd44 swift::mainEntry(int, char const**) + 4408

27 dyld                     0x00000001892090e0 start + 2360

Command SwiftCompile failed with a nonzero exit code

Accepted Answer

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.

My App build and run on actual device and simulator but fails to archive
 
 
Q