


(name of project, name of organization, identifier of organization). Run Xcode and create “Simple View Application”. ExamplesĮxample 1: Using С++ source files in a Swift-project. This variant can also be used in Swift, here’s how:ġ) In a Swift project we add source files in С++Ģ) Write a wrapper class for the C++ code in Objective-C++.ģ) Add the header file of the wrapper class to the bridging header file.Ĥ) Use the wrapper class in Swift. The most simple and trivial is to change the file extension to the implementation of the class (from *.m to *.mm) and use Objective C++ as a wrapper for the C++ code (or write the whole project in Objective C++ so that there won’t be a problem with the imported headers file). The Objective C++ solutionīut what can we do if we need to use project code in Swift which was written in C++? In Objective-C there are several ways to use C++ code. But this problem can be worked around with the help of bridging headers we can import Objective-C class headers and they will be available in Swift. Swift is a cool high-level programming language, but it’s still quite young and doesn’t have as many libraries and components as Objective-C.
