October 28th, 2013
A new compiler feature in Xcode 5 is modules. Modules simplify importing header files and linking frameworks. They also can build your project faster, working similarly to precompiled headers.
To use modules you must be using either the Mac OS X 10.9 SDK or the iOS 7 SDK. Modules do not work with earlier SDKs. Module support is currently limited to C and Objective-C code.
Xcode has two build settings for modules. If you want to use modules in your Xcode project, you must set the Enable Modules (C and Objective C) build setting to Yes. Setting the Link Frameworks Automatically build setting to Yes keeps you from having to manually add frameworks to your Xcode project.
To import a framework’s header files, use the @import statement and supply the name of the framework. The following example imports the header files from the Cocoa framework:
To import a single header file from a framework, add a period to the framework and supply the name of the header file. The following example imports the header file AudioHardware.h from the Core Audio framework:
Currently you can use @import only with Apple’s frameworks.
If you have existing code that uses #import or #include to include headers, you can support modules without changing your code. Set the Enable Modules build setting to Yes, and Xcode will use modules to build your project.
Tags: xcode 5