IOSでIonicアプリをエミュレートしようとしていますが、ionic cordova emulate ios
を実行するとエラーが発生します:
No target specified for emulator. Deploying to undefined simulator
Device type "com.Apple.CoreSimulator.SimDeviceType.undefined" could not be found.
私のOSXで利用可能なエミュレーターがあるのに、Ionicは、何らかの理由でそれらにアクセスできないようです。なぜIonicの場合、デバイスが見つからないのですか?他の場所で実行できるデバイスが明らかにありますか?これは環境変数の問題でしょうか?
参考:ionic info
:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.10
Cordova Platforms : Android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.9.2
System:
ios-sim : 7.0.0
Node : v9.1.0
npm : 6.0.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Environment Variables:
Android_HOME : not set
Misc:
backend : pro
ionic cordova emulate ios --list
を実行すると、次の出力が得られます。
Available ios virtual devices:
ただし、ios-sim showdevicetypes
を実行すると、次のようになります。
Apple-Watch-38mm, watchOS 4.3
Apple-Watch-42mm, watchOS 4.3
Apple-Watch-Series-2-38mm, watchOS 4.3
Apple-Watch-Series-2-42mm, watchOS 4.3
Apple-Watch-Series-3-38mm, watchOS 4.3
Apple-Watch-Series-3-42mm, watchOS 4.3
iPhone-5s, 11.4
iPhone-6, 11.4
iPhone-6-Plus, 11.4
iPhone-6s, 11.4
iPhone-6s-Plus, 11.4
iPhone-7, 11.4
iPhone-7-Plus, 11.4
iPhone-8, 11.4
iPhone-8-Plus, 11.4
iPhone-SE, 11.4
iPhone-X, 11.4
iPad-Air, 11.4
iPad-Air-2, 11.4
iPad--5th-generation-, 11.4
iPad-Pro--9-7-inch-, 11.4
iPad-Pro, 11.4
iPad-Pro--12-9-inch---2nd-generation-, 11.4
iPad-Pro--10-5-inch-, 11.4
Apple-TV-1080p, tvOS 11.4
Apple-TV-4K-4K, tvOS 11.4
Apple-TV-4K-1080p, tvOS 11.4
そして、xcrun simctl list
を実行すると次のようになります。
== Device Types ==
iPhone 4s (com.Apple.CoreSimulator.SimDeviceType.iPhone-4s)
iPhone 5 (com.Apple.CoreSimulator.SimDeviceType.iPhone-5)
iPhone 5s (com.Apple.CoreSimulator.SimDeviceType.iPhone-5s)
iPhone 6 (com.Apple.CoreSimulator.SimDeviceType.iPhone-6)
iPhone 6 Plus (com.Apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6s (com.Apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.Apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPhone 7 (com.Apple.CoreSimulator.SimDeviceType.iPhone-7)
iPhone 7 Plus (com.Apple.CoreSimulator.SimDeviceType.iPhone-7-Plus)
iPhone 8 (com.Apple.CoreSimulator.SimDeviceType.iPhone-8)
iPhone 8 Plus (com.Apple.CoreSimulator.SimDeviceType.iPhone-8-Plus)
iPhone SE (com.Apple.CoreSimulator.SimDeviceType.iPhone-SE)
iPhone X (com.Apple.CoreSimulator.SimDeviceType.iPhone-X)
iPad 2 (com.Apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.Apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.Apple.CoreSimulator.SimDeviceType.iPad-Air)
iPad Air 2 (com.Apple.CoreSimulator.SimDeviceType.iPad-Air-2)
iPad (5th generation) (com.Apple.CoreSimulator.SimDeviceType.iPad--5th-generation-)
iPad Pro (9.7-inch) (com.Apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (com.Apple.CoreSimulator.SimDeviceType.iPad-Pro)
iPad Pro (12.9-inch) (2nd generation) (com.Apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-)
iPad Pro (10.5-inch) (com.Apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-)
iPad (6th generation) (com.Apple.CoreSimulator.SimDeviceType.iPad--6th-generation-)
Apple TV (com.Apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple TV 4K (com.Apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K)
Apple TV 4K (at 1080p) (com.Apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p)
Apple Watch - 38mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
Apple Watch Series 2 - 38mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 - 42mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)
Apple Watch Series 3 - 38mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm)
Apple Watch Series 3 - 42mm (com.Apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm)
== Runtimes ==
iOS 11.4 (11.4 - 15F79) - com.Apple.CoreSimulator.SimRuntime.iOS-11-4
tvOS 11.4 (11.4 - 15L576) - com.Apple.CoreSimulator.SimRuntime.tvOS-11-4
watchOS 4.3 (4.3 - 15T212) - com.Apple.CoreSimulator.SimRuntime.watchOS-4-3
== Devices ==
-- iOS 11.4 --
iPhone 5s (68553C20-B109-4807-B20C-E93006B8F214) (Shutdown)
iPhone 6 (9B230488-BC8B-4947-AC2B-3B8245878625) (Shutdown)
iPhone 6 Plus (028C9FB4-4179-4772-AC96-9AEC9F447859) (Shutdown)
iPhone 6s (BFBFF883-1207-4049-851B-DDFF15D7A7D5) (Shutdown)
iPhone 6s Plus (6030E33B-DE97-41A6-A961-6C05DEA2EA34) (Shutdown)
iPhone 7 (0F1EE195-BB50-44D3-B87C-DB914196BB68) (Shutdown)
iPhone 7 Plus (42FDB489-30D3-4BEE-82F1-D6BCA84019F2) (Shutdown)
iPhone 8 (62895939-A322-4F3D-8D4E-8D8F3F44B98E) (Shutdown)
iPhone 8 Plus (79D7D0A1-03CE-425D-A714-13CE8E62BCB3) (Shutdown)
iPhone SE (82AC6B87-D98E-46A2-BE34-7F148F179796) (Shutdown)
iPhone X (FEA0BBCA-91C3-4EE3-A49A-7EE2BC4382A4) (Shutdown)
My-iPhoneX (A2E78F04-CB1B-4BCE-8BF3-8EA1B14930E5) (Shutdown)
iPad Air (6F05FAB3-7094-485E-B518-CE6EC1D46D54) (Shutdown)
iPad Air 2 (2A075B9A-35B3-410D-8D18-308A94F49F1D) (Shutdown)
iPad (5th generation) (879A193F-2AF3-4446-BB63-095AE6C9C3E6) (Shutdown)
iPad Pro (9.7-inch) (025D91DC-43CE-4497-A672-B57857BF6E68) (Shutdown)
iPad Pro (12.9-inch) (2D1C41EA-5F2E-493F-98C8-29FCCDB35D0F) (Shutdown)
iPad Pro (12.9-inch) (2nd generation) (96467014-EDC9-47EE-84FE-29AB7817B742) (Shutdown)
iPad Pro (10.5-inch) (47BEFF82-F240-4105-868D-CA4C8EE3BF29) (Shutdown)
-- tvOS 11.4 --
Apple TV (E3696606-A26C-4BCE-9CC3-1DC99B148ED3) (Shutdown)
Apple TV 4K (087290EA-40C9-4EEC-8A80-9D0A92378FA5) (Shutdown)
Apple TV 4K (at 1080p) (71014E88-3FEF-450A-B315-3C224271401A) (Shutdown)
-- watchOS 4.3 --
Apple Watch - 38mm (7914DF5F-9810-4995-908F-1BABBAE02670) (Shutdown)
Apple Watch - 42mm (A335D9E6-7974-45F6-B47D-3747FA9BD09E) (Shutdown)
Apple Watch Series 2 - 38mm (7FBCB06A-EE99-4C8F-BDD2-870EC5275EF0) (Shutdown)
Apple Watch Series 2 - 42mm (806DDCC1-588A-455D-AA1A-16F5E5931077) (Shutdown)
Apple Watch Series 3 - 38mm (DF16B352-301E-4221-81CA-2869A1F9B527) (Shutdown)
Apple Watch Series 3 - 42mm (85C06E5F-3E1A-4BC4-AECB-4EA0C88D8F09) (Shutdown)
== Device Pairs ==
BE73638A-71E6-41F2-A1EA-3372E898F1B0 (active, disconnected)
Watch: Apple Watch Series 2 - 38mm (7FBCB06A-EE99-4C8F-BDD2-870EC5275EF0) (Shutdown)
Phone: iPhone 7 (0F1EE195-BB50-44D3-B87C-DB914196BB68) (Shutdown)
E17C2241-7367-4F02-AC44-54542EDBC936 (active, disconnected)
Watch: Apple Watch Series 2 - 42mm (806DDCC1-588A-455D-AA1A-16F5E5931077) (Shutdown)
Phone: iPhone 7 Plus (42FDB489-30D3-4BEE-82F1-D6BCA84019F2) (Shutdown)
A463C9D5-E753-46F8-9493-D1A3E3BDCAA1 (active, disconnected)
Watch: Apple Watch Series 3 - 38mm (DF16B352-301E-4221-81CA-2869A1F9B527) (Shutdown)
Phone: iPhone 8 (62895939-A322-4F3D-8D4E-8D8F3F44B98E) (Shutdown)
7A7B90CE-9B4F-41A6-8721-C7457E9F4A4E (active, disconnected)
Watch: Apple Watch Series 3 - 42mm (85C06E5F-3E1A-4BC4-AECB-4EA0C88D8F09) (Shutdown)
Phone: iPhone 8 Plus (79D7D0A1-03CE-425D-A714-13CE8E62BCB3) (Shutdown)
出力ログが必要なため、ここにはたくさんのコードがあります。
または、次のようなものを試すこともできます:
cd platforms/ios/cordova
npm install ios-sim@latest
Mojaveにアップデートした後もこの問題が続く場合は、プラットフォームの削除と追加は機能しません。
代わりに、次のコマンドを使用してシミュレーターを直接呼び出すことができます
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.Apple.CoreSimulator.SimRuntime.iOS-12-2"
また、古いビルドシステムを使用している場合は、以下のようにフラグを追加できます
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.Apple.CoreSimulator.SimRuntime.iOS-12-2" --buildFlag="-UseModernBuildSystem=0"
Ionic v5.4.1およびios-sim @ latest(8.0.2)の時点では、他の回答はどれも機能しませんでした。最終的に機能したのは、listコマンドを実行してデバイスのUUIDを見つけることでした。次に、それをターゲットとして指定します。
ionic cordova emulate --list
ionic cordova emulate ios -l -c --target="<UUID>"
IOSプラットフォームを削除して追加する必要がありました
ionic cordova platform remove ios
ionic cordova platform add ios