Don't we need to link framework to XCode project anymore?

后端 未结 2 1803
挽巷
挽巷 2021-02-02 17:35

Base on this question

Why don\'t iOS framework dependencies need to be explicitly linked to a static library

I read the selected answer and still don\'t understa

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 18:02

    Check your project build settings. Underneath LLVM 5.1 — Language — Modules you should see the option 'Link Frameworks Automatically'. In your case it sounds like it's set to 'YES', the default.

    In that case, instead of producing an error when you reference a class that the compiler doesn't know, it'll figure out which Framework contains that class and link it. In your code it'll be MKMapView or one of the other MapKit classes that triggers the linkage.

    EDIT: from the relevant 'What's New?' document:

    Auto Linking is enabled for frameworks imported by code modules. When a source file includes a header from a framework that supports modules, the compiler generates extra information in the object file to automatically link in that framework. The result is that, in most cases, you will not need to specify a separate list of the frameworks to link with your target when you use a framework API that supports modules.

    Another way of looking at it is that the compiler is smart enough to mutate #import to @import when the framework has been built appropriately. All system frameworks have been.

提交回复
热议问题