In your swift classes where you want to access Objective C classes, so you will import the hidden Xcode generated file.
Put the required Objective C header files in the created bridge header file to access these classes in Swift.ģ. When you create your swift file in an Objective C app, you will need to accept click on create bridge file.Ģ. Let us summarize this three-step process:ġ. Look at the Figure 5 given below.įigure 5 – Import the Xcode generated background Swift file into Objective-C classes to create Swift objects in Objective-C In the example I build, my project name is “Guilder” So the Xcode generated file name is “Guilder-swift.h”. The name of that file will be like “NameOfTheProject-swift.h” according to your project name. We will need to import that hidden (Xcode generated background file) Swift file into Objective C classes to create Swift objects in Objective C. To solve this issue, we will need the background file generated by Xcode when created the swift file in step 1. The bridge file allows Objective C classes to be imported swift classes but does not allow Swift class objects to be created in Objective C classes. Step 3: Import Xcode generated background Swift file to allow Swift objects in Objective-C At this stage, we can create objects of Objective C classes in Swift, however, if we try to create Swift classes objects in Objective C classes it will show an error. This bridge header file allows us to create Objective C objects in Swift classes.
Figure 4 – Import the Header Files of Object-C in Bridging Header