Experimental tools:

Phones: iPhone 6s(12.1.2), iPhone8(14.0), iPhone8 Plus(15.3.1)

Environment: Xcode13.1, Xcode13.2.1, Xcode13.3


Check the dynamic link library at startup

Breakpoint debugging in main.h:

LLDB debugging image list

1. Xcode13.1

To compile successfully on Xcode13.1: add -wl, -weak-lswift_concurrency -wl,-rpath,/usr/lib/swift to Other Linker Flags in build Settings of your application.

On the iOS12
(lldb) image list
[  2] . /XX.app/Frameworks/libswiftCore.dylib 
[.] .slightlyCopy the code
On the iOS14
(lldb)image list
[  2] . /usr/lib/swift/libswiftCore.dylib 
[.] .slightlyCopy the code

On the iOS15
(lldb)image list
[  1] . /usr/lib/swift/libswift_Concurrency.dylib 
[  6] . /usr/lib/swift/libswiftCore.dylib 
[.] .slightlyCopy the code
  • Unpack the:There's no Framworks folder, so the dynamic library is embedded in iOS15
The conclusions are as follows:
  • On iOS15 or laterStorekit2DemoAll compiled successfully;
  • The only difference is that libswift_Concurrency. Dylib is only embedded in the IPA package on iOS 15
  • Libswift_Concurrency. Dylib is not referenced below iOS15
  • PS: Note that the swift dynamic library on ⚠️ iOS12 is called in the form of embedded ipA /Frameworks;

2. Xcode13.2

  • Xcode 13.2 Releasae Notes:

Apple Clang Compiler

Known issues: Applications built with Xcode 13 or Xcode 13.1 using Swift concurrency features (such as async/await), deployed to iOS before 15, tvOS before 15, or watchOS before 8, And enabling bitcode may crash at startup reporting an error that the libswift_Concurrency. Dylib library is not loaded. (86349088).

Add -wl, -weak-lswift_concurrency -Wl,-rpath,/usr/lib/swift to Other Linker Flags in build Settings.

  • Swift, new features

You can now use Swift Concurrency in applications deployed to macOS Catalina 10.15, iOS 13, tvOS 13, and watchOS 6 or later. This support includes async/await, Actors, Global Actors, Structured Concurrency, and the Task APIs. (70738378).

Required:

Concurrency Concurrency is a problem with Xcode13.2 for devices below iOS15. Concurrency issues in Xcode13.2 and later versions are due to Swift Concurrency for iOS13.0;


3. Xcode13.2.1

  • Xcode 13.2.1

Fixed issue fixes a bug where applications built using Xcode 13 or Xcode 13.1 sometimes crash at startup, incorrectly reporting

The libswift_Concurrency. Dylib library is not loaded. This only affects apps that use Swift concurrency features (such as async/await), are deployed to iOS before 15, tvOS (before 15) or watchOS (before 8) and have bitcodes enabled. (86349088);

But this is just a fix for crashes on iOS13 and iOS14; IOS13.0 was not fixed;

Let’s analyze the facts based on these conclusions, starting with iOS14, iOS15, and then looking at iOS13;

On the iOS14
(lldb)image list
[  2] . /XX.app/Frameworks/libswift_Concurrency.dylib
[  3] . /usr/lib/swift/libswiftCore.dylib 
[.] .slightlyCopy the code
  • Ipa package solution:

On the iOS15

No changes, all dynamic libraries are on the machine, no Framworks folder;

In conclusion:

  • IOS14 and iOS15 are running properly.
  • But we can see a change in iOS14:Libswift_Concurrency. Dylib is embedded in the IPA /Frameworks;
  • You can still use libswiftcore. dylib on a real phone for iOS14.
Let’s go back to iOS12
  1. dyld: Library not loaded: /usr/lib/swift/libswiftCore.dylib

Referenced from: /private/var/containers/Bundle/Application/0D0C91E1-8B80-4AD9-9EFC-0F6C82A0F87E/XXX.app/Frameworks/libswift_Concurrency. dylib

Description: the libswiftCore.dylib dynamic library could not be loaded because libswift_Concurrency. Dylib references it.

Unpack the:

In conclusion:

  • -> libswiftcore.dylib failed on iOS12
  • Libswiftcore. dylib is not set to ipA /Framworks, so libswift_Concurrency.
  • And since Swift is only forward compatible to iOS13.0, there is an apple Xcode BUG: libswift_Concurrency. Dylib should not be set Instead, you should add libswiftCore.dylib to Framworks to keep your app running properly.
The solution

So there are two solutions:

  • When setting libswift_Concurrency. Dylib to IPA /Framworks, set it to dependency libraries such as libswiftCore.dylib.
  • Devices under iOS13 do not run into the libswift_Concurrency. Dylib library because of a crash caused only by its reference problems;

4. The Xcode 13.3

On the iOS12
(lldb)image list
[  2] . /XX.app/Frameworks/libswift_Concurrency.dylib 
[  3] . /XX.app/Frameworks/libswiftCore.dylib 
[  4] . /XX.app/Frameworks/libswiftAVFoundation.dylib 
[.] .slightlyCopy the code

On the iOS14
No change,libswift_Concurrency. Dylib is set to the ipA package,libswiftCore.dylib is still set to the real machine.Copy the code
On the iOS15
No changes, all dynamic libraries are on the machine, no Framworks folder;Copy the code

In Xcode13.3 compilation, we mainly focus on:

  1. Compared with Xcode13.2.1, iOS13 and above devices have no change;
  2. Libswift_Concurrency. Dylib, libswiftCore. Dylib, libswift_Concurrency.

Second, analyze the problem process

Main sources of problems:

  • Concurrency is a Concurrency feature that allows Concurrency Concurrency to be forward-compatible with iOS13 when an APP under iOS15 starts a crash.
  • Xcode13.2.1 release claims to have fixed the above bug, in fact, there are iOS13 following devices boot crash problem;
  • Xcode13.3 fixes the above bugs;

We found an exception in Xcode13.2.1 on iOS12:

Instead of binding libswift_Concurrency. Dylib to the package, bind libswiftCore.dylib to Framworks to ensure your app runs properly. >

Xcode13.3 here is mainly:

  • Fix the problem by typing the required libswift_Concurrency. Dylib with libswiftCore.dylib.
  • But that would solve the problem, butLess rigorous: Increased the size of the bag and did not solve the problem(All iOS13 package bodies below will be added), which incidentally takes advantage of the lack of access to the library API in iOS13 below;

Rigorous up

We mentioned above in Xcode13.2.1:

So there are two solutions:

  • When setting libswift_Concurrency. Dylib to IPA /Framworks, set it to dependency libraries such as libswiftCore.dylib.
  • Devices under iOS13 do not run into the libswift_Concurrency. Dylib library because of a crash caused only by its reference problems;

Our current needs:

  • Run StoreKit2 suite on iOS15, which is only available on iOS15;
  • There is a reference to libswift_Concurrency. Dylib in the suite, which is forward compatible with iOS13.0.
  • As an SDK provider, we need to provide services for different projects and different versions of Xcode, so we cannot require the other party to use the fixed version of Xcode13.3.
  • To sum up, we only need to run on iOS15 on any Xcode13+ version;

So the solution: on devices below iOS15, do not put libswift_Concurrency. Dylib in the IPA /Frameworks;

How to solve:

delete / Applications/Xcode. App/Contents/Developer/Toolchains/XcodeDefault xctoolchain/usr/lib/swift – 5.5 / iphoneos libswift_Concu Rrency dylib file

Validation protocols

1.1 iOS12
(lldb)image list
[  2] . /XXX.app/Frameworks/libswiftCore.dylib 
[.] .slightlyCopy the code

Unpack the:

1.2 iOS14
(lldb)image list
[  2] . /usr/lib/swift/libswiftCore.dylib 
[.] .slightlyCopy the code

Unpack: No Framworks folder;

1.3 iOS15
(lldb)image list
[  3] . /usr/lib/swift/libswift_Concurrency.dylib 
[  2] . /usr/lib/swift/libswiftCore.dylib 
[.] .slightlyCopy the code

Unpack: No Framworks folder;

All the above are working properly, and Storekit2 is working properly on iOS15.

So far solved, thanks to 🙏

libswift_Concurrency.dylib

StoreKit2 [attached source code

Dynamic linker DYLD process analysis