TestFlight installed app crash with Swift Package Manager dependencies

We have migrated some of our CocoaPod dependencies to be build and linked with Swift Package Manager in Xcode 11. However, whenever we submit application to AppStore Connect and distribute with TestFlight, the app crashes the moment it tries to use API from one of the SPM linked dependencies. Other builds (adhoc and development) are working fine. Some of the SPM dependencies are also linked 2 app extensions.

Did anyone encounter this issue, would you have any idea what is the problem and/or how to fix it?

Attaching stack trace for the crash. This one happens in

ObjectMapper
dependency.


Exception Type:  EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x00000000800000d0
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [19562]
Triggered by Thread:  0


Thread 0 name:
Thread 0 Crashed:
0   OurAwesomeApp                     0x0000000101693d14 nominal type descriptor for EnumTransform + 0
1   OurAwesomeApp                     0x000000010108cda0 <- infix(_:_:) + 612 (__hidden#1488_:38)
2   OurAwesomeApp                     0x0000000101074434 <- infix(_:_:) + 100 (__hidden#434_:36)
3   OurAwesomeApp                     0x0000000100cad360 TWSplitParticipant.mapping(map:) + 1388 (DataClasses.swift:1211)
4   OurAwesomeApp                     0x00000001010842cc Mapper.map(JSON:) + 1224 (__hidden#1191_:106)
5   OurAwesomeApp                     0x0000000101087c70 _hidden#1144_ + 24 (__hidden#110_:0)
6   libswiftCore.dylib             0x000000018f3cd61c $sSTsE10compactMapySayqd__Gqd__Sg7ElementQzKXEKlF + 732 (SequenceAlgorithms.swift:807)
7   OurAwesomeApp                     0x0000000101084a68 Mapper.mapArray(JSONArray:) + 212 (__hidden#1191_:166)
8   OurAwesomeApp                     0x0000000101082a8c Mapper.mapArray(JSONObject:) + 192 (__hidden#1191_:156)
9   OurAwesomeApp                     0x00000001010753d4 _hidden#461_ + 148 (__hidden#487_:92)
10  OurAwesomeApp                     0x0000000101088c8c _hidden#1301_ + 196
11  OurAwesomeApp                     0x0000000100cac720 TWSplitRequest.mapping(map:) + 812 (DataClasses.swift:1157)
12  OurAwesomeApp                     0x00000001010842cc Mapper.map(JSON:) + 1224 (__hidden#1191_:106)
13  OurAwesomeApp                     0x0000000101082988 Mapper.map(JSONObject:) + 160 (__hidden#1191_:89)
14  OurAwesomeApp                     0x00000001010752f0 _hidden#459_ + 644 (__hidden#487_:66)
15  OurAwesomeApp                     0x000000010108896c <- infix(_:_:) + 152 (__hidden#1307_:116)
16  OurAwesomeApp                     0x0000000100ca7248 TWInvoice.mapping(map:) + 4000 (DataClasses.swift:377)
17  OurAwesomeApp                     0x00000001010842cc Mapper.map(JSON:) + 1224 (__hidden#1191_:106)
18  OurAwesomeApp                     0x0000000101087c70 _hidden#1144_ + 24 (__hidden#110_:0)
19  libswiftCore.dylib             0x000000018f3cd61c $sSTsE10compactMapySayqd__Gqd__Sg7ElementQzKXEKlF + 732 (SequenceAlgorithms.swift:807)
20  OurAwesomeApp                     0x0000000101084a68 Mapper.mapArray(JSONArray:) + 212 (__hidden#1191_:166)
21  OurAwesomeApp                     0x0000000101082a8c Mapper.mapArray(JSONObject:) + 192 (__hidden#1191_:156)
22  OurAwesomeApp                     0x00000001010753d4 _hidden#461_ + 148 (__hidden#487_:92)
23  OurAwesomeApp                     0x0000000101088c8c _hidden#1301_ + 196
24  OurAwesomeApp                     0x0000000100ca5b88 TWInvoicesByType.mapping(map:) + 328 (DataClasses.swift:266)
25  OurAwesomeApp                     0x00000001010842cc Mapper.map(JSON:) + 1224 (__hidden#1191_:106)
26  OurAwesomeApp                     0x0000000101082988 Mapper.map(JSONObject:) + 160 (__hidden#1191_:89)
27  OurAwesomeApp                     0x00000001010752f0 _hidden#459_ + 644 (__hidden#487_:66)
28  OurAwesomeApp                     0x000000010108896c <- infix(_:_:) + 152 (__hidden#1307_:116)
29  OurAwesomeApp                     0x0000000100ca3adc TWAccount.mapping(map:) + 104 (DataClasses.swift:81)
30  OurAwesomeApp                     0x00000001010842cc Mapper.map(JSON:) + 1224 (__hidden#1191_:106)
31  OurAwesomeApp                     0x0000000101082988 Mapper.map(JSONObject:) + 160 (__hidden#1191_:89)
32  OurAwesomeApp                     0x0000000100c47c18 closure #1 in DataServer.getAccountInfo(_:) + 492 (DataServer.swift:949)
33  OurAwesomeApp                     0x00000001011d7888 _hidden#2846_ + 164
34  OurAwesomeApp                     0x00000001011db76c _hidden#2893_ + 52 (__hidden#578_:0)
35  OurAwesomeApp                     0x00000001011b55e0 _hidden#996_ + 28 (__hidden#578_:0)
36  libdispatch.dylib             0x0000000181e29610 _dispatch_call_block_and_release + 24 (init.c:1408)
37  libdispatch.dylib             0x0000000181e2a184 _dispatch_client_callout + 16 (object.m:495)
38  libdispatch.dylib             0x0000000181e0d35c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996 (inline_internal.h:2487)
39  CoreFoundation                 0x00000001820da3c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1749)
40  CoreFoundation                 0x00000001820d53b8 __CFRunLoopRun + 2004 (CFRunLoop.c:3069)
41  CoreFoundation                 0x00000001820d48bc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
42  GraphicsServices               0x000000018bf40328 GSEventRunModal + 104 (GSEvent.c:2246)
43  UIKitCore                     0x000000018616a6d4 UIApplicationMain + 1936 (UIApplication.m:4753)
44  OurAwesomeApp                     0x0000000100c1048c main + 68 (InstallmentSchedulesListFactory.swift:25)
45  libdyld.dylib                 0x0000000181f5f460 start + 4

Replies

Have the same issue with xCode 11.2.1. I can build and run from xCode to a device using debug and release profile, but when the app is distributed via Test Flight to the same device it crashes. When I go back to using CocoaPods, everything works.

It seems like it is known issue that still hasnt been fixed even in Xcode 11.3 beta according to release notes 😟

I had a look through the Xcode 11.3 Beta Release Notes and didn’t see anything that resembles this issue. What entry are you referring to specifically?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

If an iOS, tvOS, or watchOS app uses a Swift Package that builds a dynamic library, you can’t submit it to the App Store. (55564324) (FB7303066)

  • Workaround: Modify the Package manifest to build a static library.

It is in Swift Packages - Known Issues

So, did switching to a static library help?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 25…29 Nov in observance of the US Thanksgiving holiday.

Not sure if this helps, but I've linked my SPM dependencies statically to a dynamic framework, which is then shared across the app and extensions. For example, I link RxSwift statically with SPM to MyDynLib, then `import RxSwift` normally in the iOS target.


Do note that MyDynLib is just a dynamic framework target within my Xcode workspace.