How can I import firefox-ios to my obj-C project - ios

I wonder how can I import https://github.com/mozilla/firefox-ios to my existing Obj-C project. While it does not a framework, I could not import sources of it in my Obj-C project files when I added the project into workspace. I tried to convert it to a static library, but I could not figured it out. I have a little bit experience on Swift and this creating static library thing. Actually, I am not sure this is the right way to do.
Thanks

You should check the Apples documentation about using Swift in Objective-c.(The Importing Swift into Objective-C part)
You can add a Swift-module header and import your .swift files and use them in your objective-c code.

Related

Can't import CommonCrypto in mixed language framework

I'm building a mixed language framework. I mainly have Swift files, and a few Objective-C ones.
One of the Objective-C files is a crypto class that uses CommonCrypto.
It seems that I can't import it for some reason, even though that I can import it in a Objective-C framework.
Can someone explain to me why that is?
All the other solutions that I found talk about how to use CommonCrypto in Swift when I need to use it in Objective-C in a Swift framework.
P.S:
I tried adding the import in the umbrella header file like so:
#import <CommonCrypto/CommonCrypto.h>
the error: Include of non-modular header inside framework module 'name of header'
This answer did not fix the problem: answer
I've encountered this very problem myself. Here's how you resolve it:
Create a module map file (here's my file).
Copy the latest CommonCrypto.h header.
Create a directory CommonCrypto for both these files.
Copy the directory (via drag-and-drop) to your project.
Add the directory path under SWIFT_INCLUDE_PATHS for your target framework.
This should allow you to use import CommonCrypto wherever you want (for Swift, not Objective-C).
Edit: Seems like I misread the question initially. You want to use CommonCrypto in Objective-C and then use that from Swift. Here's some advice: don't #import CommonCrypto in your public headers, but rather just internally. Wrap all your crypto-structures so that there's no public dependency for CommonCrypto whatsoever, and then just use it from Swift via the default bridging procedure.

How to use an Obj-c Library/Custom interface in a Swift Project

Trying to understand how I can use this in my swift project.
https://github.com/Grouper/FlatUIKit
I have copied the classes folder into my project but am not sure how to use the various .h and .m files. How would I go about using these files within my storyboard to use the custom appearances?
Did some searching and wasn't really able to understand the various threads that I found.
A bit of a broad question so I'll try to provide some basics and hopefully that helps.
If you are unaware, there is a whole book written by Apple about how to use objective-c with swift. it's available on iBooks for free Using Swift with Cocoa and Objective-C (Swift 2.1) by Apple Inc
Here is the online link
You will need to create an objective-c bridging header and import your code through the header.
Your bridging header would look like this:
#import "XYZCustomCell.h"
#import "XYZCustomView.h"
#import "XYZCustomViewController.h"
If they don't have any modules then you can use them in your swift code and it should see them. According to Apple:
Use your custom Objective-C code with the same Swift syntax you use with system classes.
let myCell = XYZCustomCell()
myCell.subtitle = "A custom cell"
If you are importing an Objective-c framework then it should already contain and umbrella header file that takes care of the bridging header stuff for you. then you just import the framework name into the class that you are planning on using.
import MyCustomFramework
Link to the apple docs here
For this, you can use a bridging header, which is used to expose Objective C code to swift. To do this, make a new header file in your project. Import the header files you would like to use in the new header file like this:
#import <FlatUIKit/FlatUIKit.h>
And then, in the build settings of your project, define the Objective-C bridging header to be the header file you just created. Now in any swift files that you would like to use the library in just import the classes like this:
import FlatUIKit
Hope this helps!

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 6 Playground using Parse framework?

I would like to use Parse SDK/Framework my playground file but I get an error if I import it. I can import the iOS frameworks like UIKit
I know there are similar posts to this (How to I import 3rd party frameworks into Xcode Playground?)
but i could not make it work for my project.
Any help here is very very much appreciated... I am not a complete newbie but am not an expert So as many details (almost for dummies ;-)) as you can please...Many thanks.
To get Parse working in playground you will need to create an Xcode project and include the Parse framework. Then within that project you can add a playground and import frameworks and code written in that project. Hope this helps.
If you are curious I did it for a framework I created and created a Playground inside the projects workspace. In that I import Dollar which is a custom framework but I guess you could import Parse and it should work https://github.com/ankurp/Dollar.swift

Add MFSideMenu 3rd party library to swift project

I'm currently translating an Objective-C project I have over to Swift. In the process, I have a few implemented 3rd party libraries that are pure Objective-C like MFSideMenu and Parse.
I've created a Bridging-Header.h file per Apple's documentation and other's recommendations to bridge the Objective-C files with the Swift code. This works fine for frameworks like Parse. Unfortunately, when importing MFSideMenu and running the application, I receive the attached errors below.
I was contemplating if this was because a library needed to be manually imported into the Objective-C files using it, so I attempted importing UIKit and Foundation in the project and manually added the frameworks without any success. Any assistance would be greatly appreciated.
Turns out, the compiler for swift no longer supports non modular based imports for frameworks. You must change all references to frameworks to #import statements rather #import.
I had the same problem, add code below at the header file of this class
#import <UIKit/UIKit.h>
it can help you

Resources