IT이야기

반응식 런오스가 시뮬레이터를 찾을 수 없음

cyworld 2022. 3. 8. 21:57
반응형

반응식 런오스가 시뮬레이터를 찾을 수 없음

내가 --시뮬레이터 논쟁에 추가하는 시뮬레이터와 상관없이, 나는 '반응-원리 런아이오스'가 시작되지 않는 문제에 직면해 왔다.XCode의 '명령줄 도구' 위치가 올바름

항상 오류가 발생하는 경우: iPhone X 시뮬레이터를 찾을 수 없음

Error: Could not find iPhone X simulator
    at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
    at new Promise (<anonymous>)
    at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
    at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
    at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)

리액터링 정보

>   React Native Environment Info:
>     System:
>       OS: macOS 10.14.2
>       CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
>       Memory: 6.76 GB / 32.00 GB
>       Shell: 3.2.57 - /bin/bash
>     Binaries:
>       Node: 10.15.0 - /usr/local/bin/node
>       Yarn: 1.13.0 - /usr/local/bin/yarn
>       npm: 6.4.1 - /usr/local/bin/npm
>     SDKs:
>       iOS SDK:
>         Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
>     IDEs:
>       Android Studio: 3.1 AI-173.4819257
>       Xcode: 10.1/10B61 - /usr/bin/xcodebuild
>     npmPackages:
>       react: 16.6.3 => 16.6.3 
>       react-native: 0.57.8 => 0.57.8 
>     npmGlobalPackages:
>       create-react-native-app: 1.0.0
>       react-native-cli: 2.0.1
>       react-native-git-upgrade: 0.2.7

갱신하다

v1.9.8로 고정되어 있다.

간편한 솔루션인 Update cli

npm install -g react-native-cli@latest

이 문제는 수정되었지만 아직 발표되지 않았다.https://github.com/react-native-community/react-native-cli/pull/274

그래서 아래 파일을 임시로 수정하여 해결할 수 있다.

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

이 줄 변경

if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {

if (!version.includes('iOS') && !version.includes('tvOS')) {

패키지를 다시 설치할 때 이 기능을 다시 적용하는 것을 잊지 마십시오.

임시방편을 찾았어

다음 파일에서:

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

...42호선을 다음으로 변경:

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('tvOS')) {

터미널에서 이 스크립트 사용

sed -i ''s/startsWith/include/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

자, 뛰어.

react-native run-ios

나는 아래와 같이 노력했다.

개방하다Xcode. 그러면.Preferences-> 선택Components탭에서.

그런 다음 목록에 사용 가능한 시뮬레이터를 하나 이상 설치하십시오.가능하면 최근에 맨 위에 있는 것이 좋다.

그것이 문제를 해결한다.

그냥 해라

npm install

그러면 경고가 표시되고 다음 명령을 사용하여 경고를 수정한다.

npm audit fix

여기 임시 수정사항도 있다.나는 카탈리나를 사용하고 있다.

이 파일:

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

42호선을 다음으로 변경:

if (!version.includes('iOS') && !version.includes('tvOS')) {

라인 52-53을 다음에서 변경:

simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'

다음으로:

simulator.isAvailable !== true

왜냐하면 명령에서 돌아온 json 리스트가xcrun simctl list --json devices, isAvailable 속성은 부울이며 속성 'Availability'가 없었다.

node_modules/react-native/local-cli/runIOS/findMatchSimulator.js에서 findMatchingSimulator.js를 수정하면 된다.

먼저 Simulator를 부팅한 다음 xcrun simctl list --json 장치를 실행하고 "state"가 "Booted"인 장치를 검색하십시오.

그런 다음 findMatchSimulator 기능의 맨 위에 추가하십시오.

return {
udid: <uuid from booted device>, // 'BFA2D7D0-AD49-472F-8279-585DDBBF9151'
name: <Name of the booted simulator>, //"iPhone X"
booted: true,
version: "com.apple.CoreSimulator.SimRuntime.iOS-13-1",

}

62호선을 교체해 해결했다.YourProjectFolder/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

이 선

if (
        simulator.availability !== '(available)' &&
        simulator.isAvailable !== 'YES'
      ) {

이걸로

if (
      !simulator.isAvailable
   ) {

경우에 따라서는 콘솔.log()를 넣어 모든 사용자를 위한 findMatchingSimulator.js 파일을 디버그하기만 하면 시뮬레이터를 감지하지 못하는 이유를 알 수 있다.내 경우에는xcrun simctl list devices --json명령어를 제공하지 않음simulator.availability그리고simulator.isAvailable끈이 아니라 바보야다음 라인을 통해 명령어가 반환되는 시뮬레이터 목록을 인쇄했다.

  console.log(JSON.stringify(simulator.simulatorName));
  console.log(simulator.isAvailable);
  console.log('-------------------------------------------------------------');

after running 명령어react-native run-ios --simulator="iPhone SE"나는 콘솔 인쇄에 따라 단말기와 고정 코드를 받았다.그리고 내 시뮬레이터가 작동하고 있었다.

npm 감사 수정으로 앱을 손상시키지 않으려면 npm 설치 시도 --force

참조URL: https://stackoverflow.com/questions/54507749/react-native-run-ios-can-not-find-any-simulator

반응형