First, you should create an Objective-C project.
After project be created. We have some parameters should be set in Build Settings.
New or add exist Swift file into the project. Then Xcode pop-ups a dialog, follows image. We just click “Create Bridging Header” to automatically crate bridging header. After that, we can see the bridging header file which be names your product name followed by adding "-Bridging-Header.h".
Finally, we need to import “MixDemo-Swift.h” to any Object-C .m. That header is created by Xcode, but you cannot see in the project folder. The file names your Product Module Name, which we mentioned above, followed by add “-Swift.h”. You can also search "Objective-C Generated Interface Header Name" under Build Settings.
#import "MixDemo-Swift.h"
Then, we can use swift object in the Objective-C project directly.
BarcodeScannerViewController *barcodeViewController = [[BarcodeScannerViewController alloc] init]; barcodeViewController.delegate = self; [self presentViewController:barcodeViewController animated:YES completion:nil];
Reference: https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
This post is much helpful for us. This is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
ReplyDeleteios app development course