I have a iOS Swift Project on Xcode.
I've been working on it for a long while using external Objective-C libraries on my Swift code with no problem.
Suddenly, after Xcode got updated (I guess), I try to run my project and apparently it's trying to compile de external Objective-C as Swift, so, of course, it fails.
I attach an screenshot with the errors:
And this is my Bridging Header:
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#import <Parse/Parse.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <Bolts/Bolts.h>
//#import <Facebook-iOS-SDK/FacebookSDK/FacebookSDK.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <Bugsnag.h>
#import <M13Checkbox.h>
#ifndef VideoCloudBasicPlayer_VideoCloudBasicPlayer_Bridging_Header_h
#define VideoCloudBasicPlayer_VideoCloudBasicPlayer_Bridging_Header_h
#import "BCOVPlayerSDK.h"
#endif
Any ideas?
Hmm.. I had the same issue before.
After trying to clean and remove derived data, I fixed it by removing the old obj-c libraries and re-adding them to my project. There may be a setting in target to tell the ARC to read objective c, but I never found it.
My Obj-c libraries somehow lost their target membership and thought it was swift.
Commit your changes. Save your bridging header and remove the library and re-add the library, File - New - Target - (make sure Obj-C is set as language), then add your class files to the directory. It should compile...
It didn't work before due to I'm using Parse as my first Cocoapod dependency. So I erased it from my Podfile and installed it by drag and drop style.
Then, just after that my final solution to my issue when working with Cocoapods dependencies was to delete everything (except Parse), update the Cocoapods to the latest version, reinstall everything (while Xcode is closed).
PD:
The solution above works perfectly when using Drag-and-drop installed libraries.
Related
I get No such module 'BRLMPrinterKit' error.
I take a reference from official document https://support.brother.com/g/s/es/htmldoc/mobilesdk/guide/getting-started/getting-started-ios.html to import framework.
Here is my step:
drag BRLMPrinterKit.framework and BRLMPrinterKitW.framework into my framework folder
Check they are in Link Binary With Libraries (remove and drag again)
Check Framework Search Paths (I'm not sure it correct or not)
Check Header Search Paths (I'm not sure it correct or not)
Finally I clean and build get No such module 'BRLMPrinterKit' error.
I have no idea how to fix my import problem, any help would be appreciated. Thanks.
That's not a Swift module, so first, you need to create a bridging header, in which you import <BRLMPrinterKit/BRLMPrinterKit.h>, then you can use the BRLM classes in your Swift files.
Try using CocoaPods to install the framework, it's more convenient and faster.
Your framework supports installation using cocoapods
https://cocoapods.org/
https://github.com/jonathantribouharet/BRLMPrinterKit
using CocoaPods to install the 'BRLMPrinterKit' framework.
add the bridge file.(Targets > Build Settings > Swift Compiler - General > Objective-C Bridgeing Header)
the bridge file.h
#ifndef PtouchPrinterKit_Bridging_Header_h
#define PtouchPrinterKit_Bridging_Header_h
#import <BRLMPrinterKit/BRPtouchBluetoothManager.h>
#import <BRLMPrinterKit/BRPtouchDeviceInfo.h>
#import <BRLMPrinterKit/BRPtouchNetworkManager.h>
#import <BRLMPrinterKit/BRPtouchPrinter.h>
#import <BRLMPrinterKit/BRPtouchPrinterData.h>
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>
#import <BRLMPrinterKit/BRPtouchPrintInfo.h>
#endif
then you can use the framework
I downloaded code from here:
https://github.com/QuickBlox/quickblox-ios-sdk
wich include sample-chat-swift example folder where seems somehow guys created a framework.
In my case if I just use cocoa pods to pull code into my project Xcode says to me that we can't find any of downloaded classes. So I am sure that is problem with bridging but my question what are the steps I need to do to create framework like guys did in theirs example.
Or do I need to bridge each files manually? If so I guess it can take so much time.
I created my own framework for using Tumblr in an app. I'm sure you know how to setup a framework project, but I'll explain what I did when I complied the framework. After you finished the framework what you do is under your xcode project folder in the directory is a fold Products. The text for Project.framework should be red or black. Either way run your project and make sure its black. Then right click and choose Show in Finder. Then you can copy that framework and bring it into the top of the project you want to use the framework in.
You will also need to make a header file. Like the one I have below if you are using Obj-c, but I'm sure you can google and find an example in swift it you are trying to hide certain aspects of your framework with a swift interface file.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
//! Project version number for Tumblr.
FOUNDATION_EXPORT double TumblrVersionNumber;
//! Project version string for Tumblr.
FOUNDATION_EXPORT const unsigned char TumblrVersionString[];
// In this header, you should import all the public headers of your framework using statements
//#import <Tumblr/Tumblr.h>
#import "TMSDKUserAgent.h"
#import "JXHTTPDataBody.h"
#import "JXHTTPOperationQueueDelegate.h"
#import "TMTumblrAuthenticator.h"
...
Regarding bridging issue, guys form QB answered on it:
so using this http://quickblox.com/developers/IOS-how-to-connect-Quickblox-framework#Additional_steps_for_Swift_using_CocoaPods
we can simple achieve bridging, even without creating framework.
QUESTION: What and where is the pre-compiled header file in an xcode project?
PROBLEM: I need help with xcode.
DISCLAIMER: I know nothing about xcode.
BACKSTORY: I have an app built with appcelerator, which builds an xcode project for me. Now I want to make it Citrix Ready which by this press release should be easy http://www.appcelerator.com/press-releases/citrix/ but < rant > they have no documentation on this, no one at appcelerator seems to care, and they say to use SO for support (which I did and it got me the peer pressure badge, yay!).< /rant >
So, since they suck I'm trying to do it myself directly in xcode and with a question that is acceptable within SO guidelines.
SITUATION: I'm up to step 3 of the steps to do this are listed on the Citrix website: http://docs.citrix.com/en-us/mdx-toolkit/10/xmob-mdx-dev-guide-overview/xmob-mdx-dev-ios-apps.html#par_anchortitle_33e5
Step 3: Revise a line of code in the pre-compiled header file in the app project to import WorxEnable.h from Worx.framework as shown in the following example
#ifdef__OBJC__
_
//import MDX extensions
#import <AVFoundation/AVFoundation.h>
#import <SystemConfiguration/SCNetworkReachability.h>
#import <Worx/WorxEnable.h>
#endif
I just don't know what or where the pre-compiled header file is.
Any help would be much appreciated.
I look forward to posting questions about steps 4 and 5 asking what those mean and how to do them:
Step 4: Add the following to “other linker flags” if they do not already appear:
Step 5: Add the following frameworks and libraries:
Thanks!
Hum, I think it's the .pch file.
If it not exist in your Xcode project (Xcode does not create automatically this file now), create one like myproject-Prefix.pch (just an example).
And in the build settings, add your file path in Prefix Header
My pch file :
#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <SystemConfiguration/SystemConfiguration.h>
#endif
I have a small prefix header file
#ifndef UP_FOR_IT_PrefixHeader_pch
#define UP_FOR_IT_PrefixHeader_pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
#import "ABConstants.h"
#import "ABCache.h"
#endif
#endif
it can't find Parse.h. I linked it from Link binary with libraries everything seems right but whatever I tried it does't compile. I tried removing the lib and import again but nothing changed. Removed indexes on derived data but still no clue.
What should I try? It took 2 hours and still not working.
Xcode 6. IOS 8
Goto Build Settings > Apple LLVM 6.0 - Language > Prefix Header
Add here: $(SRCROOT)/PrefixHeader.pch
If $(SRCROOT) not working for you, set the value of 'Prefix Header' to your PCH file name, with the project name - i.e. for project named 'Test-Project' and PCH file named 'Test-Project-Prefix.pch' and add the complete string 'Test-Project/Test-Project-Prefix.pch'
Select your project (named "Project" for example) and click on "ProjectTests" (in TARGETS section).
Then, go to Build Phases > Link Binary With Libraries and add Parse.framework
Just in case rest of the answers doesn't work for someone. Try changing Under "Target Membership", the scope of your targets from public to project. Hopefully it helps.
If you are using cocoapods, you may checkout this link.
I got this problem but none of the solution above worked for me.
I'm using cocoapods, the reason is that in the Podfile I only linked pods to default target. If you are going to add another one, you should add another target configuration in Podfile(target:'target' do). Usually the new one is the same to the original one, you could use link_with to make life easier.
But life is not always that easy. It looks like that link_with is deprecated. You may checkout this link.
I have a workspace and I'm trying to add Core Data to it. I went to the project I want to add Core Data to, selected the Target, hit the + sign under Link Wit Binary Files and added the Core Data framework. That part works fine. I can build and run. When I try the next and using this line:
#import <CoreData/CoreData.h>
I get build errors. These build errors look like:
"ARC Semantic Issue"
Pointer to non-const type 'id' with no explicit ownership
These errors are present in
NSEntityDescription.h
NSManagedObjectModel.h
NSMnagedObject.h
NSManagedObjectContext.h
NSPersistentStore.h
Does anyone know why I'm not able to import Core Data to an existing iOS project? Thanks in advance!
In my framework search paths, I had an erroneous path that correctly built once I removed it:
$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
It should be as simple as adding CoreData.framework to your target:
Click the plus button (+) under Linked Frameworks and Libraries
Then in your Prefix file (Tabs-Prefix.pch in this case) in the #ifdef __OBJC__ declaration:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#impport <CoreData/CoreData.h> //Added core data here
#endif
If this does not work, perhaps you have an older version of Xcode installed and the paths are messed up. It could be trying to import an older framework.
I think this could be related to your entity definitions. Is it possible that you have declared entities that use the attribute name id? That would typically be a NSNumber type in the model subclasses, i.e. *id.
It seems that in this case, the compiler instead of complaining about the *id in the class files, it indicates the id in the header files, which is confusing.
--> Try changing your attribute names.
I had the same problem. It was solved by the following steps:
Remove Reference to CoreData.framework from Frameworks group in Xcode.
Remove CoreData.framework from 'Link Binary with Libraries' in target settings.
Quit Xcode (Cmd + Q).
Open your project folder in Finder and delete CoreData.framework file.
Start Xcode, open your project. Now you may to add the CoreData.framework in 'Link Binary with Libraries'.
Don't forget to add #import <CoreData/CoreData.h> into <projectName>-Prefix.pch located at Supported Files. My prefix header seems like this:
`
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#endif
`
I don't know how existance of any file in project directory can affect to compile errors, but it works for me.
Hope this helps for anyone who reads it.