I'm getting a file not found error when I try to #import "DodgeHeroReal-Swift.h. My Product Module name is set to DodgeHeroReal and Defines Modules is also set to YES (both at target level and project level for both build settings). I already have a Bridging header that was generated by Xcode. I have a swift class emojisClass that I want to be able to use in my Objective-C ViewController EmojiShopViewController.
I've looked at the many wonderful StackOverflow posts regarding mixed objc and swift projects, yet none of the solutions proposed seem to work. I've looked at the Apple Documentation page too but that doesn't help either. Can someone walk me through how I can use the following swift class in my ViewController.m?
Here is GlobalFunc.swift (which has the class emojisClass)
@objc(EmojiClass) class emojisClass {
@objc(buyAngle) func buyAngle(){
if(emotiBucks >= 10000){
var value = emotiBucks-10000
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "haveAngleEmoji")
NSUserDefaults.standardUserDefaults().setInteger(value, forKey: "emotiBucks")
NSUserDefaults.standardUserDefaults().synchronize()
}
}
func buyAlien(){
if(emotiBucks >= 2000){
var value = emotiBucks-2000
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "haveAlienEmoji")
NSUserDefaults.standardUserDefaults().setInteger(value, forKey: "emotiBucks")
NSUserDefaults.standardUserDefaults().synchronize()
}
}
func buySassy(){
if(emotiBucks >= 5000){
var value = emotiBucks-5000
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "haveSassyEmoji")
NSUserDefaults.standardUserDefaults().setInteger(value, forKey: "emotiBucks")
NSUserDefaults.standardUserDefaults().synchronize()
}
}
func buyHeart(){
if(emotiBucks >= 3000){
var value = emotiBucks-3000
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "haveHeartEmoji")
NSUserDefaults.standardUserDefaults().setInteger(value, forKey: "emotiBucks")
NSUserDefaults.standardUserDefaults().synchronize()
}
}
}
I've imported the bridging header in my EmojiShopviewController.m: #import "Dodge Hero-Bridging-Header.h". Now I want to be able to call the function buyAngle() that's declared in my swift file.
EDIT: The project was originally a swift project, then I added Obj-C files, then the Bridging-Header. So the project contains .swift and objc files, and now I want to be able to generate the ProductModule-Swift.h without deleting any of my current files.
EDIT 2: running find * -iname '*Swift.h' and then a CMD+F in Terminal in my DerivedData directory returns this:
****** Other stuff ********
DodgeHeroReal-gmmvxsfrydixythkdwqjpncbqlpl/Build/Intermediates/DodgeHeroReal.build/Debug-iphonesimulator/DodgeHeroRealTests.build/DerivedSources/DodgeHeroReal-Swift.h
DodgeHeroReal-gmmvxsfrydixythkdwqjpncbqlpl/Build/Intermediates/DodgeHeroReal.build/Debug-iphonesimulator/DodgeHeroRealTests.build/DerivedSources/DodgeHeroRealTests-Swift.h
DodgeHeroReal-gmmvxsfrydixythkdwqjpncbqlpl/Build/Intermediates/DodgeHeroReal.build/Debug-iphonesimulator/DodgeHeroRealTests.build/Objects-normal/x86_64/DodgeHeroReal-Swift.h
****** More other stuff ********