Cordova : 특정 iOS 에뮬레이터 이미지 시작
개발 단계에서 주로 iOS에 중점을 둔 Cordova를 사용하여 크로스 플랫폼 모바일 앱을 개발 중입니다.
내 개발 프로세스의 경우 명령 줄에서 직접 Cordova 앱을 시작하고 지정된 에뮬레이터에로드 할 수 있다면 이상적입니다. 프로젝트 루트 디렉토리에서 다음을 실행하여이를 수행 할 수 있습니다.
$cordova run --debug --emulator iOS
이것은 잘 작동하며 iOS 7.0.3의 시뮬레이션 된 iPhone 4 Retina에서 내 앱을 실행하는 iOS 시뮬레이터가됩니다.
이 시뮬레이트 된 장치 외에도 (예를 들어) iPad에서 테스트하고 싶습니다. 이 에뮬레이션 이미지가 설치되어 있으며 Xcode에서 수동으로 앱을 시작할 수 있습니다. 또한, 명령 list-emulator-images
(에 위치한 project_dir/platforms/ios/cordova/lib
) 다음과 같은 출력을 제공한다 :
"iPhone Retina (3.5-inch)"
"iPhone Retina (4-inch)"
"iPhone Retina (4-inch 64-bit)"
"iPhone"
"iPad"
"iPad Retina"
그러나 문제는 기본 설정 ( iPhone Retina (4-inch)
에뮬레이션 이미지로 표시) 이외의 다른 방법으로 에뮬레이터를 시작하는 방법을 알 수없는 것 같습니다 . 관련 출력은 cordova help
다음 정보 를 제공합니다.
run [--debug|--release]
[--device|--emulator|--target=FOO]
[PLATFORM] ............................ deploys app on specified platform devices / emulators
나는 다음과 같은 것들을 시도했다.
cordova run --debug --emulator=iPad iOS
그리고 많은 변형이 있지만 운이 없습니다. 동일한 에뮬레이터에서 시작할 때마다.
명령 줄 도구 설명서 에는 이와 관련하여 정보가 제공되지 않으며 광범위한 Google 검색에서도 아무것도 찾지 못했습니다. 나는 사소한 것을 놓치고 있습니까? 아니면 이상한 일을하려고합니까? 나는 여기 누군가가 이것에 경험이 있기를 바랍니다.
미리 감사드립니다!
편집 : 명시 적으로 언급하는 것을 잊었다. Mac에서이 모든 작업을 수행하고 있습니다. 앞에서 언급했듯이 Xcode의 다른 에뮬레이터 / 시뮬레이터에서 앱을 실행하면 정상적으로 작동합니다.
사용 가능한 시뮬레이터 이미지가 무엇인지 찾으려면 해당 이미지를 나열하는 데 사용할 수 있습니다
$ cordova emulate ios --list
Available iOS Virtual Devices:
iPhone-4s, 9.3
iPhone-5, 9.3
iPhone-5s, 9.3
iPhone-6, 9.3
iPhone-6-Plus, 9.3
iPhone-6s, 9.3
iPhone-6s-Plus, 9.3
iPad-2, 9.3
iPad-Retina, 9.3
iPad-Air, 9.3
iPad-Air-2, 9.3
iPad-Pro, 9.3
그런 다음 --target 매개 변수에 시뮬레이터 이름 중 하나를 사용하십시오.
cordova emulate ios --target="iPhone-4s, 9.3"
cordova emulate ios --target="iPad-Air-2, 9.3"
cordova emulate ios --target="iPhone-6s, 9.3"
cordova emulate ios --target="iPhone-6-Plus, 9.3"
중요 사항 다른 대상 시뮬레이터를 시작하기 전에 시뮬레이터를 종료하십시오 (메뉴 막대 선택 Simulator->Quit
)
3.5 인치에서 4 인치 iPhone으로 전환하려면 메뉴를 통해 iOS 시뮬레이터를 종료해야 할 수도 있습니다.
동적 목록은 platforms/ios/cordova/lib/list-emulator-images
말하는 것처럼 csantanapr 사용할 수 :
cordova emulate ios --target="iPhone-4s"
그러나이 경우 cordova (또는 PhoneGap 또는 기타) 프로젝트는 iOS 버전 7.0.3의 iPhone 4s 시뮬레이터 에서 시작됩니다 .
If you want launch project on same simulator, but with other version iOS (7.1 or 8.0, if it versions exist in your system)?
Of corse, you can do like say cobberboy:
start a specific emulator and choose your ios version by directly using ios-sim.
But you can improve --target
option of cordova run
command.
At first you must ensure what target iOS version available on your system.
For it use answer of cobberboy:
$ ios-sim showdevicetypes
Then you need to open the file your_project_dir/platforms/ios/cordova/lib/run.js
and find lines of code like below:
// validate target device for ios-sim
// Valid values for "--target" (case sensitive):
var validTargets = ['iPhone-4s', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6',
'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
For use iPhone-4s, 7.1
(or some other) simple add it to array validTargets
.
var validTargets = ['iPhone-4s', 'iPhone-4s, 7.1', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6',
'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
And in
cordova emulate ios --target="iPhone-4s, 7.1"
your --target="iPhone-4s, 7.1"
will be valid.
And function deployToSim
of run.js
:
function deployToSim(appPath, target) {
// Select target device for emulator. Default is 'iPhone-6'
if (!target) {
target = 'iPhone-6';
console.log('No target specified for emulator. Deploying to ' + target + ' simulator');
}
var logPath = path.join(cordovaPath, 'console.log');
var simArgs = ['launch', appPath,
'--devicetypeid', 'com.apple.CoreSimulator.SimDeviceType.' + target,
// We need to redirect simulator output here to use cordova/log command
// TODO: Is there any other way to get emulator's output to use in log command?
'--stderr', logPath, '--stdout', logPath,
'--exit'];
return spawn('ios-sim', simArgs);
}
convert iPhone-4s, 7.1
to valid argument com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1
for ios-sim
.
TL;DR
You can start a specific emulator and choose your ios version by directly using ios-sim.
export appname="./platforms/ios/build/emulator/Hello World.app"
ios-sim launch "$appname" --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPad-2, 8.0" --stderr ./platforms/ios/cordova/console.log --stdout ./platforms/ios/cordova/console.log
Details
When I ran this:
cordova emulate ios --target="iPad"
and looked at the processes running, I saw this (on a single line):
ios-sim launch ./platforms/ios/build/emulator/HelloWorld.app
--stderr ./platforms/ios/cordova/console.log
--stdout ./platforms/ios/cordova/console.log
--family ipad
--exit
Investigating further into ios-sim, it looks like there are some more specific options, particularly:
--devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices.
e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"
So I did as it suggested and ran ios-sim with a "showdevicetypes" argument and got this:
$ ios-sim showdevicetypes
com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-5, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-2, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-Air, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-5, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-2, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-Air, 8.0
com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone, 8.0
com.apple.CoreSimulator.SimDeviceType.Resizable-iPad, 8.0
Don't include version number
cordova run ios --target="iPhone-6s"
As of Xcode 8.3.2...
Old thread, I know, but it seems, perhaps, that the answer has changed slightly. The hints from earlier posts in this thread helped, but so did reading the documentation included in the code, <cordova-project>/platforms/ios/cordova/lib/run.js
Execute ./platforms/ios/cordova/lib/list-emulator-images
to list the available emulator images. Do not include the version number on the end when making the cordova call to run in the desired emulator.
cordova run ios --emulator --target="iPad-Air"
I can't comment on the answer above due to my low reputation, but the list of targets is available from:
start-emulator
under
your platform/ios/cordova/lib/
Having said that, I cannot make the ipad retina emulator work...
fastest output of devices list: $ instruments -s devices
Just use the device name without the version.
Runs iOS simulator with web request based on already generated build for cordova application. Execute this request from browser opens simulator on mac with iPhone 8Plus version: http://hostname:3000/cordova/build/[xxxx-buildnumber]/emulate?target=iPhone-8-Plus
Different iphone and ipad simulator
cordova run ios --list
cordova emulate ios --target "iPhone-7"
@Birja's answer is working right now but the run command he used finally is still wrong so here the right answer:
To list all the devices available in simulator cordova run ios --list
It will result in something like this:
Available ios devices:
Available ios virtual devices:
Apple-TV-1080p, tvOS 12.2
Apple-Watch-Series-2-38mm, watchOS 5.2
iPhone-5s, 12.2
iPhone-6, 12.2
iPad-Air-2, 12.2
iPad--5th-generation-, 12.2
iPad-Pro--9-7-inch-, 12.2
iPad-Pro, 12.2
iPad-Pro--12-9-inch---2nd-generation-, 12.2
iPad-Pro--10-5-inch-, 12.2
iPad--6th-generation-, 12.2
iPad-Pro--11-inch-, 12.2
iPad-Pro--12-9-inch---3rd-generation-, 12.2
cordova run ios --target "iPad-Pro, 12.2"
Use any target from the above. To run in simulator.
참고URL : https://stackoverflow.com/questions/22310526/cordova-start-specific-ios-emulator-image
'Programing' 카테고리의 다른 글
iOSTableView는 iOS 7에서 오프셋으로 시작합니다. (0) | 2020.07.22 |
---|---|
Java에서 int의 스트림을 char의 스트림으로 변환 (0) | 2020.07.22 |
Android Retrofit 라이브러리에서 수업 용 변환기를 만들 수 없습니다. (0) | 2020.07.22 |
nil & empty의 문자열 확인 (0) | 2020.07.22 |
기존 파일을 일괄로 덮어 쓰는 방법은 무엇입니까? (0) | 2020.07.21 |