Appium support for Xamarin iOS projects

Does Appium work with Xamarin iOS projects?

I’m getting the following error when I try to run Appium against the “XamarinStore”, which is one of the reference apps included with Xamarin:

Bad app: /Users/dev/appium/sample-code/sample-code/examples/java/junit/Users/iandow/Projects/xamarin-store-app-master/XamarinStore.iOS/bin/iPhoneSimulator/Debug/XamarinStoreiOS.app

Yes, it does. Here’s a sample app from Xamarin.

Any idea why appium is returning the “Bad app” error?

The XamarinStoreiOS.app works fine in the simulator that gets spawned from Xamarin Studio.

I’m not sure why that’s erroring. The Xamarin apps I’ve tested work fine.

I solved my problem. Here’s what I’ve discovered:

In my junit class (e.g. SimpleTest.java), a relative path must be used for the appDir. If I use the full path, appium will return, …Bad app…Error locating the app: ENOENT, stat….

In other words, this works:

    `File appDir = new File(System.getProperty("user.dir"), "../../../apps/XamarinStore.iOS/bin/iPhoneSimulator/Release/");`

but this fails:

    `File appDir = new File(System.getProperty("user.dir"), "/Users/devone/Projects/xamarin-store-app-master/XamarinStore.iOS/bin/iPhoneSimulator/Release/");`

Here’s the error I get:

`Failed to start an Appium session, err was: Error: Bad app: /Users/devone/development/appium/sample-code/sample-code/examples/java/junit/Users/devone/Projects/xamarin-store-app-master/XamarinStore.iOS/bin/iPhoneSimulator/Release/XamarinStoreiOS.app. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/devone/development/appium/sample-code/sample-code/examples/java/junit/Users/devone/Projects/xamarin-store-app-master/XamarinStore.iOS/bin/iPhoneSimulator/Release/XamarinStoreiOS.app'`
1 Like

You could try File.getCanonicalPath. appium requires the full non-relative path.

Hi my .app file made in xamarine crashes when I try to install it in simulator using appium plz help

@Shashank_Garg Were you able to resolve this issue? What is the error you see in the Appium logs?

@bootstraponline, @iandow

When launching the Xamarin test app from Appium/Xcode simulator, it crashes and the error is Instruments crashed on startup. This is the same error when I try to launch my ios app compiled and built using Xamarin. How did you get your xamarin built ios app to work with Xamarin?

I didn’t have to do anything special to get Xamarin apps working. I compiled it for the iOS simulator and then tested via the simulator.

thanks but I do give full path and the every xamrine app crashes also when instantiated through appium ui directly. also note it works only on system which have xamrine installed on it. plz do help here’

@bootstraponline: do u have xmarine installed on the system u are testing in. If yes then it will work the problem in getting it work in a system which dosent have xamrine.

Logs

nfo: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.flickr.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.facebook.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.weibo.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.imfoundation.IMRemoteURLConnectionAgent): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.vimeo.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.tencentweibo.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (com.apple.twitter.xpc): The _DirtyJetsamMemoryLimit key is not available on this platform.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local AnalogClockiOS[17433]: MonoTouch: Socket error while connecting to MonoDevelop on 127.0.0.1:10000: Connection refused

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local AnalogClockiOS[17433]: The assembly mscorlib.dll was not found or could not be loaded.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local AnalogClockiOS[17433]: It should have been installed in the `/Developer/MonoTouch/Source/monotouch/builds/install/simulator86/lib/mono/2.0/mscorlib.dll’ directory.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server com.apple.CoreSimulator.SimDevice.D8089B28-2071-476E-B390-397471195F37.launchd_sim[17390] (UIKitApplication:com.your-company.AnalogClock.iOS[0x132f][17433]): Service exited with abnormal code: 1

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local SpringBoard[17401]: Unable to get short BSD proc info for 17433: No such process

info: [debug] [INST] 2014-12-05 05:15:25 +0000 Fail: The target application appears to have died

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local ScriptAgent[17435]: Warning - Unable to stop script because the script was already stopped.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local SpringBoard[17401]: Application ‘UIKitApplication:com.your-company.AnalogClock.iOS[0x132f]’ exited voluntarily.

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server assertiond[17405]: assertion failed: 13F34 12B407: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:25 server.local SpringBoard[17401]: Unable to deliver -[UIRemoteApplication showTopMostMiniAlertWithSynchronizationPort:] message to port 0: (ipc/send) invalid destination port

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:26 — last message repeated 1 time —

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:26 server assertiond[17405]: assertion failed: 13F34 12B407: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1

info: [debug] [INST] Instruments Trace Complete (Duration : 32.550449s; Output : /tmp/appium-instruments/instrumentscli0.trace)

info: [debug] [INSTSERVER] Instruments exited with code 0

info: [debug] Killall instruments

info: [debug] Instruments crashed on startup

info: [debug] Attempting to retry launching instruments, this is retry #1

info: [debug] Killall iOS Simulator

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:26 — last message repeated 1 time —

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:26 server.local DTMobileIS[17409]: Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [IOS_SYSLOG_ROW ] Dec 5 10:45:26 server.local DTMobileIS[17409]: Could not create service named com.apple.instruments.server.services.launchdaemon

yes, I have xamarin installed on the system I’m testing.

Thanks for your response @bootstraponline

When you say Simulator, are you referring to the Xamarin simulator or Xcode simulator? I believe Appium uses Xcode simulator to load apps and when I try to load the Xamarin test app or my ios app built from Xamarin using Appium, instruments keeps crashing. Looking for some pointers around this issue if you have experienced it before?

@Shashank_Garg - I seem to be getting the same error. So you’re saying, if you have Xamarin installed on the machine and you try to load the app on a simulator using Appium, it works?

yes is works even for xcode simulator for a system which has xamrine installed. As per my understanding some reference/ dependeincies are missing while compiling a xamrine app. my company is a priority customer of xamrine hence i have pitches the same question to them too.
What we can try is automating on the device by using Bundel Id

Thanks for the update. Keep me posted on what you hear from Xamarin.
When you used the Bundle ID and used a real device, it worked for you? Where do you get the bundle ID from?

i didnt try that option in a non xamrine system will try on Monday. if you have source code then u can get in form app properties else
You can findle the bundle id from the plist. Right Click in the app file and click on “show package contents”. You will find a plist file there. Open it with any text editor and you will get the bundle id.

//code to get bundle id
var target = UIATarget.localTarget();
var app_name = target.frontMostApp().bundleID();
UIALogger.logDebug(app_name);

Hi Shashank,

I installed Xamarin studio on the Mac and tried to launch the app through Appium. It still keeps crashing with the instruments crashed error. Did you try to launch the app on Xamarin simulator or Xcode simulator (through Appium)?

I tried launching in through appium and it worked.

Try compiling the code in ur machine using Xamarin and use the compiled app for appium it should work this way

Hi Shashank,

your solution to compile the code in Xamarin on the Mac running Appium worked. The app is now launching on ios simulator as expected. Thanks much for your help !

Did you hear back from Xamarin on how this dependency can be removed? It wont be feasible to have a Xamarin license on all test automation machines.