Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modules are disabled - but why?

I'm struggeling with Modules in a project. Where I use @import I get "Use of '@import' when modules are disabled". But why are they disabled?

  • In my build settings I have "Enable modules (C and Objective-C)" set to Yes for all targets.
  • Setting "Link Frameworks Automatically" to Yes or No does not impact this (compile-time) error
  • Although the project used to have Objective-C++ and some C++ code, it doesn't anymore. Are there any project-settings I can have missed that were set because of this?
  • I have no more .pch files in the project, and the build settings have no mention of them
  • I use CocoaPods (0.39.0) with "use_frameworks!" and the modules I wish @import are from there. But the same error happens if I replace the '#import ' or '#import ' with '@import Foundation;' and '@import UIKit', so I expect this is not related
  • The project is from pre-iOS7 so I might have missed a setting that used to be on by default
  • The project requires iOS 8 and builds against iOS 9.2.

I realize that loading third-party modules will probably slow down the apps loading time. I'm converting to CocoaPods with use_frameworks! so that I can measure by how much. If it's not too bad, I'd like to use as I'm planning to move multiple swift-only parts of the codebase into their own frameworks (as open source coocapods)

I believe that this is not be a duplicate of other questions on SO since I've gone through the ones I found (big thank-you to this one), followed the links, re-watched WWDC'13 session 404, and read the related posts on Apples forums, so I believe I've done my homework. :-)

like image 325
niklassaers Avatar asked Dec 26 '15 19:12

niklassaers


1 Answers

In my project I have a bridging header to bridge from ObjC to Swift, and there is a generated header file to bridge from Swift to ObjC. It turns out that if the bridging header referenced headers where the implementation file referenced the bridge file from Swift to ObjC, module support is disabled. So be careful about what you put in your bridging file, and be careful about when you import the generated -Swift.h file.

like image 177
niklassaers Avatar answered Nov 09 '22 04:11

niklassaers