can't import embedded framework with xcode 6 GM
Asked Answered
E

3

43

I added a framework target in my project. But when I attempt to import the framework, the compiler will return an error Use of '@import' when modules are disabled. I have already included the arm64 architecture in its Architectures build settings. And I can see the framework in Build Phases. I can import a framework in a new project instead of my current project. Is there any additional config I missed?

Effervesce answered 17/9, 2014 at 5:48 Comment(0)
E
102

Use of '@import' when modules are disabled

Error msg says you are trying to use modules by @import when it is disabled. Goto build settings and enable modules or use #import instead.

enter image description here

Enable it by changing to YES

Ecg answered 17/9, 2014 at 5:53 Comment(7)
All the frameworks will not support modules i guess, so you might have to use #import insteadEcg
what you gotta dig through all the LLVM <X.n> options and set this setting? i would expect nothing less from what I've seen so far with xcode/swift.Ellaelladine
@import GoogleMobileAds; But I get error saying Module 'GoogleMobileAds' not found. I also installed latest GoogleMobileAds 7.0 from podsMyrtamyrtaceous
@KumarMaishi I also still have this error. How did you fix it?Embonpoint
@Embonpoint I fixed this by removing GoogleMobileAds from pods and added by just drag and dropMyrtamyrtaceous
@MaishiWadhuwani dragging what and where you drop it, i'm confused, can you help me with that, because i'm stuck on this errorWilldon
@PradnyanandMilindPohare Add GoogleMobileAds drag and drop directly in your project. And add in "Linked Framework and Libararies"Myrtamyrtaceous
P
38

For those that still have problems with enabling Modules.

The problem could be that the header file was imported into file.mm file (objective-c++), which is not supported to the @import module syntax.

Here is a good answer explaining other possible problems. https://mcmap.net/q/16276/-import-quot-unexpected-39-39-in-program-quot

Pak answered 7/7, 2015 at 8:38 Comment(1)
This is correct! You saved me hours of mucking about!Nantucket
S
1

I have the same problem in Xcode 7. I have found the solution. It's to wrap Google Analytics into Cocoa Class (.m and .h), and use this wrapper from your .mm files. Also you should enable modules in Xcode.

For more information, please check my answer (and my Gist) here: https://mcmap.net/q/390191/-ios-cocoapods-how-to-resolve-quot-use-of-39-import-39-when-modules-are-disabled-quot-error

I'm sorry, if it looks like I'm trying to spam, but I don't know how to re-link all those questions and answers better in one self-containing discussion thread.

Seleneselenious answered 28/3, 2016 at 17:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.