Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing to @import causes build errors #1139

Closed
sbwilson opened this issue Nov 21, 2015 · 4 comments
Closed

Changing to @import causes build errors #1139

sbwilson opened this issue Nov 21, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@sbwilson
Copy link

The changes in ffbe551 cause my builds to break with the error:

error: use of '@import' when modules are disabled
@import Foundation;

This occurs in a cocoapods-based project (using the release/3.0 branch by :git/:branch) with Modules enabled in the build settings for this project (though not used anywhere else). The error occurs when compiling the application's PCH, using #import <MagicalRecord/MagicalRecord.h>. I've tried replacing that with @import MagicalRecord with the same error.

Any hints how to get around this? Since Xcode 6+ (and perhaps earlier) treats #import the same as @import, it doesn't make much sense as to why this change is needed...

Thanks!

@tonyarnold
Copy link
Contributor

That's because CocoaPods completely ignores the Xcode project 😦

Telling Cocoapods to use frameworks would probably fix it, but I'll have a look when I have some time.

@sbwilson
Copy link
Author

I'm already building with use_frameworks!. Here's my complete Podfile if it helps...

source 'https://github.com/CocoaPods/Specs.git'

workspace '../MyApp'
xcodeproj '../MyApp'

platform :osx, '10.10'
inhibit_all_warnings!
use_frameworks!

target :MyApp do
  pod 'Typhoon', '3.3.4'
  pod 'ReactiveCocoa', '~> 2.0'
  pod 'JLRoutes'
  pod 'GCDWebServer'
  pod 'NSLogger', '~> 1.5'
  pod 'CocoaLumberjack', '~> 1.9'
  pod 'MagicalRecord/Shorthand', :git => 'https://github.com/magicalpanda/MagicalRecord', :branch => 'release/3.0'
  pod 'RegexKitLite', '~> 4.0'
  pod 'JRSwizzle', '~> 1.0'
  pod 'RXCollections'
  pod 'YAML-Framework', '~> 0.0.1'
  pod 'CoreParse'
  pod 'MAKVONotificationCenter'
  pod 'sundown'
  pod 'DirectoryWatchdog', '~> 1.1'
end

@tonyarnold tonyarnold added the Bug label Nov 21, 2015
@tonyarnold tonyarnold added this to the 3.0.0 milestone Nov 21, 2015
@tonyarnold tonyarnold self-assigned this Nov 21, 2015
@tonyarnold
Copy link
Contributor

Yeah, there's probably some CocoaPods setting you could have fiddled with here, because not supporting @import seems like a massive oversight (and I don't believe that team would have overlooked this).

But I don't have time to muck about with CocoaPods, so I've just reverted to using the older framework import syntax. Let me know if this doesn't work for you.

@sbwilson
Copy link
Author

That does seem to fix the problem. Thanks!

On further investigation, it seems that it may be a problem with ObjectiveC++ (which we use a fair amount of). An answer to a Stack Overflow question suggests that the flag -fcxx-modules is the solution. I've tried it with a blank Cocoa App, and confirm that @import in the AppDelegate.h (with AppDelegate.mm) does cause the same error, and -fcxx-modules in "Other C++ Flags" does fix said errors. However, it's no longer documented in the latest documentation, and given that the SO answer suggests that it is "EXPERIMENTAL and VERY BROKEN", I wonder if #import would be much preferred at this stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants