App crash when dynamically linked with Combine and launched on iOS 12

My app uses an embed framework.

This framework has a conditional use of Combine with:

- canImport

- @available.


But, when running on iOS 12, app crashes.

dyld: Library not loaded: /System/Library/Frameworks/Combine.framework/Combine
Referenced from: /Users/.../Library/Developer/Xcode/DerivedData/../Build/Products/Debug-iphonesimulator/XYZ_SDK.framework/XYZ_SDK
Reason: image not found

Same thing on device.


Thanks for your help.

Answered by florentmorin in 676472022

Finally working with this solution, also used with SwiftUI:

#if (arch(arm64) || arch(x86_64))
#if canImport(Combine)

// Combine code

#endif
#endif

Are any of your iOS 13 objects implementing a custom hash? I noticed this caused me to crash in iOS 12 and earlier when conditionally linking to Combine
Code Block Swift
 func hash(into hasher: inout Hasher) {
          hasher.combine(foo)
      }


Accepted Answer

Finally working with this solution, also used with SwiftUI:

#if (arch(arm64) || arch(x86_64))
#if canImport(Combine)

// Combine code

#endif
#endif

App crash when dynamically linked with Combine and launched on iOS 12
 
 
Q