Use of unresolved identifier 'TestFairy' error in Xcode 9 when using TestFairy.begin()

405 views Asked by At

After following all of the necessary steps on the TestFairy website to integrate the TestFairy SDK into iOS, I've run into a problem. I dragged the files into my project, I've checked "Copy files if needed", I've created the Bridging Header required to import TestFairy.

The app compiles and runs on the simulator but the error occurs when I try to archive the application.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Check if the user isn't logged in, make the login screen the launcher
    if !userDefaultExists(forKey: "username") {
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let initialViewController = storyboard.instantiateViewController(withIdentifier: "LoginView")
        self.window?.rootViewController = initialViewController
        self.window?.makeKeyAndVisible()
    }

    TestFairy.begin(appToken)

    return true
}

The error message is "Use of unresolved identifier 'TestFairy'".

3

There are 3 answers

3
Rakesh Patel On

This error occurs because of your bundle could not find your file so please select TestFairy.m file and check its target. Its target is selected for your project. If not then check it and select. then run again.

check below image--> Right side target is selected

enter image description here

1
Vijay Sharma On

Disclaimer: I work at TestFairy

These sort of problems are most often related to a problem with your project settings. While copying the TestFairy library into your project, you may have added to it to a path that is not searched for during archiving. Cocoapods would indeed make sure that you would not have this sort of problem, however, if you ever wanted to revert back to dragging the library into your project, feel free to reach out to us at [email protected]

0
Keenan Cookson On

I managed to find a workaround for the problem I faced. I installed TestFairy using Cocoapods instead of using the recommended TestFairy SDK integration technique (Drag and Drop).