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 to avoid the error
- 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 to avoid the error
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, select Single View App in iOS (other types of iOS applications are also acceptable), and click Next. (figure 2)
Figure 2. Select the iOS application.
Next, specify the following value on the screen specified in the project information. (figure 3)
- If the Organization Identifier field is blank, specify an appropriate name that is not duplicated by any other organization in the world.
- If the Organization Name field is blank, specify an appropriate value for this as well.
- Specify xctrunner in the Product Name field.
- For the Team field, 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, a 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. Switch devices.
On this screen, the Team field is specified for the Signing section, 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 field on the test edit screen (figure 7).
In case of Xcode10 or earlier, specify <Organization Identifier value created in Xcode>.xctrunner.
Figure 7. Specify the WDA bundle ID (in case of Xcode11 onwards).
Finally, restart the iOS real device. (figure 8)
Figure 8. Restart 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 section, 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 Application > Utilities, right-click login and select Lock Keychain "login" (figure 10). Then, select Unlock Keychain "login" and enter the password to return to an unlocked state.
The user name or passphrase you entered is not correct.
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.
(...)
Testing failed:
WebDriverAgentRunner:
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
- Go to Settings > Locations > Command Line Tools, select the version of Xcode that you unzipped in step 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. Change 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 belong to the team for the team ID, and have the appropriate role as described here.
If there is no particular problem, log in to iOS “Certificates, Identifiers & Profiles” page in the Apple developer program, and check the following points.
First, check that the certificate is registered in the Certificates field. (figure 13)
Figure 13. Certificates setup.
Next, check that the ID in the App IDs field matches “<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 field. (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 the settings to avoid the error, 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 the settings to avoid the error. In case there is not a “provisioning profile” with a newer correction date in the folder, the creation will not work properly, and the settings to avoid the error 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 MagicPod bug investigation
- The following Xcode setup information image will appear when you create an Xcode dummy project