找不到离子目标设备

Posted

技术标签:

【中文标题】找不到离子目标设备【英文标题】:ionic Target Device not found 【发布时间】:2019-08-08 10:11:32 【问题描述】:

我有一个 ionic3 项目,我正在尝试在 iphone plus 8、12.4 模拟器上运行它。但是当我运行时:

ionic cordova emulate ios --target="iPhone-8-Plus" --verbose

它给了我一个错误:

** BUILD SUCCEEDED **

Command finished with error code 0: xcodebuild -workspace,MyApp.xcworkspace,-scheme,MyApp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 8 Plus,build,CONFIGURATION_BUILD_DIR=/Users/myuser/MyProjects/mobileapp/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/myuser/MyProjects/mobileapp/platforms/ios/build/sharedpch,-UseModernBuildSystem=0
No scripts found for hook "after_compile".
No scripts found for hook "after_build".
> native-run ios --app "platforms/ios/build/emulator/MyApp.app" --target iPhone-8-Plus --verbose
[native-run] 2019-08-08T10:01:24.916Z client:usbmuxd connectUsbmuxdSocket
[native-run] 2019-08-08T10:01:24.919Z client:usbmuxd getDevices
[native-run] 2019-08-08T10:01:24.920Z protocol:usbmux socket write: "messageType":"ListDevices"
[native-run] 2019-08-08T10:01:25.517Z protocol:usbmux Response: "DeviceList":[]
[native-run] 2019-08-08T10:01:25.523Z native-run Caught fatal error:  Error: No device or simulator with UDID "iPhone-8-Plus" found
[native-run]     at Object.run (/usr/local/lib/node_modules/native-run/dist/ios/run.js:47:23)
[native-run]     at process._tickCallback (internal/process/next_tick.js:68:7) code: 'ERR_TARGET_NOT_FOUND', exitCode: 1, data: undefined 
[native-run] ERR_TARGET_NOT_FOUND: No device or simulator with UDID "iPhone-8-Plus" found
[ERROR] An error occurred while running subprocess native-run.

        native-run ios --app "platforms/ios/build/emulator/MyApp.... exited with exit code 1.

我运行以下命令来检查设备:

ionic cordova emulate --list
[native-run]   iPad (5th generation) 12.4 80B0D70B-2E2D-4D9C-B098-119AC267E908
[native-run]   iPad (6th generation) 12.4 C9975663-AD93-4582-8521-8DECF6BBE611
[native-run]   iPad Air 12.4 C6235A65-D421-464E-A0CE-A238E851F511
[native-run]   iPad Air (3rd generation) 12.4 672C4237-B6FE-4F30-8BE8-F1D1E6D1A0BA
[native-run]   iPad Air 2 12.4 FB5447BD-E1AE-4434-943F-64C940C467D5
[native-run]   iPad Pro (10.5-inch) 12.4 54C47CD4-4074-4021-A355-57DBE30A6223
[native-run]   iPad Pro (11-inch) 12.4 FCFD179A-C8E1-48AF-94A4-95CFEF37C88C
[native-run]   iPad Pro (12.9-inch) 12.4 76BCB2BD-75E1-473C-B73E-3E7D6EE9B7ED
[native-run]   iPad Pro (12.9-inch) (2nd generation) 12.4 8F73DCAD-9BDB-4009-AB2E-910745F5EEB0
[native-run]   iPad Pro (12.9-inch) (3rd generation) 12.4 ADDC043D-9476-49CF-8FD9-D9F92A0AF4DE
[native-run]   iPad Pro (9.7-inch) 12.4 252EB4D4-17A3-465E-8A26-9F0EA1D28999
[native-run]   iPhone 5s 12.4 4284CF9C-AEBE-4890-83FF-D8C3B0BA47B9
[native-run]   iPhone 6 12.4 A4BF9A50-2FF6-49B0-82B8-F3EDA6DB6E0B
[native-run]   iPhone 6 Plus 12.4 904CE565-198F-49BD-A5A3-DE927B320CD0
[native-run]   iPhone 6s 12.4 3B3225E7-2591-4441-991E-3B1CE494CE90
[native-run]   iPhone 6s Plus 12.4 4A5431F9-B7B5-45F2-A7F9-4CFB633D7BF0
[native-run]   iPhone 7 12.4 7DBEA756-7759-4025-809B-D6704FF23223
[native-run]   iPhone 7 Plus 12.4 1E7DF2AB-E4AE-4834-8BFA-328E8B7DE34E
[native-run]   iPhone 8 12.4 B1BBB831-4C2C-4107-A3B1-F5C3B6699957
[native-run]   iPhone 8 Plus 12.4 DFB1E30F-AEC9-4089-8D16-2AC71FC6B704
[native-run]   iPhone SE 12.4 30AC9EE2-8132-4A61-B7B2-E651A7C7691E
[native-run]   iPhone X 12.4 1C20F1D6-132D-46F1-AE1E-A027984D832A
[native-run]   iPhone Xs 12.4 490D0B7C-5044-4E07-830B-E8FDBC8E8B7C
[native-run]   iPhone Xs Max 12.4 A5CD7626-8954-4CF9-8603-168CA1BCAAFD
[native-run]   iPhone Xʀ 12.4 B776F557-C4BD-49A8-9F81-5F6AD839AD0A

然后:

./myproject/platforms/ios/cordova/lib/list-emulator-images
Apple-Watch-Series-2-38mm, watchOS 5.3
Apple-Watch-Series-2-42mm, watchOS 5.3
Apple-Watch-Series-3-38mm, watchOS 5.3
Apple-Watch-Series-3-42mm, watchOS 5.3
Apple-Watch-Series-4-40mm, watchOS 5.3
Apple-Watch-Series-4-44mm, watchOS 5.3
iPhone-5s, 12.4
iPhone-6, 12.4
iPhone-6-Plus, 12.4
iPhone-6s, 12.4
iPhone-6s-Plus, 12.4
iPhone-7, 12.4
iPhone-7-Plus, 12.4
iPhone-8, 12.4
iPhone-8-Plus, 12.4
iPhone-SE, 12.4
iPhone-X, 12.4
iPhone-XS, 12.4
iPhone-XS-Max, 12.4
iPhone-XR, 12.4
iPad-Air--3rd-generation-, 12.4
iPad-Air, 12.4
iPad-Air-2, 12.4
iPad--5th-generation-, 12.4
iPad-Pro--9-7-inch-, 12.4
iPad-Pro, 12.4
iPad-Pro--12-9-inch---2nd-generation-, 12.4
iPad-Pro--10-5-inch-, 12.4
iPad--6th-generation-, 12.4
iPad-Pro--11-inch-, 12.4
iPad-Pro--12-9-inch---3rd-generation-, 12.4
Apple-TV-1080p, tvOS 12.4
Apple-TV-4K-4K, tvOS 12.4
Apple-TV-4K-1080p, tvOS 12.4

我尝试了不同的目标选项,例如“iPhone-8-Plus”、iPhone 8 Plus、“iPhone-8-Plus, 12.4”、“DFB1E30F-AEC9-4089-8D16-2AC71FC6B704”(旁边的 id iphone 8 plus,但没有任何成功。

如果我从 xcode 打开项目并从那里运行它,它可以正常工作。

有什么想法吗? 谢谢

【问题讨论】:

【参考方案1】:

您必须运行以下命令:

ionic cordova run ios --livereload --target "BA4986B3-9102-4250-91BF-7DDF7D7BC60D"

其中 target 是您列表中的设备 ID

【讨论】:

【参考方案2】:

原来$ cordova emulate --list 的结果与$ native-run --list 的结果不同(运行这两个命令,您会看到设备名称不同)。

Ionic CLI uses native-run 默认运行模拟器,因此您使用 emulate --list 命令获得的设备名称将不匹配。您需要通过添加标志--no-native-run 来使用cordova 而不是本机运行来运行您的应用程序:

$ ionic cordova emulate ios --target="iPhone-8-Plus" --no-native-run

离子科尔多瓦运行

此命令将首先使用 ionic build 来构建 Web 资产(或带有 --livereload 选项的 ionic serve)。然后,cordova build 用于编译和准备您的应用程序。 最后,本机运行实用程序用于在设备上运行您的应用。要在此过程中使用 Cordova,请使用 --no-native-run 选项

来自https://ionicframework.com/docs/cli/commands/cordova-run

【讨论】:

【参考方案3】:

关闭 chrome 调试器以及chrome://inspect 选项卡。

【讨论】:

以上是关于找不到离子目标设备的主要内容,如果未能解决你的问题,请参考以下文章

离子3:找不到管道''[重复]

打字稿错误找不到名称'require'。离子 3

找不到模块“离子原生”

离子/角度:找不到管道“异步”

离子 - 错误:找不到模块'android-versions'

离子 3 - 找不到 FirebaseInstanceID