好吧,这个问题我搞砸了4天,终于用脚本解决了。
设置
- RN 0.61.5 从 0.59.10 升级
- Xcode 11.3.1
- CocoaPods 1.9.3
相关的 npm 包:
"react-native": "0.61.5",
"@react-native-firebase/app": "^8.4.6",
"@react-native-firebase/auth": "^9.3.1",
"@react-native-firebase/crashlytics": "^8.4.11",
"@react-native-firebase/database": "^7.5.12",
"@react-native-firebase/messaging": "^7.9.1",
"react-native-code-push": "6.3.0",
"react-native-config": "1.4.0"
使用的指南和来源:
Pod 文件:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
project 'lend24app',
'Debug' => :debug,
'Release' => :release,
'Staging' => :release,
'Beta' => :release
target 'lend24app' do
use_frameworks!
$RNFirebaseAsStaticFramework = true
# Pods for lendmn
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'RNInputMask', :path => '../node_modules/react-native-text-input-mask/ios/InputMask'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"
pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec"
pre_install do |installer|
installer.analysis_result.specifications.each do |s|
s.swift_version = '4.0' unless s.swift_version
end
# workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # >= 1.9
end
end
end
end
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name == 'Staging' || config.name == 'Beta'
config.build_settings['CONFIGURATION_TEMP_DIR'] = '$(PROJECT_TEMP_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)'
config.build_settings['CONFIGURATION_BUILD_DIR'] = '$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)'
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.name == 'Staging' || config.name == 'Beta'
config.build_settings['CONFIGURATION_TEMP_DIR'] = '$(PROJECT_TEMP_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)'
config.build_settings['PODS_CONFIGURATION_BUILD_DIR'] = '${PODS_BUILD_DIR}/Release$(EFFECTIVE_PLATFORM_NAME)'
end
end
end
end
target 'lend24appTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
此设置是2016年以来一个项目逐步开发的结果,所以项目和实际配置不推荐,最好从头开始!
导致此问题的步骤,所有步骤都无法生成 beta 存档:
- 通过升级命令升级rn
- 使用RN Upgrade helper 修补命令丢失的文件
- 使用上面提到的来自 Code Push 的 guide 创建 Xcode 配置
- 未知...
在旅途中的某个地方,我最终得到了 PODS_CONFIGURATION_BUILD_DIR 构建设置,该设置具有 ${PODS_BUILD_DIR}/Release$(EFFECTIVE_PLATFORM_NAME) for Beta configuration
此时正在运行 Beta 构建,但归档失败并显示 source: unbound variable
每当我将PODS_CONFIGURATION_BUILD_DIR 更改为${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 或者如果我编辑出Podfile 修复相同的PODS_CONFIGURATION_BUILD_DIR 更改构建阶段失败
'React/RCTBridgeDelegate.h' file not found.
通过...frameworks.sh 挖掘很明显Pods 构建输出到Release-iphoneos 文件夹,而由于PODS_CONFIGURATION_BUILD_DIR 设置或类似设置,其余部分在Beta-iphoneos 中,我尝试更改为默认值,但是然后构建甚至在到达这个构建阶段之前就失败了[CP] Embed Pods Frameworks
最后,我只是在此阶段之前使用以下脚本将所有内容从 Release-iphoneos 移动到 Beta-iphoneos:
+ New Run Script Phase
# Type a script or drag a script file from your workspace to insert its path.
if [[ "$CONFIGURATION" == "Debug" ]]; then
exit 0
elif [[ "$CONFIGURATION" == "Release" ]]; then
exit 0
fi
mv $BUILD_DIR/Release$EFFECTIVE_PLATFORM_NAME/* $BUILD_DIR/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME/
在这里有点累,只是想它可能会帮助有类似情况的任何人,希望我能提供更多帮助,欢迎反馈。