I try to integrate Swift code in my app.My app is written in Objective-C and I added a Swift class. I\'ve done everything described he
I spent about 4 hours trying to enable Swift in my Xcode Objective-C based project. My myproject-Swift.h file was created successfully, but my Xcode didn't see my Swift-classes. So, I decided to create a new Xcode Objc-based project and finally, I found the right answer! Hope this post will help someone :-)
*.swift file (in Xcode) or add it by using Finder.Objective-C bridging header when Xcode asks you about that.Implement your Swift class:
import Foundation
// use @objc or @objcMembers annotation if necessary
class Foo {
//..
}
Open Build Settings and check these parameters:
YES
Copy & Paste parameter name in a search bar
myproject
Make sure that your Product Module Name doesn't contain any special characters
YES
Once you've added
*.swiftfile to the project this property will appear in Build Settings
myproject-Swift.h
This header is auto-generated by Xcode
$(SRCROOT)/myproject-Bridging-Header.hImport Swift interface header in your *.m file.
#import "myproject-Swift.h"
Don't pay attention to errors and warnings.