@import vs #import-ios 7

Source: Internet
Author: User

It ' s a new feature called Modules or "semantic import". There ' s more info in the WWDC Session 205 & 404 Videos. It ' s kind of a better implementation of the pre-compiled headers. You can use modules with any of the system frameworks in IOS 7 and Mavericks. They is a packaging together of the framework executable and it ' s headers and is touted as being safer and more Efficien T than #import .

one of the big advantages of using  @import  is that you don't have the to add the framework for you want I n the project settings, it ' s done automatically. That means so can skip the step where you click the plus button and search for the Framework (Golden Toolbox), then Move it to the "frameworks" group. It would save many developers from the cryptic "Linker error" messages.

also, you don't actually need to use the  @import  keyword. If you opt-in to using modules, all #import  and  #include  directives is mapped to use  @import  automatically. That means, you don ' t has to change your source code (or the source code of libraries, that's download from Elsewher e). Supposedly using modules improves the build performance too, especially if you haven ' t been using pchs well or if your Project has many small source files.

Modules is enabled by default in new projects in Xcode 5. To enable them in a older project, go into your project build settings, search for "Modules" and set "Enable Modules" to "YES". The "Link frameworks" should be "YES" too:

You are using Xcode 5 and the iOS 7 or Mavericks SDK, but can still release for older OSs (say IOS 4.3 or whate ver). Modules don ' t change how your code was built or any of the source code. You can ' t use them for your own frameworks.

From the WWDC slides:

  • Imports Complete Semantic Description of a framework

  • doesn ' t need to parse the headers

  • Better to import a framework ' s interface

  • Loads binary representation

  • More flexible than precompiled headers

  • Immune to effects of local macro definitions (e.g. #define readonly 0x01 )

  • Enabled for new projects by default

To explicitly use modules:

Replace with #import <Cocoa/Cocoa.h>@import Cocoa;

You can also import just one header with this notation:

@import Iad.adbannerview;

The Submodules autocomplete for your in Xcode.


@import vs #import-ios 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.