Can't Import Embedded Framework with Xcode 6 Gm

can't import embedded framework with xcode 6 GM

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.

Sample Image

Enable it by changing to YES

Using Cocoapods in embedded framework with Xcode 6 GM

There's a good post that came out today about using the development branch of Cocoapods 0.36.0 which is where frameworks/swift support is being added.

http://swiftwala.com/cocoapods-is-ready-for-swift/

Baring that I've been linking pods into a framework and then including the headers in the bridging header. Its a little wacky but it works so long as you don't want to write swift that uses the pods in the framework itself.

Edit
The pre-release version of 0.36.0 is out you can see the blog post here.

How to import GoogleMobileAds framework?

It seems that one needs to use #import , and specify each specific file as necessary. For example:

#import <GoogleMobileAds/GoogleMobileAds.h>

I guess the instructions on the Google site are out of date.

How do I use Cocoapods in an embedded framework?

Assuming in your Podfile you are using the link_with 'MyCustomFramework', where 'MyCustomFramework' is your embedded framework name, and have run pod install. Select your Project file (Blue on the top right) and go into "Build Settings". Then, find 'Allow non-modular includes in Framework Modules' and set it to YES, for both the Project file (blue) and the Custom Framework target (ex. MyCustomFramework - orange "lunchbox case" icon).

Setting build settings for non-modular includes

Then you can include cocoa pods stuff in your main MyCustomFramework.h file.
Including CocoaPods in CustomFramework

Then just import '@import MyCustomFramework;' in your Application target, and you'll get the rest of the CocoaPods at your disposal. (Ex. showing you access to 'each' from ObjectiveSugar).
Importing CustomFramework into AppDelegate

Whether you should do this or not is a separate issue, but this allows your Custom Framework to include the CocoaPods libraries in itself, which then allows the Application target to just include your Custom Framework and gets all the CocoaPods as well.

Sorry for the multiple images, but I like to be visual.

Optional Framework Not Working (CoreAudioKit not on Simulator)

I actually would have thought that would work, but I think you can solve it another way. This worked for me:

  1. remove all references to CoreAudioKit in your target settings Build Phases (Link Binary With Libraries)

  2. make sure there's no similar settings entered in manually. for example, don't add this setting: -weak_framework CoreAudioKit in the Other Linker Flags

  3. use preprocessor flags to conditionally compile your code for the simulator:

#import "ViewController.h"

#if !TARGET_IPHONE_SIMULATOR
@import CoreAudioKit;
#endif

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

#if !TARGET_IPHONE_SIMULATOR
if ([CABTMIDICentralViewController class]) { // maybe not needed?
CABTMIDICentralViewController *vc = [[CABTMIDICentralViewController alloc] init];
}
#endif
}

Note: in my example above, you might not need to test for the existence of the CABTMIDICentralViewController class. It depends on whether your app is targeting only iOS 8+, or also iOS 7.

Update

Per comments below by @Yar and @JeremyHuddlestonSequoia, note that this solution requires you to Enable Modules and Link Frameworks Automatically in project build settings. These Xcode settings now default to the proper values for this technique, but in case you're managing an older project, make sure they're enabled.

Other References

https://stackoverflow.com/a/26510640/119114

https://stackoverflow.com/a/25883210/8047

iOS CocoaPods - how to resolve use of '@import' when modules are disabled error?

I googled a lot, but hacked the solution for your problem myself. Cleaning the project, re-building etc. wasn't working for me.

The solution is to wrap API into Cocoa Class, and use this class in your imports instead of original.

  1. Create class, for example APAnalyticsTracker, where AP supposed to be your common application prefix. Here you'll have two files: APAnalyticsTracker.m and APAnalyticsTracker.h
  2. Import #import <Google/Analytics.h> in APAnalyticsTracker and wrap the original implementation like this (see Gist for more information): https://gist.github.com/vladignatyev/c240a1a4867b17894b10
  3. Use APAnalyticsTracker.h from .mm files freely.
  4. Remember to enable modules, see https://stackoverflow.com/a/33125158/882187 comment from @barrast

Importing Contacts Framework in xcode7 , Swift2

Yes try giving some different project name say"MyContactsDemo". it should work.

Note:posted in answer block as suggested by the person who questioned.



Related Topics



Leave a reply



Submit