Error "dyld: Library not loaded: @rpath/XCTest.framework/XCTest" displays When deploying WebDriverAgent into real device

@derunewige

I was stuck for 5 months, unable to run tests on real iOS devices. I wish I could point you to one exact configuration or error that was causing this framework/XCTest issue (and many other issues), but I cannot. What I ended up doing is wiping my whole machine and starting the setup process from scratch. It was a gamble because I really didn’t know what I was going to do if that didn’t work, but it did.

While in the process of setting up my environment, I took very detailed notes of exactly what I did, in order. I’ll share this with you. There are some very basic steps in here (i.e. install Chrome, etc.) but I wanted a record of exactly what I did in case I had problems again:

  1. Install Chrome / Firefox
  2. Install Xcode
  3. Install Xcode command line tools (xcode-select --install)
  4. Install Homebrew (ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)")
  5. Install Appium GUI // **NOTE: This is obsolete; install Appium Desktop instead
  6. Install JDK (JDK 8 Update 121) // **NOTE: Not sure what the current version is, but this was most recent at the time
  7. Install Eclipse (Eclipse IDE for Java Developers) NOTE: I recently switched to Intelli-J. Personal preference.
  8. Install git (brew install git)
  1. Install node with brew (brew install node) //** NOTE: I initially installed nodejs from https://nodejs.org/en/, but I later read that it shouls be installed via brew. If you installed from the site and need to uninstall and reinstall with brew, instructions are here
  2. Add export PATH="/usr/local/bin:$PATH" to bash_profile
  3. Run sudo npm install npm -g to make sure that I got the most recent version of npm
  4. Install Appium (npm install -g [email protected])
  5. Install TestNG in Eclipse (Help -> Eclipse Marketplace)
  6. Install ideviceinstaller (brew install --HEAD ideviceinstaller)
  7. Install appium doctor (npm install appium-doctor -g)
  8. Install Carthage (brew install carthage)

At this point, you should be able to run tests on the Simulator

  1. Install ios-deploy (brew install ios-deploy)
  2. Install appium-xcuitest-driver (npm install -g appium-xcuitest-driver)
  3. Install deviceconsole (npm install -g deviceconsole)
  4. Navigate to /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent and run the following:
    mkdir -p Resources/WebDriverAgent.bundle
    ./Scripts/bootstrap.sh -d
  5. Follow the steps in this video: https://www.youtube.com/watch?v=Yi177Si5aLU (You will have completed some of the steps in this video already, but the main takeaway is the Xcode part - getting rid of errors in WebDriverAgent.xcodeproj, code signing, etc.)
  6. In the WebDriverAgent folder, run bash Scripts/bootstrap.sh -d
  7. Make sure app and developer account are trusted on device (Settings -> General -> Profiles & Device Management)

At this point, you should be able to run tests on real iOS devices

I had an awful time with this and maybe there’s a better way to do it, but this is what finally got me up and running. I wish I knew what was causing this framework/XCTest problem but I never figured it out. Best of luck to you, and if it doesn’t work I’d be happy to help you troubleshoot.

2 Likes