How does an app with lower base sdk work?

前端 未结 7 1353
悲&欢浪女
悲&欢浪女 2021-01-05 08:24

In XCode I can specify Base SDK. I am wondering how does that work behind the scenes? If I am running an app, for example, on a device that has iOS 7 and my base SDK is iOS

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 09:07

    Apple never changes / deletes / renames classes or methods. They only add new ones.
    If they don't want you to use it anymore, they mark it as deprecated.

    This is a very important point.
    At compile-time, the compiler checks if all classes and method signatures are available in the SDK your building your app with.

    If that's the case, you can build and deploy your app. Because those classes and methods will never be deleted from newer versions of the framework, your app will run just fine.


    On the other hand, you can build apps and deploy them to systems, which do not actually support the current SDK. For example, you can use Autolayout (NSLayoutConstraint class is available since 10.7) and deploy it for Mac OS X 10.6. The compiler will not say a word.

    The app will crash though on systems prior to 10.7.

提交回复
热议问题