Xcode14下Fastlane Gym归档报错:modulemap缺失/库未找到
React Native iOS Fastlane Gym归档失败:Module Map文件丢失问题
问题现象
yarn react-native run-ios可正常运行,但执行bundle exec fastlane staging时,Gym的归档步骤报错:
[15:43:43]: ▸ <unknown>:0: error: module map file '/Users/distiller/Library/Developer/Xcode/DerivedData/MyApp-bupcdothwllbfwavuwwinjrmdvlb/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/VisionCamera/VisionCamera.modulemap' not found [15:43:43]: ▸ <unknown>:0: error: module map file '/Users/distiller/Library/Developer/Xcode/DerivedData/MyApp-bupcdothwllbfwavuwwinjrmdvlb/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/YogaKit/YogaKit.modulemap' not found
环境信息
- React Native v0.71.4(从v0.70.7按官方迁移指南升级)
- 已配置Swift桥接头文件
- CI环境:CircleCI
配置文件
Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, min_ios_version_supported prepare_react_native_project! flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'MyApp' do config = use_native_modules! flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :flipper_configuration => flipper_config, :app_path => "#{Pod::Config.instance.installation_root}/.." ) end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings["ONLY_ACTIVE_ARCH"] = 'YES' config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = 'arm64' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' end end installer.pods_project.build_configurations.each do |config| config.build_settings["ONLY_ACTIVE_ARCH"] = 'YES' config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = 'arm64' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' end react_native_post_install( installer, :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) end
Fastfile
default_platform :ios platform :ios do before_all do setup_circle_ci end lane :staging do # Build staging and deploy to testflight sh "yarn env-staging" match(type: "appstore") increment_build_number( xcodeproj: "./ios/MyApp.xcodeproj", build_number: ENV['CIRCLE_BUILD_NUM'] ) gym( clean: true, scheme: "MyApp", project: "./ios/MyApp.xcodeproj", export_method: "app-store", output_directory: "./build-tools/deploy/data" ) pilot( skip_waiting_for_build_processing: true ) end end
排查细节
- Pod生成的
release.xcconfig中,PODS_CONFIGURATION_BUILD_DIR定义为${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME),但归档时该路径下无对应modulemap文件 - 尝试设置
USE_FRAMEWORKS=static后:yarn react-native run-ios报错'VisionCamera/FrameProcessorPlugin.h' file not found- Fastlane Gym报错
RCTAppDelegate.h file not found
- 手动删除xcconfig中modulemap相关配置行后,出现
ld: library not found for -lCocoaAsyncSocket;删除对应LIBRARY_SEARCH_PATHS行又出现ld: framework not found hermes
已尝试的无效操作
- 删除Pods目录、Podfile.lock后重新执行
pod install - 清理Xcode构建产物、DerivedData目录
- 修改Xcode构建目标配置
解决方案(适用于CI的永久方案)
1. 统一Fastlane Gym构建路径
在Gym参数中指定固定构建路径,避免归档时路径不一致:
gym( clean: true, scheme: "MyApp", project: "./ios/MyApp.xcodeproj", export_method: "app-store", output_directory: "./build-tools/deploy/data", build_path: "./ios/build" # 添加此行,统一构建产物路径 )
2. 强制静态框架并修复头文件引用
在Podfile开头设置静态框架,同时在post_install中添加补丁修复头文件问题:
# Podfile开头添加 ENV['USE_FRAMEWORKS'] = 'static' # ... 原有Podfile内容 ... post_install do |installer| # ... 原有post_install代码 ... # 修复VisionCamera和RCTAppDelegate头文件引用 installer.pods_project.targets.each do |target| if target.name == 'VisionCamera' target.build_configurations.each do |config| config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) $(SRCROOT)/../node_modules/react-native-vision-camera/ios/**" end end if target.name == 'MyApp' # 替换为你的主target名称 target.build_configurations.each do |config| config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) $(SRCROOT)/../node_modules/react-native/React/**" end end end # ... 原有post_install代码 ... end
3. CI中确保依赖安装顺序
在Fastlane的staging lane中添加pod install步骤,确保依赖正确安装:
lane :staging do sh "yarn env-staging" sh "cd ios && bundle exec pod install" # 添加此行 match(type: "appstore") increment_build_number( xcodeproj: "./ios/MyApp.xcodeproj", build_number: ENV['CIRCLE_BUILD_NUM'] ) gym(...) pilot(...) end
4. 针对Release构建关闭ONLY_ACTIVE_ARCH
在post_install中,仅Debug模式保留ONLY_ACTIVE_ARCH,Release模式关闭以避免架构缺失:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = 'arm64' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' # 仅Debug模式开启ONLY_ACTIVE_ARCH config.build_settings["ONLY_ACTIVE_ARCH"] = config.name == 'Release' ? 'NO' : 'YES' end end installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = 'arm64' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' config.build_settings["ONLY_ACTIVE_ARCH"] = config.name == 'Release' ? 'NO' : 'YES' end # ... 原有post_install代码 ... end
内容的提问来源于stack exchange,提问作者oaowren
相关产品推荐
相关产品推荐

