5

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<A>(_:_:) + 612 (__hidden#1488_:38)
2   OurAwesomeApp                       0x0000000101074434 <- infix<A>(_:_:) + 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<A>(_:_:) + 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<A>(_:_:) + 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 (OurAwesomeFactoryFactory.swift:25)
45  libdyld.dylib                   0x0000000181f5f460 start + 4

1 Answer 1

7

2019-11-27 update

In the related Swift bug post, somebody has found a workaround:

Setting DEAD_CODE_STRIPPING = NO in our app’s target fixes the crash.


original post

First of all, it is a compiling issue of SPM. Simply just rollback to CocoaPods.

Until Xcode 11.2.1, Apple has not yet fixed this issue.

Delete all the derived files, clean the project. And then try running your project with the release configuration. Now you should be able to reproduce the crash.


I was using two libs named Moya and Parchment in an iOS project, with Swift Package Manager, migrated from CocoaPods. And the app downloaded from TestFlight crashes when the logic referencing the two libs is executed.

And the crash log looks completely like nonsense, pointing to a memory alignment issue of the method descriptor of a method.

Apple mentioned a known issue in Xcode release note, I don't know if it is related:

If an iOS, tvOS, or watchOS app uses a Swift Package that builds a dynamic library, it cannot be submitted to the App Store. (55564324)

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

4
  • we did migrate back immediately, but I still wanted to solve the issue. It is not fixed in Xcode 11.3 beta either Nov 25, 2019 at 23:30
  • @ZdeněkTopič the release note of Xcode 11.3 did not mention this issue. But someone has found a solution, I edited my answer.
    – iMoeNya
    Nov 27, 2019 at 3:53
  • It is there in release notes, the same message as you posted in your original post, it is last item in the release notes for 11.3 beta. Nov 28, 2019 at 9:20
  • 1
    This still an issue on Xcode 12.2 with Swift 5.3; Thank you, we didn't know where else to do after a week of crashes that seemed to be unavoidable. Nov 19, 2020 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.