Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent building on App with SDK having a lower deployment target

Tags:

xcode

ios

I created a static library that has a Deployment Target of iOS 10.2. The library is integrated in an app that has a Deployment target of 9.0.

Somehow the app builds and runs fine on iOS 9.0. Why is that? Should the app build even though the library only targets iOS 10.2 and above?

like image 793
Titouan de Bailleul Avatar asked Mar 01 '17 09:03

Titouan de Bailleul


1 Answers

Yes, Your build will compile without error if your app's Base sdk is equal or higher than Deployment target of static library.

Static Library internally is bunch of complied object. after your app compiles,at the time of linking, it checks for availability of symbols used in static library. and if your project's base sdk is equal or higher than Static library's deployment target, your project will find definition of all the symbols used in library -So No compiler error.

At runtime, you may get error if you use your app on device with ios version lower than static library's deployment target and have used symbols not available in that version.

If your code/library's uses a symbol:

  1. Not defined in the base SDK of main project (for example, a symbol from a newer OS in library), you get a compile-time error.
  2. Defined in the base SDK but marked as deprecated, you get a compile-time warning.
  3. Defined in the deployment target, your code links and builds normally. At run time:

    • On a system running an OS earlier than the deployment target, your code may fail to load if you use symbols unavailable in that OS.
    • On a system running an OS equal to or later than the deployment target, your code has null pointers for symbols not available in that OS.

Source: developer.apple.com

here is Image from above link, explaining what symbols you can use depending on deployment target and base sdk Image from above link, explaining what symbols you can use depending on deployment target and base sdk.

like image 183
PlusInfosys Avatar answered Oct 11 '22 18:10

PlusInfosys