9

I have a header in a CocoaPods project I'm working on in Xcode 6, in which I have an @import Cocoa; statement. It builds fine in its own project, but when I integrate it into the client app, I get the following error:

Use of '@import' when modules are disabled

I checked the CLANG_ENABLE_MODULES setting in every target of my client project, as well as every target in the Pods project, and every single one is set to YES. What could be triggering this error. I can switch back to a #import, which does fix it, but I'd like to understand why this is happening, since everything looks like it's configured properly.

I pushed my podspec (UnzipKit), but I also replaced the @import statements with #import to get it working. Also, I'm using Cocoapods 0.35.0. If you use this in your Podfile, it'll get you the @import version.

pod 'UnzipKit', :git => 'https://github.com/abbeycode/UnzipKit.git', :commit => '38cd0225015a245b0d3167666b3f40d57f99147a'
Dov
  • 14,039
  • 12
  • 71
  • 151
  • Do you resolve problem? I also use cocoapods with library that use `@import`. In one project all works fine, in other I get the same error. Modules are enabled everywhere. – Gralex May 05 '15 at 08:54
  • @Sk0prion No I didn't. As mentioned, I had to revert back to `#import`s everywhere. – Dov May 05 '15 at 18:33

1 Answers1

6
Use of '@import' when modules are disabled

If you are using Xcode version6 then make sure that below two things should be enable inside Language Module settings. Refer the attached screenshot:- enter image description here

If you are using Xcode version lower than 6, You will get error because the module only work with apple framework and you cannot use them in other framework or third party Apps. You can check here

For more details of this answer check this stackOverflow answer

Community
  • 1
  • 1
Hussain Shabbir
  • 13,963
  • 4
  • 34
  • 53
  • Why would someone downvote this? That's the right answer, you can only use `@import` on Apple frameworks like `@MapKit`. – barndog Dec 24 '14 at 18:32
  • 1
    I updated the question to mention that I _am_ using Xcode 6. Besides, I am importing Cocoa and Foundation, which are Apple frameworks. – Dov Dec 25 '14 at 03:34
  • 1
    This doesn't solve my problem. I can add "@import" but then sometimes I get the same error. – Daniel Ryan May 05 '15 at 21:39