When testing using iOS real devices, the error message “Error: Unable to launch WebDriverAgent because of xcodebuild failure: ‘xcodebuild failed with code 65’” may appear when connecting to the device or running the test. Currently, if this type of error occurs, the necessary settings are automatically carried out by creating a dummy project in Xcode as follows.
This is an Appium and Xcode issue, as described here on this page.
Table of Contents
- Settings for the avoidance of errors
- If a password-related error occurs
- When using a combination of older devices from Xcode 10 onwards and older than iOS 12
- If it still does not work correctly
1. Settings for the avoidance of errors
First, connect the iOS real device used for running the test to the Mac PC using a USB cable.
Next, open “Xcode” from the list of Mac applications. (Figure 1)
In case multiple versions of Xcode are installed on the PC, open the same version of Xcode that you are using for the test.
Figure 1 Xcode
After launching, select “File” > “New” > “Project” from the menu at the top of the screen, and select the iOS “Single View App” (other types of iOS applications are also acceptable), and click “Next”. (Figure 2)
Figure 2 Selecting the iOS application
Next, specify the following value on the screen specified in the project information. (Figure 3)
- If the “Organization Identifier” is blank, specify an appropriate name that is not duplicated by any other organization in the world.
- If the “Organization Name” is blank, specify an appropriate value for this as well.
- Specify “xctrunner” as the “Product Name”.
- For the “Team” item, select the Apple ID Team corresponding to the “Team ID” used in this real device test.
If there are multiple Team options and you are not sure which to use, you can confirm the correspondence between the Apple ID and Team from “Apple IDs” in “Xcode”>”Preferences”>”Accounts” on the Xcode upper menu.
Figure 3 Project Setup
If you then select “Next”, and then “Create” from the next screen, the Project shall be created.
When the created Project information screen is displayed, change the device display at the top-left of the screen to the iOS real device currently connected by USB cable. (Figure 4)
Figure 4 Switching devices
On this screen, the “Team” is specified for the “Signing” session, as shown in Figure 5, and as long as no errors occur, setup is complete.
Figure 5 If Signing setup is successful
If an error occurs, as shown in Figure 6, connect to the iOS real device using the USB cable, and click the “Register Device” button to resolve the error.
Figure 6 In case an error occurs with Signing setup
When running the iOS real device test, from Xcode11 onwards, you specify the <Organization Identifier value created in Xcode> for the “WDA bundle ID” on the test Edit screen (Figure 7).
In case of Xcode10 or earlier, specify <Organization Identifier value created in Xcode>.xctrunner.
Figure 7 Specifying the WDA bundle ID (in case of Xcode11 onwards)
Finally, restart the iOS real device. (Figure 8)
Figure 8 Restarting the iOS real device
The error should stop occurring if you connect to the device and run the test in this state.
2. If a password-related error occurs
If the password is not successfully input in the codesign password authentication dialog box (Figure 11), despite entering your password multiple times, and you get the error message “The user name or passphrase you entered is not correct” at the Xcode signing session, resolve the issue by taking the following steps.
The cause of the error is thought to be a bug within Xcode.
- In “Keychain access” (Figure 9), which can be launched from the “Application” > “Utilities” folder, right-click the “Login” item and select ”Lock keychain ‘Login’”(Figure 10). Then, select “Unlock keychain ‘Login’” and enter the password to return to an unlocked state.
Figure 9 Keychain access
Figure 10 Lock keychain “Login”
- At the password authentication dialog box in Figure 11, select “Always allow”, rather than “Allow”, after entering your password.
Figure 11 codesign password dialog box
After running the above, reconfigure the settings to avoid the error. If you still receive an error, try locking and unlocking the keychain “Login” again.
Even if you click “Reject” at the password authentication dialog box, by carrying out keychain “Login” lock and unlock again, the dialog box shall be displayed again.
3. When using a combination of older devices from Xcode 10 onwards and iOS 12 or older versions
In case the connection does not work properly, by following these steps and setting the MagicPodDesktop Log Level to “MagicPod Bug Investigation”, the following message can be displayed.
WebDriverAgentRunner-Runner.app (217) encountered an error (Failed to load the test bundle. (Underlying error: bundle “WebDriverAgentRunner” is malfunctioning or is unable to load a required resource. . The bundle is broken or a required resource is unavailable. . dlopen_preflight(/var/containers/Bundle/Application/A2B6B2E8-87C0-4BF9-A13B-48F1FBE0CD86/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner): Library not loaded: /System/Library/Frameworks/CoreServices.framework/CoreServices
In this case, you can resolve the issue using the following steps.
- Download Xcode 9.* here, unzip it and move it to an appropriate folder.
- Launch the version of Xcode that you are currently using
- From “Preference” -> “Locations” > “Command Line Tools”, select the version of Xcode that you unzipped in 1. (Figure 12)
- Note that, if you move the location of the selected Xcode after making the selection, it will not function properly.
Figure 12 Changing Command Line Tools in Xcode
Note that when connecting to devices with iOS 12 onwards, it is necessary to return to the original Command Line Tools selection every time.
4. If it still does not work properly
First, confirm the following points.
- Does the Team use when performing the setup work described above correspond to the Team ID specified for the iOS real device test?
- When performing the Xcode setup work described above, is the device displayed in the top-left of the Project screen the device connected to the PC by the USB cable? Further, does the message “OS Version lower than deployment target” appear in the device display? If it does, then after setting the Deployment Target to an appropriate value from this page, click the button on the top-left of the Xcode screen, to display the message “Build Succeeded.”
- When installing multiple versions of Xcode on the PC, is the Xcode version you have set up the same version used for the test?
- Have you launched the iOS simulator? If so, exit the simulator.
- Is the program ID of the Apple developer you are using to log in to Xcode a charged ID? We do not recommend using the free version.
- The Apple Developer Program ID logged in on Xcode must have the appropriate role as described here.
If there is no particular problem, log in to the Apple developer program iOS “Certificates, Identifiers & Profiles” page, and check the following points.
First, check that the Certificate is registered in the Certificates item. (Figure 13)
Figure 13 Certificates setup
Next, check that the ID in the “App IDs” item matches the “<Organization Identifier value created in Xcode>.xctrunner” (Figure 14). “*” is a pattern that matches an arbitrary character string.
Figure 14 App IDs setup
Finally, confirm that the device to be used for the test is registered in the “Devices” item. (Figure 15)
Figure 15 Devices setup
If the Xcode setup completes normally, the three items of information described above should be automatically generated. If they are not generated correctly, either redo the Xcode setup or create/edit the information directly from the Apple developer program screen (when directly creating or editing, it is better to redo setup to avoid errors, just in case).
If it still doesn’t work, the problem may be resolved by doing the following.
- Relaunch Xcode after deleting the “provisioning profile” under /Users/username/Library/MobileDevice/Provisioning Profiles (unless you relaunch, the deletion of the Xcode is not recognized). Redo setup to avoid errors. In case there is not a “provisioning profile” with a newer correction date in the folder, the creation will not work properly, and the setup to avoid errors will not complete normally either.
- After tapping “Developer” > “Clear Trusted Computers” in the iOS real device setup app, remove the USB cable once and reconnect. A message asking you to confirm whether you trust the computer will appear, so tap “Trust”.
If it still does not work correctly, although the probability is low, the problem may be resolved by carrying out the following steps.
- Delete the “WebDriverAgent-***” directory under /Users/Username/Library/Developer/Xcode/DerivedData.
- Confirm that there is no process with the name iproxy running using Activity Monitor on the Mac, and terminate all such processes if they are running.
- If the app WebDriverAgentRunner is installed on the iOS real device, you should uninstall this.
- Try the steps to reacquire the Apple ID and certificate for Xcode as described on the Xcode "Please enter your keychain login password"
If it still does not work correctly, please send an inquiry to support along with the following information.
- Console and Appium Console text when you try to connect but fail with the log level set to “Expert”
- The following Xcode setup information image will appear when you create an Xcode dummy project