我今天升级到 Xcode 10.2,因为升级后我无法通过 cli 运行 react-native run-ios
:
react-native run-ios --simulator="iPhone X"
Found Xcode workspace a.xcworkspace
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/user/Documents/work/a/a-light-ui/node_modules/react-native/local-cli/cliEntry.js:117:22)
如果我运行xcrun simctl list devices
,所有模拟器都显示(关机)(不可用,未找到运行时配置文件)
:
iPhone X (7AADFA50-7B57-4A40-8434-9A86F345D7ED) (Shutdown) (unavailable, runtime profile not found)
自从将 xcode 升级到 10.2 后,还有其他人遇到过 RN 的这个问题吗?它仍然可以通过 Xcode 工作..但这意味着打开 Xcode。
最佳答案
我是这样解决的;
首先,你需要走这条路
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
然后;
您需要更改此代码
if (!version.startsWith('iOS') && !version.startsWith('tvOS'))
与
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))
希望对你有帮助
引用:https://github.com/facebook/react-native/issues/21498#issuecomment-476621627
关于ios - 自从升级到 Xcode 10.2 我不能再通过 cli 运行 react-native run-ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55363698/