Search code examples
iosxcodeimportcocos2d-iphone

Why doesn't @import (module) work in Cocos2d ios?


Sorry, this is probably a very basic question, but I can't find an answer for it. I am trying to add two modules to a Cocos2d project (@import CoreBluetooth; and @import QuartzCore;). When try to add them to my header file I get an error that says, "Unexpected '@' in program." Are modules not supported in Cocos2d? Do I need to do something to enable them? Am I overlooking something else? Thanks.


Solution

  • Modules are by default enabled in new Xcode projects. For existing projects, go to the "Build Settings" and set "Enable Modules" to YES:

    enter image description here

    If you set "Link Frameworks Automatically" to YES as well then all imported frameworks are automatically added to the link libraries.

    A good overview of the @import compiler feature is