更新到xcode 11.0后无法构建React Native项目

Gan*_*hna 19 xcode core-data ios react-native xcode11

我有一个在React Native版本0.59.8和xcode版本10.3上运行的React Native项目。不知何故,我的xcode已更新到版本11.0,此后,我无法使用react-native run-ios命令构建项目。

我试图清理并再次构建。但这无济于事。

我收到以下错误:

CoreData: annotation:  Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo'
error Could not find iPhone X simulator.
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?

Ale*_*hao 6

不确定第一个错误,但是error Could not find iPhone X simulator升级到XCode 11后,第二个错误也有相同的问题

基本上,我将react native项目中的53行/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.jssimulator.isAvailable !== 'YES'更改为simulator.isAvailable !== true

根本原因是新的XCode 11更改了模拟器元数据格式,并对本机findMatchingSimulator方法作出了强烈反应,使其与以前的格式紧密耦合。

  • @shinlos对于RN 0.59.9,您可以在`node_modules / @ react-native-community / cli / build / commands / runIOS /`中找到此文件。 (3认同)

Gan*_*hna 5

我能够解决“找不到iPhone X模拟器”错误。

这些是解决上述错误的步骤:

运行命令find . -iname findMatchingSimulator.js以找到findMatchingSimulator.js文件。

在此文件中,将代码从

if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') {
        continue;
      }
Run Code Online (Sandbox Code Playgroud)

if (simulator.availability !== '(available)' && simulator.isAvailable !== true) {
        continue;
      }
Run Code Online (Sandbox Code Playgroud)

通过执行此模拟器,错误得以解决。但是另一个错误

CoreData: annotation:  Failed to load optimized model at path '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPackaging.framework/Versions/A/Resources/XRPackageModel.momd/XRPackageModel 9.0.omo'
Run Code Online (Sandbox Code Playgroud)

存在,从而使构建失败。如果我安装xcode 10.3并运行命令react-native run-ios,它仍然可以工作。希望问题解决。在xcode 11中是否有针对此问题的任何修复程序?