Error while executing appium script in java on ios device

I’m seeing the exact same issue. My Appium tests are written in a way that they start the server programatically. It works as expected on the simulator - no issues at all. On the real device, however, I get the [XCUITest] Error: Unknown device or simulator UDID: <udid> error.

  • Appium 1.6.4
  • I tried uninstalling/reinstalling libimobiledevice (with --HEAD, per the instructions)
  • I switched USB ports
  • I ran ios-deploy -c and my device is recognized
  • I verified my device name is correct in my capabilities

I ran Appium from the console and then attempted to run my tests on the real device, and that worked. I just can’t run them for some reason when I start the Appium server programmatically.

Did you ever find a solution to this problem?

It’s environmental issue only, so creating builder with environment.

This is the code, which solves the issue for me

	Map<String, String> env = new HashMap<>(System.getenv());
	env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
                AppiumServiceBuilder builder = new AppiumServiceBuilder()
			.usingDriverExecutable(new File("/usr/local/bin/node"))
			.withAppiumJS(new File("/Applications/"));
	service = AppiumDriverLocalService.buildService(builder);


Have a scenario, Have the code in eclipse on windows, to start the appium server on mac from windows.
Installed appium through npm, manually if i start the server on mac and trigger the run using the eclispe code on windows is working fine. when i start the appium server though code, Im getting the below error. Also tried setting the PATH variable on mac and also in eclipse environment Run congiuration.–> No luck.
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: "Carthage not found. Install using brew install carthage". (WARNING: The server did not provide any stacktrace information)

Note: Carthage is installed. carthage version- 0.27
appium 1.7.1
node version - v6.4.0
npm version -v3.10.6

Appreicate help:slight_smile:

@Rudra any thoughts on the issue im facing?

Fixed the issue! Thanks!

@Bhuvan: How did you fixed the issue? I am facing same issue(Carthage not found. Install using brew install carthage". ) when I start server through eclipse using appiumDriverLocalService. But If I start Appium server on terminal on mac & then try to hit the code the iOS app works fine for me. Please help for the same.

Make sure the PATH variable is available for all the processes–> bash profile and .bashrc should be
set to /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin.

I have solved the problem by setting PATH in run configuration in eclipse

  1. In terminal type ‘echo $PATH’ and copy the path
  2. Go to eclipse and select which class file you have to run and select run configuration
  3. Click on environment - select new
  4. Name as ‘PATH’ and value as ‘paste the path you have in terminal’
  5. Now do apply and run will works

Below is the code to run appium server from script in eclipse for real iOS device, I ran and worked on iphone X

public static AppiumDriver setUp() throws Exception {
AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withArgument(GeneralServerFlag.LOG_LEVEL, “info”)

		service = AppiumDriverLocalService.buildService(builder);
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("appium-version", "1.8");
		capabilities.setCapability("platformName", "iOS");
		capabilities.setCapability("app", "/Users/user/Downloads/test.ipa");
	capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
		capabilities.setCapability("device", "iPhone");
		capabilities.setCapability("deviceName", "iPhone X");
		capabilities.setCapability("platformVersion", "11.26");
		capabilities.setCapability("bundleId", "com....");

driver = new IOSDriver<>(new URL(“”), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
return driver;