从命令行启动React Native应用程序时出错

时间:2018-04-12 19:25:33

标签: react-native

我有一个React Native应用程序,最近升级到React Native 0.55。我之前可以运行命令react-native run-ios --simulator="iPhone X"在模拟器中启动应用程序。现在我不能,但我仍然可以使用build和run在Xcode中运行应用程序。

以下是react-native run-ios --simulator="iPhone X"输出中的错误:

▸ Compiling RCTBundleURLProvider.m

❌  /dev/node_modules/react-native/React/Base/RCTBundleURLProvider.m:15:53: use of undeclared identifier 'undefined'; did you mean 'underline'?

const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
                                                    ^~~~~~~~~~~~~~


▸ Compiling RCTLayoutAnimationGroup.m
▸ Compiling RCTNavigator.m
▸ Compiling RCTTabBar.m
** BUILD FAILED **



The following build commands failed:
    CompileC /dev/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTBundleURLProvider.o Base/RCTBundleURLProvider.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing Build/Products/Debug-iphonesimulator/MyApp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier Build/Products/Debug-iphonesimulator/MyApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

如果有帮助,这里是react-native info的输出:

Environment:
  OS: macOS High Sierra 10.13.3
  Node: 9.5.0
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
  react-native: 0.55.0 => 0.55.0

我的设置有什么问题,我应该如何解决?

1 个答案:

答案 0 :(得分:2)

作为一种解决方法,你应该尝试 react-native run-ios --port 8088RCT_METRO_PORT=8081 react-native run-ios,但不确定是否有效。

在提交33d710e8c58ef1dc69816a59ac1cf390894e7cb9中添加了

RCT_METRO_PORT var,看起来它破坏了版本0.54 / 0.55以从cli运行ios应用程序。

与此同时,我继续使用xcode运行我的react-native应用程序。

希望它可以修补或挑选,或最终修复到下一个主要版本。

关于它有一个开放的GitHub issue