How to import framework into XCode project? - ios

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

Related

Cocoa pods objective c files in Swift project. Bridging issue

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.

What is Foobar-umbrella.h for?

Assuming I got a Framework called Foobar. When I try compiling my iOS project I get the compiler warning:
Umbrella header for module 'Foobar' does not include header
'Foobar-umbrella.h'
I don't get what this 'Foobar-umbrella.h' is and why it isn't included. Some details about my project:
An iOS 8 App project mostly written in Swift. A little bit Objective-C
The 'Foobar' framework is a separate project mostly written in Swift which I have included as a subproject to my main project.
It has been included by embedding it in build phases and depending on it. But I am not explicitly linking against it.
I use Cocoapods, but 'Foobar' is not included as a pod.
The umbrella header is the 'master' header file for a framework. Its use is that you can write
#import <UIKit/UIKit.h>
instead of
#import <UIKit/UIViewController.h>
#import <UIKit/UILabel.h>
#import <UIKit/UIButton.h>
#import <UIKit/UIDatePicker.h>
and so on.
For me, <XCTest/XCTestCase+AsynchronousTesting.h> is included in <XCTest/XCTest.h>. Maybe it is not for you? In that case, add the
#import <XCTest/XCTestCase+AsynchronousTesting.h>
manually.

Xcode trying to compile Objective-C libraries as Swift

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.

Swift class in Cocoa Touch Objective-C Framework

I'm trying to build a Cocoa Touch Framwork (XCode 6, obviously) with Objective-C and some Swift classes.
I've successfully added Swift classes to regular projects (no framworks) before so I'm aware of the build settings required for this (Embedded Content Contains Swift Code). Unfortunately, the framework project doesn't build the header file (projectName-Swift.h) and I'm not able to import the class and the Swift classes into any of my .m files.
Does anybody know why this wouldn't work, and what build settings I need to change in order to make this work?
Finally found the answer;
Within the frameworks the import statement for Swift files has to look as follows;
#import <ProjectName/ProjectName-Swift.h>
instead of
#import "ProjectName-Swift.h"
Sometimes it helps to RTFM (https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_82)
I've struggled with this for a while because I don't think the documentation is clear. I have a slightly different project setup, and it's taken me a while to work this out so I thought I'd answer here.
I have a project with name: MyProject
In this project, I have a framework: MyFramwork
I have a swift file in MyFramework which I want to import into an objective c file in MyFramework.
To do this, you need:
#import <MyFramework/MyFramework-Swift.h>
NOT
#import <MyProject/MyFramework-Swift.h>
Hope that helps someone.

xcode cannot compile NSString

xcode will not compile a FRESH project with only libxml2 and its requirements installed. it returns this error every time.
http://puu.sh/bYc7D/b37d7c6e99.png
I do not know how to resolve this, has anyone had this before?
Most of the standard project templates include a prefix header called project_name-Prefix.pch (and a reference to it in build settings, search for 'prefix').
Since most classes use the Foundation library, including Foundation.h in that header is a good idea. Also make sure that Foundation.framework is included under "Build Phases" -> "Link Binary With Libraries".
If your project isn't setup that way, it might be useful to create a new project using the most basic template (like Single View), observe how its setup and do the same things to your project.
Looks like Foundation isn't imported. Do you have anything in your prefix header file?
Regardless, try importing it into your header:
#import <Foundation/Foundation.h>
Or alternatively if you use modules:
#import Foundation;
Import Fondation? I don't see it at the top of the file.

Resources