Automated testing on real IOS device fails because Appium inspector can't connect to the device. (Xcodebuild failed with code 65 & 66)

I have a problem with I was not able to get rid of for the past days.

My goal is to start an automated test, for an app that is already downloaded on the device, from my Mac on my iPhone.

I started with installing: Node.js Java JDK & JAVA_HOME variable Appium & Appium inspector xCode & xCode Command lines tools Appium driver (xcuitest & UIAutomation)

In the next step in entered my Desired Capabilities in the Appium inspector: platformName : ios appium:platformVersion : 16.1 appium:deviceName: iPhone 11 pro appium:bundleId : appium:automationName : XCUITest appium:udid: <udid from my devic appium:xCodeOrgId : appium:xCodeSigningId : iPhone Developer

After entering these information I moved on and opened the WebDriverAgent.xcodeproj and signed in with my free Developer Account (Apple ID) and assigned a Team to WebDriverAgentLib, WebDriverAgentRunner, all Integrationtests and the IntegrationApp. The Firestone worked but the last three failed with the Error:

Failed to create provisioning Profile. The app ID “com.facebook.WebDriverAgentRuner” can not be registered to your development team. Change your bunde identifier to a unique String to try again.

and

No profiles for ‘com.facebook.WebDriverAgentRunner’ were found. Xcode couldn’t find any iOS App Development provisioning profiles matching ‘com.facebook.WebDriverAgentRunner’.

After reviewing the Problem I came up with following a few tutorials without any luck. I tried to create a profiling Profile, but most ways I found were with the free version or just wouldn’t work. So i changed the bundle identifiers, even though it’s not a beautiful solution and was able to trust the computer and install an app with xCode.

But when I try to start a session with Appium inspector after I started the Appium server in Visual Studio Code it still fails with the Error:

In Appium inspector: Error Failed to create session. An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65 xcodebuild error message: . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.

In Visual Studio Code:

[debug] [XCUITestDriver@f4dc (e98a8edb)] Matched '/status' to command name 'getStatus'
[debug] [XCUITestDriver@f4dc (e98a8edb)] Proxying [GET /status] to [GET        http://127.0.0.1:8100/status] with no body
[debug] [iProxy@00008030:8100] Connection was refused to port 8100
[XCUITestDriver@f4dc (e98a8edb)] socket hang up
[Xcode] xcodebuild exited with code '65' and signal 'null'
[debug] [XCUITestDriver@f4dc (e98a8edb)] Event 'wdaStartFailed' logged at 1674136358245 (14:52:38 GMT+0100 (Mitteleuropäische Normalzeit))
[debug] [XCUITestDriver@f4dc (e98a8edb)] Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
[debug] [XCUITestDriver@f4dc (e98a8edb)] xcodebuild error message:
[debug] [XCUITestDriver@f4dc (e98a8edb)] . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITestDriver@f4dc (e98a8edb)] Quitting and uninstalling WebDriverAgent
[XCUITestDriver@f4dc (e98a8edb)] Shutting down sub-processes
[debug] [WebDriverAgent] Successfully reset '/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj/project.pbxproj' with bundle id 'com.facebook.WebDriverAgentRunner'
[debug] [XCUITestDriver@f4dc (e98a8edb)] No WDAs on the device.
[XCUITestDriver@f4dc (e98a8edb)] {}
[DevCon Factory] Releasing connections for 00008030-0005298C0C45802E device on any port number
[DevCon Factory] Found cached connections to release: ["00008030-0005298C0C45802E:8100"]
[DevCon Factory] Releasing the listener for '00008030-0005298C0C45802E:8100'
[debug] [iProxy@00008030:8100] Closing the connection
[debug] [DevCon Factory] Cached connections count: 0
[debug] [XCUITestDriver@f4dc (e98a8edb)] Not clearing log files. U`clearSystemFiles` capability to turn on.
[iProxy@00008030:8100] The connection has been closed
[debug] [AppiumDriver@567d] Event 'newSessionStarted' logged at 1674136358629 (14:52:38 GMT+0100 (Mitteleuropäische Normalzeit))
[debug] [AppiumDriver@567d] Encountered internal error running command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
[debug] [AppiumDriver@567d] xcodebuild error message:
[debug] [AppiumDriver@567d] . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[debug] [AppiumDriver@567d]     at quitAndUninstall (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:584:15)
[debug] [AppiumDriver@567d]     at /Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:619:11
[debug] [AppiumDriver@567d]     at wrapped (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:95:13)
[debug] [AppiumDriver@567d]     at retry (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:68:13)
[debug] [AppiumDriver@567d]     at retryInterval (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:105:10)
[debug] [AppiumDriver@567d]     at /Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:599:7
[HTTP] <-- POST /session 500 14443 ms - 1398
[HTTP] 

After this try I even tried to add the bootstrapPath as a desired Capability and the agentPath as a desired Capability, with no luck.
But the error changed a little:

Failed to create session. An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 66 xcodebuild error message: . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.

Is there something I’m doing wrong, or is there better way to do automated testing on real iOS devices? I would be very happy if you could help me out.

kind regards, henry