Skip to content

Instantly share code, notes, and snippets.

@Gaia-Murata
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaia-Murata/688d99b53f62d79d6795 to your computer and use it in GitHub Desktop.
Save Gaia-Murata/688d99b53f62d79d6795 to your computer and use it in GitHub Desktop.
importより安全で効率的な@import

#importより安全で効率的な@import http://stackoverflow.com/questions/18947516/import-vs-import-ios-7

You can use modules with any of the system frameworks in iOS 7 and Mavericks.

iOS7とMavericksフレームワークで使える

you don't need to add the framework in the project settings, it's done automatically.

(+ボタンで)フレームワークを追加する必要がない

You don't actually need to use the @import keyword. If you opt-in to using modules, all #import and #include directives are mapped to use @import automatically.

別に@importを使わなくても勝手にマッピングしてくれる (昔のプロジェクトを変更する必要なんてない)

Modules only work with Apple frameworks (UIKit, MapKit, GameKit, etc).

Appleのframeworkしか対応してない

Modules are enabled by default in new projects in Xcode 5 . To enable them in an older project, go into your project build settings, search for "Modules" and set "Enable Modules" to "YES".

Xcode5の設定でEnable ModulesをYESにすれば昔のプロジェクトでもそのまま使える

You have to be using Xcode 5 and the iOS 7 or Mavericks SDK, but you can still release for older OSs (say iOS 4.3 or whatever). Modules don't change how your code is built or any of the source code.

Xcode5でiOS7 か Mavericks SDK なら昔のOSでもソースコード変更する必要はない (昔のOSでも使えるって意味だと思われ)

From the WWDC slides:

  • Imports complete semantic description of a framework
  • Doesn't need to parse the headers
  • Better way 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
 Replace #import  with @import Cocoa
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment