![]() ![]() You can embed some types of targets, directly into the bundle of an existing app. Provide a name for the target and configure other target-related options, such as the programming language. ![]() You can add as many of these as you want, and indeed you'll want to import all the Objective-C code you want to use in Swift. To add a new target: Choose File > New > Target. If you want to start using your Objective-C code in Swift, you need to add import lines to that bridging header file, like this: #import "YourFile.h" For those unfamiliar with the term, Xcode template is something we use quite often. This will create a new console app with a default c++ main file. ![]() To create an Objective-C bridging header file, all you need to do is drag some Objective-C code into your Swift project – Xcode should prompt you with the message "Would you like to configure an Objective-C bridging header?" Click "Creating Bridging Header" and you'll see a file called YourProjectName-Bridging-Header.h appear in your project.īut that's only half the problem: Xcode has created the bridging header and modified your build settings so that it gets used, but it hasn't actually put anything into it. Create a new project ( Shift + Ctrl + N ), select Visual C++ and Console App. If you want to use Objective-C code in your Swift app – and let's face it, that's going to happen quite a lot! – then you need to create a bridging header that allows your Swift code to work with your Objective-C code. How to create an Objective-C bridging header to use code in Swift
0 Comments
Leave a Reply. |