Appium [求助] iOS 真机开启 appium 服务后,inspector 无法调起

414562336 · 2015年01月08日 · 最后由 梦梦GO 回复于 2017年05月19日 · 2031 次阅读

说明:iphone6 plus 8.1.2 appium GUI 1.3.3

xcode 模拟器运行工程,可正常启动,使用可真机调试的开发者证书打包应用到真机,工程也正常运行。
appium gui 设置中,勾选并填写正确的 bundle id udid, force device 为 iphone6 plus,server address 为 127.0.0.1,其他均未勾选。
步骤:使用 xcode 将应用打包到真机中,退出 Xcode,启动 appium GUI,启动 appium 服务,点击 inspector,手机上应用被拉起,然后一会儿退回手机桌面,应用被再次拉起,重试多次后报错无法拉起 inspector。必现。日志中的错误 Could not start script, target application is not frontmost.查了资料也没找到对应的解决办法,请各位大神指教。

以下是运行时日志:

info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","platformVersion":" ","newCommandTimeout":"999999","automationName":"Appium","deviceName":"iPhone 6 Plus"}}

info: Client User-Agent string: Appium (unknown version) CFNetwork/720.1.1 Darwin/14.0.0 (x86_64)

info: [debug] App is an iOS bundle, will attempt to run as pre-existing

info: [debug] Creating new appium session 4699692f-0e02-4087-aa08-4648e85e4634
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 8.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 /Applications/Appium.app/Contents/Resources/node_modules/appium/com.huawei.pushagent.mtn.onsite/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Applications/Appium.app/Contents/Resources/node_modules/appium/com.huawei.pushagent.mtn.onsite/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn't exist
info: [debug] Creating instruments

`parseFileSync()` is deprecated. Use `parseStringSync()` instead.

info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/apple/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/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/apple/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js
info: [debug] Reusing dynamic bootstrap: /Users/apple/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js

info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.1","iOSSDKVersion":"8.1","deviceName":"iPhone 6 Plus","platformVersion":" "}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 Plus (  Simulator)'
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 iOS Simulator
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 53c64243179b24ebec384dc8de22d5074175ba05
info: [debug] Couldn't find ideviceinstaller, trying built-in at /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
info: [debug] Checking app install status using: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id 53c64243179b24ebec384dc8de22d5074175ba05 --bundle com.huawei.pushagent.mtn.onsite

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 ci chu be lying cang
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.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 53c64243179b24ebec384dc8de22d5074175ba05 com.huawei.pushagent.mtn.onsite -e UIASCRIPT "/Users/apple/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":999999}

info: [debug] [INST STDERR] 2015-01-08 11:00:29.052 instruments[903:22897] WebKit Threading Violation - initial use of WebKit from a secondary thread.

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:30 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:30 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:31 Huawei-10 syslog_relay[25954] <Notice>: syslog_relay found the ASL prompt. Starting...
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:31 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:31 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:31 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:31 Huawei-10 mobile_installation_proxy[25957] <Error>: 0x100494000 handle_connection: Could not receive request from host.
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 SpringBoard[16989] <Warning>: Entitlement com.apple.multitasking.termination required to kill applications.
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 com.apple.xpc.launchd[1] (UIKitApplication:com.huawei.pushagent.mtn.onsite[0x9548][26061]) <Notice>: Service exited due to signal: Killed: 9
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 SpringBoard[16989] <Warning>: Unable to get short BSD proc info for 26061: No such process
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:32 Huawei-10 SpringBoard[16989] <Warning>: Unable to get short BSD proc info for 26061: No such process
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 SpringBoard[16989] <Warning>: Application 'UIKitApplication:com.huawei.pushagent.mtn.onsite[0x9548]' exited abnormally via signal.
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 assertiond[63] <Warning>: Could not set priority of <BKNewProcess: 0x15eec0c30; com.huawei.pushagent.mtn.onsite; pid: 26061; hostpid: -1> to 2, priority: No such process
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 UserEventAgent[21051] <Warning>: id=com.huawei.pushagent.mtn.onsite pid=26061, state=0
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 assertiond[63] <Warning>: Could not set priority of <BKNewProcess: 0x15eec0c30; com.huawei.pushagent.mtn.onsite; pid: 26061; hostpid: -1> to 4096, priority: No such process
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: xpcproxy[26063] Container: /private/var/mobile/Containers/Data/Application/1806BB26-0E79-45BD-8254-FF395BC2A9E3 (sandbox)
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 5-4[26063] <Error>: assertion failed: 12B440: libxpc.dylib + 71820 [A4F17798-F3DE-3FBC-85E3-F569762F0EB9]: 0x7d
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 Unknown[26063] <Error>:
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 notification_proxy[24898] <Error>: 0x10070c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:34 Huawei-10 kernel[0] <Notice>: flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 lockdownd[67] <Error>: Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:33 Huawei-10 notification_proxy[24898] <Error>: 0x100794000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.3","revision":"34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78"},"isShuttingDown":false},"sessionId":"4699692f-0e02-4087-aa08-4648e85e4634"}

info: <-- GET /wd/hub/status 200 1.502 ms - 178 {"status":0,"value":{"build":{"version":"1.3.3","revision":"34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78"},"isShuttingDown":false},"sessionId":"4699692f-0e02-4087-aa08-4648e85e4634"}

info: [debug] [INST] 2015-01-08 03:00:45 +0000 **Fail: Could not start script, target application is not frontmost.**

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:48 Huawei-10 com.apple.xpc.launchd[1] (UIKitApplication:com.huawei.pushagent.mtn.onsite[0x9858][26063]) <Notice>: Service exited due to signal: Killed: 9

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:48 Huawei-10 SpringBoard[16989] <Warning>: Unable to get short BSD proc info for 26063: No such process

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:48 Huawei-10 backboardd[15566] <Notice>: ALS: SetDisplayFactor: factor=1.0000

info: [IOS_SYSLOG_ROW ] Jan  8 11:00:49 Huawei-10 SpringBoard[16989] <Warning>: Application 'UIKitApplication:com.huawei.pushagent.mtn.onsite[0x9858]' exited abnormally via signal.

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

共收到 13 条回复 时间 点赞

我也遇到过这种情况,你看看你 Xcode 里面模拟器安装的对嘛?需要下载对应版本模拟器的

他是真机。不过真机是可以运行的。只是你不会。

发帖还是要遵循规矩的。

#3 楼 @lihuazhang 首先承认错误,后续发帖务必先看清要求。然后是问题,使用开发者证书打的包可以在真机运行,appium GUI 也能拉起应用(只是提示 ail: Could not start script, target application is not frontmost.),是不是能证明本身打包和证书是没问题的,也看了你的真机运行的文章,目前还不能确定问题可能出在哪边,还望能指正,是证书问题?appium 配置问题?版本匹配问题?多谢!



以上是配置截图

#4 楼 @313077271 真机端有配置么?

手机设置里面有个开发者,里面把 Enable UI Automation 打开试试

#6 楼 @lihuazhang 真机端将 Enable UI Automation 打开了,还需要其他什么设置?

#7 楼 @mouseyoung 打开了。我怀疑是打包的问题,请问打包需要什么特别的要求吗?使用的是开发者证书打的包,本机的 UDID 也加到了 provision 文件中。

#9 楼 @313077271 开发证书是可以的。

/Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 53c64243179b24ebec384dc8de22d5074175ba05 com.huawei.pushagent.mtn.onsite -e UIASCRIPT "/Users/apple/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js" -e UIARESULTSPATH /tmp/appium-instruments 用 instruments 直接运行看看

连接真机,打开被测工程,点击 Product—>Profile,完全退出自动启动的 instruments,在 xcode 文件夹中找出刚刚生成的.app 文件,拷出来后 appium 里设置 AppPath,和其他必要参数,Launch,打开 inspector,我平常是这么个流程,你试试看可以嘛?

我运行时候也是介个样子,然后重启或者手机等一下就好了。。。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册