1

I need to use a library for my application that requires to be added in the old-fashioned way (there is no pod available or anything else). This framework has the requirement for iOS 14.0 as the minimum supported version.

Is there any way to have that application compile and fully work for a lower version of iOS? My app has to support an iOS version down to 11.0.

For the moment I have a crash when running the iOS 13 simulator right after the application launches. Basically, I want to check if the current running version is greater than 14.0 and initialize a class from the framework, but for the moment the library is included at the compile time.

enter image description here

Later edit: I tried the following things after @Dávid Pásztor suggested the weak linking:

  1. weak import the library (optional): iOS 13 runs ok, but I have a crash on iOS 15: enter image description here
  2. import the library with default values (required): on iOS 15 the class from the library is initialized, but the iOS 13 app crashes after splash screen: enter image description here
Meeshoo
  • 129
  • 11
  • 2
    Yes, you just need to use weak linking. [Official docs for weak linking](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html). And relevant SO Q&A:[What does it mean to weak link a framework](https://stackoverflow.com/questions/16922013/what-does-it-mean-to-weak-link-a-framework) – Dávid Pásztor Jun 29 '22 at 14:13
  • @DávidPásztor I've done this but the application is still crashing when trying to initialize the View Controller which imports the framework. Any ideas on how to fix this? – Meeshoo Jun 29 '22 at 15:08
  • You need to wrap all code that uses the framework in `#available iOS14` statements (or you can try to use `#if canImport` as well, but that might not work). – Dávid Pásztor Jun 29 '22 at 15:22
  • I am already creating an instance of the class using this framework only "if #available(iOS 14, *)". I will try to clean the project and compile it again. Hopefully, it is an Xcode problem. The weak framework seems to be imported correctly. – Meeshoo Jun 29 '22 at 15:25

0 Answers0