Issues with Safari on Real iOS Devices - Appium v1.3.4 with Java

Sorry, not sure if this is Issue/Bug or Support topic, and not perhaps not even an Appium issue.

Devices:

MacBook Retina OSX 10.9.5 - XCode 6.1
iPhone 4 on 7.1.2
iPad 3 on 8.0

My libraries are:

ideviceinstaller HEAD
libimobiledevice 1.1.7
libplist 1.12
node 0.10.32
usbmuxd 1.0.10

ios-webkit-debug-proxy 1.4 from source, running:

./bin/ios-webkit-debug-proxy-launcher.js -c [device udid]:27753 -d

Appium v1.3.4 running from source, using:

./reset.sh --ios --real-safari --code-sign 'iPhone Developer' --profile 'profile code'

I’m not actually sure what to put in for code-sign but it doesn’t seem to matter. Profile code is from the provision file from Apple.
Then run Appium with:

node lib/server/main.js -U <udid>

Where both UDID are copied from, so they should not be wrong:

instruments -s devices

Now when I run the Java test:

Sometimes it works, but it sometimes ios-webkit-debug-proxy will have an error:

Invalid message _rpc_applicationUpdated: <dict>
    <key>WIRApplicationBundleIdentifierKey</key>
    <string>com.apple.mobilesafari</string>
    <key>WIRApplicationNameKey</key>
    <string>Safari</string>
    <key>WIRIsApplicationProxyKey</key>
    <false/>
    <key>WIRIsApplicationActiveKey</key>
    <integer>0</integer>
    <key>WIRApplicationIdentifierKey</key>
    <string>PID:176</string>
</dict>

Which ios-webkit-debug-proxy-launcher.js catches and relaunches ios-webkit-debug-proxy.
However, another error sometimes comes up before that one:

stderr: Unknown app_id com.apple.mobilesafari

At this point, Appium will have an entry saying that the connection was refused since ios-webkit-debug-proxy is dead. This error isn’t caught by i-w-d-p launcher, so I added it to the error messages to detect.

Now, with my change, Unknown app_id is caught but the ios-webkit-debug-proxy-launcher does not look like it restarts:

stderr: Unknown app_id com.apple.mobilesafari

Detected error message: Unknown app_id
Killing proxy!
RUNNING: ios_webkit_debug_proxy -c 93aa224dbed74d186076fcf422836298d7ae29d8:27753 -d
stderr: Invalid message _rpc_applicationSentListing: <dict>
	<key>WIRApplicationIdentifierKey</key>
	<string>com.apple.mobilesafari</string>
	<key>WIRListingKey</key>
	<dict>
		<key>17</key>
		<dict>
			<key>WIRPageIdentifierKey</key>
			<integer>17</integer>
			<key>WIRTitleKey</key>
			<string>Google</string>
			<key>WIRURLKey</key>
			<string>https://www.google.com/?gws_rd=ssl</string>
		</dict>
		<key>19</key>
		<dict>
			<key>WIRPageIdentifierKey</key>
			<integer>19</integer>
			<key>WIRTitleKey</key>
			<string>Apple</string>
			<key>WIRURLKey</key>
			<string>http://www.apple.com/</string>
		</dict>
	</dict>
</dict>
...

ss.remove_fd(6)
Disconnected :27753 from iPhone (<udid>)
ss.remove_server_fd(4)
ss.remove_fd(3)

child process exited with code 0

Occasionally with my change, I get nothing happening after SafariLauncher launches Safari:

[debug] Didn't get a new command in 60 secs, shutting down...
[info] Shutting down appium session
[debug] Stopping ios
[debug] Closing socket server.
[debug] Instruments socket server was closed
[debug] Sending sigterm to instruments

and ios-webkit-debug-proxy is still running. Maybe this is because Appium has sent the command to the device already and ios-webkit was off during the restart of an error?

Does anyone have any idea what I can do to get Safari testing to work (reliably)?

Thanks.

Edit: I have Web Inspector turned on, and UI Automation enabled for my iOS 8.0 iPad.

UPDATE: I have tried it with a 10.8.5 VM, so it doesn’t seem to be OS related.

Related issues that I’ve read in case someone else has this problem:

https://groups.google.com/forum/#!msg/appium-discuss/HmQo3hLdSyQ/disg_volTKMJ

hi,
I am still facing the same issue, @jchuong have u find any solution

Note:
I am getting error while installing --HEAD ideviceinstaller

Error:
undefined macro - AM_PROG_CC_C_O
undefined macro - AM_PROG_LIBTOOL
undefined macro - AM_COMPILER_FLAGs

Thanks

I should have fix this myself: