The new syntax in Objective-C
in Xcode 5
is @import
to import a framework.
See question for details. Advantage is that you don't have to include the framework in project avoiding linker errors, you don't need to add quotes and .h to just the name of the framework, it is faster for precompiled headers, and you have a namespace that protects you from accidentally renaming a symbol. All nice additions.
My question is, for your own files, for example MyFancyViewController.h, do you continue to use #import
or does @import completely replace it? Also, can I define my own modules easily? Just looks more messy having both syntaxes in the same file.
for you including of your project files do you continue to use #import or does @import completely replace it?
@import
, so far, is for Apple frameworks only, so at the time of writing you still have to use #import
for anything else.
The good news is that, if you opt-in, any #import
will be implicitly replaced for you by the compiler, so you don't need to convert your previous code to benefit from modules.
Also, can I define my own modules easily?
Yes and no.
Yes, it's easy, but...
...no you cannot, since this feature is currently not supported for non-Apple frameworks.
To define your own module - if you could - you would need to do:
export MyAwesomeModule:
public:
// methods and whatever you want to export
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With