Connect Objective-C framework to Swift iOS 8 app (Parse framework)
A "Fool Proof" way of adding a bridging header is as follows:
If you have a Swift project, add a new Objective-C File to your project and Xcode will prompt if you want to configure your project with a bridging header. Press yes.
If you have a Objective-C project, add a new Swift File to it and you will get the same prompt. Press yes.
After you get the bridging header, you can delete the file you just added if you want to.
Objective C framework for swift app, error: Argument passed to call that takes no arguments
This syntax:
MyApi.init(launchOptions)
calls the initialiser of MyApi
. Note that init
is a keyword in Swift and has special meaning! Since MyApi
inherits from NSObject
, it inherits the parameterless initialiser, which is what the Swift compiler thinks that you are trying to call. This is the same as:
MyApi(launchOptions)
However, your init
method in Objective-C is not an initialiser for a MyApi
object, is it? It's just a regular class method called init
. To call it in Swift, you have to escape the special meaning of the init
keyword by adding backticks around it:
MyApi.`init`(launchOptions)
The backticks are quite astonishing, so I'd suggest that you rename init
to something else, like setup
.
How to link a stand-alone Swift OS X app to a private framework (also created in Swift)?
I may be wrong but is seems like a case of "Linked Frameworks and Libraries" vs "Embedded Binaries".
- Click on your project Workspace
- Select your project Target
- In the General tab, remove the Framework from "Linked Frameworks and Libraries"
- Add it to "Embedded Binaries"
- Build
It will be automatically added to the "Linked Frameworks and Libraries" also but you'll have it once instead of two times.
No Such Module 'Ensembles' Error - importing objective-c framework to use in swift project
When creating a bridging header you do not need to use import.
However I don't think you may be adding a bridging header correctly, go to, file, new, file, add a objective-C file and a dialog should pop up asking if you want to create a bridging header. Add both files but delete the objective-C file and keep the bridging header.
Then import the ensembles framework to the bridging header like so.
#import
When creating a bridging file successfully you should not need to import the framework in your swift files and it should be available throughout your project. See this post for more information - Connect Objective C framework to Swift iOS 8 app (Parse framework)
Related Topics
Why Do We Use Use_Frameworks! in Cocoapods
Exhaustive Condition of Switch Case in Swift
iOS Memory Allocation - How Much Memory Can Be Used in an Application
How to Add Unique Constraints for Some Fields in Core Data
How to Detect When Keyboard Is Shown and Hidden
Uitableview - Change Section Header Color
Uialertview First Deprecated iOS 9
Why Is Main Window of Type Double Optional
Kcfstreamerrordomainssl, -9802 When Connecting to a Server by Ip Address Through Https in iOS 9
Callback Method If User Declines Push Notification Prompt
How to Make an Uipickerview Component Wrap Around
What Is "Self" Used for in Swift
How to Set the Title of a Uibutton as Left-Aligned
Presentviewcontroller:Animated:Yes View Will Not Appear Until User Taps Again