기본 변경 기본 iOS 시뮬레이터 장치 대응
이 명령을 실행할 때:
react-native run-ios
내 앱은 iPhone6 시뮬레이터 장치에서 기본적으로 실행됩니다.
Found Xcode project RN.xcodeproj
Launching iPhone 6 (9.2)...
기본적으로 앱을 다른 시뮬레이터 장치(예: iPhone5s)에서 실행하려면 어떻게 해야 합니까?
시지정터이를 --simulator
깃발
iOS 14.0 이상에서 사용할 수 있는 장치는 다음과 같습니다.
npx react-native run-ios --simulator="iPhone 8"
npx react-native run-ios --simulator="iPhone 8 Plus"
npx react-native run-ios --simulator="iPhone 11"
npx react-native run-ios --simulator="iPhone 11 Pro"
npx react-native run-ios --simulator="iPhone 11 Pro Max"
npx react-native run-ios --simulator="iPhone SE (2nd generation)"
npx react-native run-ios --simulator="iPhone 12 mini"
npx react-native run-ios --simulator="iPhone 12"
npx react-native run-ios --simulator="iPhone 12 Pro"
npx react-native run-ios --simulator="iPhone 12 Pro Max"
npx react-native run-ios --simulator="iPhone 13 Pro"
npx react-native run-ios --simulator="iPhone 13 Pro Max"
npx react-native run-ios --simulator="iPhone 13 mini"
npx react-native run-ios --simulator="iPhone 13"
npx react-native run-ios --simulator="iPod touch (7th generation)"
npx react-native run-ios --simulator="iPad Pro (9.7-inch)"
npx react-native run-ios --simulator="iPad (9th generation)"
npx react-native run-ios --simulator="iPad Air (4th generation)"
npx react-native run-ios --simulator="iPad Pro (11-inch) (3rd generation)"
npx react-native run-ios --simulator="iPad Pro (12.9-inch) (5th generation)"
npx react-native run-ios --simulator="iPad mini (6th generation)"
사용 가능한 모든 iOS 장치 나열:
xcrun simctl list devices
현재 기본값을 설정할 수 있는 방법이 없습니다.
항목을 다음에 추가하여 npm을 사용할 수도 있습니다.scripts
의 의요소 package.json
예: 예일. 파
"launch-ios": "react-native run-ios --simulator \"iPad Air 2\""
다음합니다.npm run launch-ios
이를 달성하는 방법은 여러 가지가 있습니다.
- 을 사용하여
--simulator
- 을 사용하여
--udid
먼저 사용 가능한 모든 장치를 나열해야 합니다.실행 중인 모든 장치를 나열하려면 다음과 같이 하십시오.
xcrun simctl list devices
그러면 다음과 같은 출력이 제공됩니다.
iOS 13.0 이상에서 사용할 수 있는 장치는 다음과 같습니다.
== Devices ==
-- iOS 13.6 --
iPhone 8 (5C7EF61D-6080-4065-9C6C-B213634408F2) (Shutdown)
iPhone 8 Plus (5A694E28-EF4D-4CDD-85DD-640764CAA25B) (Shutdown)
iPhone 11 (D6820D3A-875F-4CE0-B907-DAA060F60440) (Shutdown)
iPhone 11 Pro (B452E7A1-F21C-430E-98F0-B02F0C1065E1) (Shutdown)
iPhone 11 Pro Max (94973B5E-D986-44B1-8A80-116D1C54665B) (Shutdown)
iPhone SE (2nd generation) (90953319-BF9A-4C6E-8AB1-594394AD26CE) (Booted)
iPad Pro (9.7-inch) (9247BC07-00DB-4673-A353-46184F0B244E) (Shutdown)
iPad (7th generation) (3D5B855D-9093-453B-81EB-B45B7DBF0ADF) (Shutdown)
iPad Pro (11-inch) (2nd generation) (B3AA4C36-BFB9-4ED8-BF5A-E37CA38394F8) (Shutdown)
iPad Pro (12.9-inch) (4th generation) (DBC7B524-9C75-4C61-A568-B94DA0A9BCC4) (Shutdown)
iPad Air (3rd generation) (03E3FE18-AB46-481E-80A0-D37383ADCC2C) (Shutdown)
-- tvOS 13.4 --
Apple TV (41579EEC-0E68-4D36-9F98-5822CD1A4104) (Shutdown)
Apple TV 4K (B168EF40-F2A4-4A91-B4B0-1F541201479B) (Shutdown)
Apple TV 4K (at 1080p) (D55F9086-A56E-4893-ACAD-579FB63C561E) (Shutdown)
-- watchOS 6.2 --
Apple Watch Series 4 - 40mm (D4BA8A57-F9C1-4F55-B3E0-6042BA7C4ED4) (Shutdown)
Apple Watch Series 4 - 44mm (65D5593D-29B9-42CD-9417-FFDBAE9AED87) (Shutdown)
Apple Watch Series 5 - 40mm (1B73F8CC-9ECB-4018-A212-EED508A68AE3) (Shutdown)
Apple Watch Series 5 - 44mm (5922489B-5CF9-42CD-ACB0-B11FAF88562F) (Shutdown)
그런 다음 출력에서 이름 또는 UUID를 선택한 후 원하는 대로 진행할 수 있습니다.
- 를 사용하여
--simulator
선택사항:
npx react-native run-ios --simulator="iPhone SE"
- 를 사용하여
--udid
플래그 실행:
npx react-native run-ios --udid 90953319-BF9A-4C6E-8AB1-594394AD26CE
이 답변이 당신에게 도움이 되었기를 바랍니다.
의 서별만수에서 별칭을 수 .~/.bash_profile
파일 이름:
alias rn-ios="react-native run-ios --simulator \"iPhone 5s (10.0)\""
그런 다음 생성된 별칭을 사용하여 react-native를 실행합니다.
$ rn-ios
다음과 같이 검색하면 프로젝트 설정이 있습니다.
{project}/node_modules/react-native/local-cli/runIOS/runIOS.js
아래에 몇 가지 옵션이 있습니다.module.exports
다음을 포함합니다.
options: [{ command: '--simulator [string]', description: 'Explicitly set simulator to use', default: 'iPhone 7', }
내 것은 231번 라인이었고, 그것을 설치된 유효한 시뮬레이터로 설정하고 실행하기만 하면 됩니다.react-native run-ios
기본적으로 해당 시뮬레이터로 실행됩니다.
이름은 같지만 iOS 버전이 다른 시뮬레이터의 이름을 변경합니다.
Xcode -> Window -> Devices and Simulators -> Simulators.
대응 기본 프로젝트 폴더 열기
패키지를 편집합니다.제이손
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"flow": "node_modules/.bin/flow",
"start-iphone6": "react-native run-ios --simulator \"iPhone 6 11.3\""
}
4)npm run start-iphone6
Ian L이 답변했듯이, 저는 또한 스크립트를 관리하기 위해 NPM을 사용합니다.
예:
{
"scripts": {
"ios": "react-native run-ios --simulator=\"iPad Air 2\"",
"devices": "xcrun simctl list devices"
}
}
이를 통해 필요한 것을 신속하게 얻을 수 있습니다.
- 장치 : 모든 나열장:
npm run devices
- 시뮬레이터를 합니다.
npm run ios
여기 iOS 시뮬레이터를 변경하기 위한 새로운 경로가 있습니다.
default: 'iPhone 6' or something else
경로:
<project_root>/node_modules/@react-native-community/cli/build/commands/runIOS/runIOS.js
사용할 수 있습니다.
npx react-native run-ios --simulator="iPhone 14"
하여 "6 (iPhone 6 (9.2)"를 추가하지의 새 합니다.--simulator="iPhone 14"
이 명령으로 장치 목록 가져오기
xcrun simctl list devices
콘솔
== Devices ==
-- iOS 13.5 --
iPhone 6s (9981E5A5-48A8-4B48-B203-1C6E73243E83) (Shutdown)
iPhone 8 (FC540A6C-F374-4113-9E71-1291790C8C4C) (Shutting Down)
iPhone 8 Plus (CAC37462-D873-4EBB-9D71-7C6D0C915C12) (Shutdown)
iPhone 11 (347EFE28-9B41-4C1A-A4C3-D99B49300D8B) (Shutting Down)
iPhone 11 Pro (5AE964DC-201C-48C9-BFB5-4506E3A0018F) (Shutdown)
iPhone 11 Pro Max (48EE985A-39A6-426C-88A4-AA1E4AFA0133) (Shutdown)
iPhone SE (2nd generation) (48B78183-AFD7-4832-A80E-AF70844222BA) (Shutdown)
iPad Pro (9.7-inch) (2DEF27C4-6A18-4477-AC7F-FB31CCCB3960) (Shutdown)
iPad (7th generation) (36A4AF6B-1232-4BCB-B74F-226E025225E4) (Shutdown)
iPad Pro (11-inch) (2nd generation) (79391BD7-0E55-44C8-B1F9-AF92A1D57274) (Shutdown)
iPad Pro (12.9-inch) (4th generation) (ED90A31F-6B20-4A6B-9EE9-CF22C01E8793) (Shutdown)
iPad Air (3rd generation) (41AD1CF7-CB0D-4F18-AB1E-6F8B6261AD33) (Shutdown)
-- tvOS 13.4 --
Apple TV 4K (51925935-97F4-4242-902F-041F34A66B82) (Shutdown)
-- watchOS 6.2 --
Apple Watch Series 5 - 40mm (7C50F2E9-A52B-4E0D-8B81-A811FE995502) (Shutdown)
Apple Watch Series 5 - 44mm (F7D8C256-DC9F-4FDC-8E65-63275C222B87) (Shutdown)
예를 들어 ID가 없는 시뮬레이터 문자열을 선택합니다.
iPad Pro(12.9인치)(4세대)
최종 명령
아이폰
아이폰 6s
react-native run-ios --simulator="iPhone 6s"
아이폰 8
react-native run-ios --simulator="iPhone 8"
아이폰 8 플러스
react-native run-ios --simulator="iPhone 8 Plus"
아이폰 11
react-native run-ios --simulator="iPhone 11"
아이폰 11 프로
react-native run-ios --simulator="iPhone 11 Pro"
아이폰 11 프로 맥스
react-native run-ios --simulator="iPhone 11 Pro Max"
아이폰SE(2세대)
react-native run-ios --simulator="iPhone SE (2nd generation)"
아이패드
아이패드 프로(9.7인치)
react-native run-ios --simulator="iPad Pro (9.7-inch)"
아이패드(7세대)
react-native run-ios --simulator="iPad (7th generation)"
아이패드 프로 (11인치) (2세대)
react-native run-ios --simulator="iPad Pro (11-inch) (2nd generation)"
아이패드 프로(12.9인치) 4세대
react-native run-ios --simulator="iPad Pro (12.9-inch) (4th generation)"
아이패드 에어(3세대)
react-native run-ios --simulator="iPad Air (3rd generation)"
올바른 iOS 시뮬레이터 버전 번호를 지정하는 XCode 10.2에 문제가 있어서 다음과 같이 사용했습니다.
react-native run-ios --simulator='iPhone X (com.apple.CoreSimulator.SimRuntime.iOS-12-1)'
iPhone Xʀ Simulator용
"iosxr": "react-native run-ios --simulator=\"iPhone Xʀ\"",
이것을 패키지의 스크립트에 추가하기만 하면 됩니다.json 파일
여기서 사용되는 문자 "ʀ"는 "R"과 다른 유니코드입니다.
그다음에$ yarn iosxr
iPhone Xʀ Simulator에서 앱을 실행합니다.
저는 그것을 위한 CLI 툴을 개발했습니다."rndcli"를 입력하고 장치를 선택하면 됩니다.
https://github.com/nazrdogan/rndcli
기본 장치를 변경하고 싶고 react-native run-ios만 실행해야 한다면 finder에서 키워드 "runios"를 검색하여 폴더를 열고 index.js 파일을 필요한 장치로 'iphone X'iphone X'를 변경할 수 있습니다.
: https://i.stack.imgur.com/BCtR1.png
첫 번째 경우:
로그인 화면에서 발생했습니다.autoFocus
에.TextInput
그 말을 듣고 모든 것이 정상으로 돌아왔습니다.
두 번째 경우:
엑스포와 함께!
XCode 업데이트 후 항상 iPhone 12 Max 시뮬레이터를 사용했지만 iPhone 8을 선호했습니다.제가 취한 조치는 다음과 같습니다.
- 시뮬레이터가 포커스에 있는 동안 다음으로 이동합니다.
File -> Open Simulator
기본값으로 설정할 항목을 선택합니다. - 이전 시뮬레이터를 닫고,
localhost:19002
터미널에서 서버를 중지합니다.ctr + C
. - 달려.
npm start
를 누릅니다.i
.
이제 당신이 열어둔 시뮬레이터에서 실행되고 있습니다.
해피 코딩!
RN 0.64.2의 경우, 구성은 다음 위치에 있습니다.node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
파일의 기본 시뮬레이터를 수정하면 됩니다.
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js의 라인 코드 변경
55호선
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== true
) {
continue;
}
다음을 대체합니다.
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== true
) {
continue;
}
언급URL : https://stackoverflow.com/questions/37328942/react-native-change-default-ios-simulator-device
'programing' 카테고리의 다른 글
분기 기준 변경 (0) | 2023.05.21 |
---|---|
각도 2 - 모델 변경 후 뷰가 업데이트되지 않음 (0) | 2023.05.21 |
su를 사용하여 나머지 bash 스크립트를 해당 사용자로 실행하려면 어떻게 해야 합니까? (0) | 2023.05.21 |
급여표에서 세 번째 또는 네 번째 최대 급여를 찾는 방법은 무엇입니까? (0) | 2023.05.21 |
Visual Studio에서 zure 함수를 게시하는 동안 오류 발생 (0) | 2023.05.21 |