Connect Objective-C Framework to Swift iOS 8 App (Parse Framework)

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".

  1. Click on your project Workspace
  2. Select your project Target
  3. In the General tab, remove the Framework from "Linked Frameworks and Libraries"
  4. Add it to "Embedded Binaries"
  5. 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



Leave a reply



Submit