React Native 0.70.6添加相机权限后出现x86_64架构重复符号错误
React Native 0.70.6 添加相机权限后出现
duplicate symbols for architecture x86_64 错误 项目原本运行正常,在通过react-native-permissions添加相机权限的Pod配置后,编译时触发duplicate symbols for architecture x86_64错误。已尝试删除Pods重新生成、删除DerivedData文件夹,问题仍未解决。
当前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, '12.4' install! 'cocoapods', :deterministic_uuids => false target 'JDB_App' do config = use_native_modules! # Flags change depending on the env values. flags = get_default_flags() pod 'Firebase', :modular_headers => true pod 'FirebaseCore', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true $RNFirebaseAsStaticFramework = true permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-Camera', :path => "#{permissions_path}/Camera" use_react_native!( :path => config[:reactNativePath], # Hermes is now enabled by default. Disable by setting this flag to false. # Upcoming versions of React Native may rely on get_default_flags(), but # we make it explicit here to aid in the React Native upgrade process. :hermes_enabled => true, :fabric_enabled => flags[:fabric_enabled], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. :flipper_configuration => FlipperConfiguration.enabled, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'JDB_AppTests' do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install( installer, # Set `mac_catalyst_enabled` to `true` in order to apply patches # necessary for Mac Catalyst builds :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end
解决方法
- 匹配依赖版本:React Native 0.70.6需要对应版本的react-native-permissions,检查package.json中依赖版本是否兼容,必要时调整到适配版本。
- 统一静态库配置:项目中已设置
$RNFirebaseAsStaticFramework = true,需确保权限组件也以静态框架形式引入,避免符号冲突:
方法1:修改相机权限的Pod配置,添加模块化头声明
方法2:在pod 'Permission-Camera', :path => "#{permissions_path}/Camera", :modular_headers => trueuse_native_modules!之前添加全局静态框架配置$PermissionsAsStaticFramework = true - 排查重复引入:执行
npx react-native unlink react-native-permissions,确认没有通过自动link重复引入Permission-Camera模块,之后重新执行pod install。 - 深度清理编译缓存:
- 执行
pod deintegrate彻底移除Pods - 删除项目根目录下的
Podfile.lock文件 - 执行
pod install --repo-update更新依赖 - 打开Xcode,按
Command+Shift+K清理项目,再重新编译
- 执行
内容的提问来源于stack exchange,提问作者Arain001
相关产品推荐
相关产品推荐

