Swift Bridging Header and Obj-C Class Visibility

I applied the bridge title specified in the assembly settings to the full path to it, automatically creating the title. After that, I included obj-c header files in it. But every attempt to call the constructor of the object is not performed: "Using an undeclared identifier." enter image description here

List of things I did:

  • Generated .m and Xcode file proposed to create bridge header
  • Added obj-c files to create and import in the header
  • In the build setup, a FULL path is provided for linking the header file

enter image description here

  1. Used Obj-C type in code ... But it is not built.
  2. Then I provided not the full path to the title, but the path from the folder in which the project is located - there is no result.

I double-checked all the steps in accordance with the documentation for the apple, but there was no result. What for? Any help would be appreciated.

+6
ios objective-c swift xcode6
source share
2 answers

Follow these steps:

  • Create a Swift Project
  • Add a test class as Cocoa Class instead of .m and .h separately. Xcode prompts you to add a bridge title.
  • Import the title of the test class into the title of the title you already made. Swift should not have instances of a test class.
  • Copy BL_KeyChainWrapper.m and .h to the project directory in finder.
  • Drag the BL_KeyChainWrapper files into the project and make sure that Add to targets .
  • Import the BL_KeyChainWrapper header into the header header.
  • Create an instance of the BL_KeyChainWrapper class in Swift.

If you follow the steps above and there is still an error. You probably did not declare a class named BL_KeyChainWrapper in BL_KeyChainWrapper.h. Make sure you have the following code in your BL_KeyChainWrapper.h:

@interface BL_KeyChainWrapper : BaseClass 
+2
source share

Well, after creating a test project with a header bridge, I found out the following:

  • I added a .m file, Xcode suggested I create a bridge header.

  • I added the .h file, called it a class, and created the Obj-C class this way.

and

In the build settings, the code generation section is as follows:

enter image description here

The bridge file located in the following path:

ProjName / BridgHeader.h

At the same level as the .xcodeproj file exists.

BUT:

When I added the already created Obj-C class to create the project and added the header import to the header header, I could not use it:

enter image description here

So, I think Xcode 6 beta 2 cannot add existing files to a fast project. Has anyone encountered this problem? Reason: I do not want to embed all existing libraries that I have been developing for 5 years for the created files.

PS:

Header Title:

enter image description here

0
source share

All Articles