Extremely new to Swift and Objective C. My manager has tasked me with reposting an outdated app back onto the app store. It was removed due to some Apple updates and our app didn’t meet the new qualifications. But I’ve been having issues just trying to compile the project. So I by first updating the project by running updates on its old software like XCode. But now I’m stuck at this issue of the AppDelegate Swift functions can’t be seen in the objective C code. However, when I right-click and go to definition, it has has no problem finding them. This is one example.
3
Answers
You need to add
@objc
as prefix for variables or functions which you would like to access from Swift file to Objective C or mark class as@objcMembers
if you want to access everything from swift file to Objective cmake sure you have created a bridging header file. Here is helper link
You need to import that bridging header in your Objective C file.
If you have do all three steps as mentioned, you will be able to access that function.
In your code you are accessing instance methods as class methods
Error itself saying that
Follow below steps
Now you can access method as
Else
Finally you need to know difference between Class & Instance Methods
FYI :
Also if you want to use Swift Files in Objective-C Files or mix of it, you need to have BridgeHeader File
Follow answer suggested by @Pushkraj Lanjekar
Hope it helps.
The AppDelegate is a Swift file and you need to import it to an Objective-C file. Check the Apple’s guide importing swift into Objective-C, you need to:
Import the genareted Swift header to the SettingsViewController.m
#import "ThinkNotes-Swift.h"
If the module name is not ThinkNotes then replace that with your projects module name.