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.
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).
Then you can include cocoa pods stuff in your main MyCustomFramework.h file.
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).
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:
remove all references to CoreAudioKit in your target settings Build Phases (Link Binary With Libraries)
make sure there's no similar settings entered in manually. for example, don't add this setting:
-weak_framework CoreAudioKit
in the Other Linker Flagsuse 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.
- Create class, for example
APAnalyticsTracker
, whereAP
supposed to be your common application prefix. Here you'll have two files:APAnalyticsTracker.m
andAPAnalyticsTracker.h
- Import
#import <Google/Analytics.h>
inAPAnalyticsTracker
and wrap the original implementation like this (see Gist for more information): https://gist.github.com/vladignatyev/c240a1a4867b17894b10 - Use
APAnalyticsTracker.h
from.mm
files freely. - 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
Info.Plist Utility Error: "Info.Plist Couldn't Be Opened Because There Is No Such File"
Get Uiwebview Content's Height
Container View Getting Pushed Down as If It Had a Uinavigationbar
Detect Which App Is Currently Running on iOS Using Sysctl
How to Prevent Initial White Flash When Showing a Uiwebview
How to Have One Static Cell in a Dynamic Tableview
(iOS + Storekit) How to Detect When I'm in the Sandbox
Best Way to Save and Retrieve Uicolors to Core Data
Property Cannot Be Found in Forward Class Object
Ios6 Simulator Mkmapkit "Couldn't Find Default.Styleproto in Framework"
Swift How to Change Uialertcontroller's Title Color
How to Convert a Kcvpixelformattype_420Ypcbcr8Biplanarfullrange Buffer to Uiimage in iOS
Difference Between Completion Handler and Blocks:[Ios]
Property "Assign" and "Retain" for Delegate
How to Add a Credit/Debit Card into Apple Wallet from the iOS App