I have tried it on real device follow the video, and met a issue as below.
Code:
import java.net.URL;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Main {
public static void main(String[] args) throws Exception {
AppiumDriver driver;
DesiredCapabilities ca = new DesiredCapabilities();
ca.setCapability("platformName", "iOS");
ca.setCapability("deviceName", "iPhone4");
ca.setCapability("platformVersion", "7.1");
ca.setCapability("udid", myudid);
ca.setCapability("app", "settings");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AppiumDriver(url, ca);
Error:
Detail response:
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"com.apple.Preferences","platformVersion":"7.1","deviceName":"iPhone4","platformName":"iOS","udid":"d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6"}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] App is an iOS bundle, will attempt to run as pre-existing
info: [debug] Creating new appium session 4ec9788d-b5f9-42d3-9d48-b6471556b604
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 7.1
info: [debug] Not checking whether simulator is available since we're on a real device
info: [debug] Detecting automation tracetemplate
info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/com.apple.Preferences/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/com.apple.Preferences/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn't exist
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/andy/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Volumes/Appium/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"sendKeyStrategy":"grouped"}
info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...
info: [debug] Dynamic bootstrap path: /Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js
info: [debug] Reusing dynamic bootstrap: /Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"5.1.1","iOSSDKVersion":"7.1","deviceName":"iPhone4","platformVersion":"7.1"}
info: [debug] fixDevice is on
info: [debug] Fixing device. Changed from: "iPhone - Simulator - iOS 7.1" to: "iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1"
info: [debug] Final device string is: 'iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1'
info: [debug] Not setting device type since we're on a real device
info: [debug] Checking whether we need to set app preferences
info: [debug] Not setting iOS and app preferences since we're on a real device
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iPhoneSimulator
info: [debug] Killing any other simulator daemons
info: [debug] On a real device; cannot clean device state
info: [debug] Not setting locale because we're using a real device
info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS device log capture via deviceconsole
info: [debug] Not pre-launching simulator
info: [debug] Creating iDevice object with udid d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Couldn't find ideviceinstaller, trying built-in at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
info: [debug] Checking app install status using: /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 --bundle com.apple.Preferences
info: [debug] App is installed.
info: [debug] fullReset not requested. No need to install.
info: [debug] Starting command proxy.
info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT "/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.filebrowser
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [debug] [INST STDERR] 2015-01-30 11:30:19.926 instruments[2625:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences
info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall iPhoneSimulator
info: Launching instruments
info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT "/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) mstreamd: Not monitoring for external power.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) PS: Media stream daemon stopping.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) AS: : Shared Streams daemon has shut down.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Warn ) mstreamd: mstreamd shutting down.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3514] : (Note ) mstreamd: mstreamd starting up.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3514] : (Note ) PS: Media stream daemon starting...
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.filebrowser
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [debug] [INST STDERR] 2015-01-30 11:30:27.076 instruments[2628:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences
info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #2
info: [debug] Killall iPhoneSimulator
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : DeregisterInterface: Frequent transitions for interface en0 (10.100.10.120)
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : mDNS_RegisterInterface: Frequent transitions for interface en0 (FE80:0000:0000:0000:049B:119E:0757:444A)
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0: BSSID changed to b0:00:b4:fa:b1:83
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0::IO80211Interface::postMessage bssid changed
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : 083794.439762 wlan.N[6861] [bringUpLink] AppleBCMWLAN Left BSS(up): @0x809dea00 BSSID=b0:00:b4:fa:b1:83 rssi=-48 snr= 0 rate=54 (100%) channel= 1 encryption=0x8 ap=1 failures= 0 age=1477 ssid[11]='clouddevice'
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : 083794.439923 wlan.N[6862] [bringUpLink] AppleBCMWLAN Roamed to BSS: @0x809d9c00 BSSID=28:34:a2:32:54:13 rssi=-61 snr= 0 rate=54 (100%) channel=11 encryption=0x8 ap=1 failures= 0 age=1132 ssid[11]='clouddevice'
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0: BSSID changed to 28:34:a2:32:54:13
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0::IO80211Interface::postMessage bssid changed
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : mDNS_RegisterInterface: Frequent transitions for interface en0 (10.100.10.120)
info: Launching instruments
info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT "/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.filebrowser
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [debug] [INST STDERR] 2015-01-30 11:30:34.194 instruments[2632:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences
info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #3
info: [debug] Killall iPhoneSimulator
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:35 iPhone-4 lockdownd[53] : 00201000 selectsocket: receive secure message timeout!
info: Launching instruments
info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT "/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.filebrowser
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [debug] [INST STDERR] 2015-01-30 11:30:41.935 instruments[2635:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences
info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iPhoneSimulator
info: [debug] Killing any other simulator daemons
info: [debug] On a real device; cannot clean device state
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: [debug] Cleaning up appium session
info: [debug] Error: Instruments crashed on startup
at Instruments.onInstrumentsExit (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:387:31)
at null. (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess.handle.onexit (childprocess.js:820:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 26241.652 ms - 182
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"}}}
info: <-- GET /wd/hub/status 200 1.216 ms - 104 {"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"}}}