如何使用cocoapods和工作区构建React Native项目?

时间:2019-01-30 10:50:41

标签: ios react-native cocoapods xcodebuild

在安装Pods并将工作区添加到我的react native项目之前,请使用以下命令成功构建项目:

xcodebuild -scheme [SchemeName] archive -archivePath ./build/[AppName].xcarchive -allowProvisioningUpdates

我使用CocoaPods安装了RN Firebase,它需要一个xcworkspace来管理软件包。据此,我添加了工作区选项,以允许xcodebuild查找Pods:

-workspace [AppName].xcworkspace

添加此选项后,构建失败,因为找不到main.jsbundle。

Loading dependency graph, done.

SHA-1 for file /Users/nicolas/development/git/availpro.mobile/index.js is not computed

ReferenceError: SHA-1 for file /Users/nicolas/development/git/availpro.mobile/index.js is not computed
    at DependencyGraph.getSha1 (/Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/node-haste/DependencyGraph.js:201:13)
    at /Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/DeltaBundler/Transformer.js:164:26
    at Generator.next (<anonymous>)
    at step (/Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/DeltaBundler/Transformer.js:31:30)
    at /Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/DeltaBundler/Transformer.js:50:14
    at new Promise (<anonymous>)
    at /Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/DeltaBundler/Transformer.js:28:12
    at Transformer.transformFile (/Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/DeltaBundler/Transformer.js:188:7)
    at /Users/nicolas/development/git/availpro.mobile/node_modules/metro/src/Bundler.js:78:34
    at Generator.next (<anonymous>)

+ [[ false != true ]]
+ [[ ! -f /Users/nicolas/Library/Developer/Xcode/DerivedData/AvailproMobile-gewuoxculvshvhehwwobcbkhdzba/Build/Intermediates.noindex/ArchiveIntermediates/AvailproMobile-staging/BuildProductsPath/Release-iphoneos/AvailproMobile.app/main.jsbundle ]]
+ echo 'error: File /Users/nicolas/Library/Developer/Xcode/DerivedData/AvailproMobile-gewuoxculvshvhehwwobcbkhdzba/Build/Intermediates.noindex/ArchiveIntermediates/AvailproMobile-staging/BuildProductsPath/Release-iphoneos/AvailproMobile.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/nicolas/Library/Developer/Xcode/DerivedData/AvailproMobile-gewuoxculvshvhehwwobcbkhdzba/Build/Intermediates.noindex/ArchiveIntermediates/AvailproMobile-staging/BuildProductsPath/Release-iphoneos/AvailproMobile.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2

要快速解决此问题,我会在xcodebuild之前手动生成main.jsbundle:

react-native bundle --entry-file='index.js' --bundle-output='./ios/[AppName]/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'

在我看来,此修补程序比真正的解决方案更有效。

任何人都可以告诉我为什么使用.xcworkspace构建项目时,在生成.xcodeproj生成项目时却不生成main.jsbundle吗?

谢谢!

0 个答案:

没有答案