OGeek|极客世界-中国程序员成长平台

标题: ios - 架构 x86_64 的 1159 个重复符号 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:52
标题: ios - 架构 x86_64 的 1159 个重复符号

我最近在使用 react-native-maps 时遇到了一个奇怪的问题。尝试通过 xcode 编译应用程序时,出现以下错误

...
ld: 1159 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Whole stacktrace

到目前为止,我已经尝试了所有方法。例如这些帖子 first second

这是我的 Podfile:

platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'

target "__APP_NAME__" do
  react_native_path = "../node_modules/react-native"
  pod "yoga", :path => "#{react_native_path}/ReactCommon/yoga"
  pod 'React', path: '../node_modules/react-native', :subspecs => [
  'Core',
  'RCTActionSheet',
  'RCTGeolocation',
  'RCTImage',
  'RCTLinkingIOS',
  'RCTNetwork',
  'RCTSettings',
  'RCTText',
  'RCTVibration',
  'RCTWebSocket'
  ]

  pod 'GoogleMaps'

  pod 'Firebase/Core', '~> 5.3.0'
  pod 'Firebase/Messaging', '~> 5.3.0'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

我还尝试使用在 react-native-maps 存储库的自述文件中指定的完全相同的 Podfile(结果相同),并尝试删除 -ObjC 标志来自 Other Linker Flags 并导致应用程序构建,但是当我尝试启动它时,它在 main.m 文件中因 Thread 1: signal SIGABRT 而崩溃。 Thread 1: signal SIGABRT

编辑:

在安装 react-native-maps 之前我已将我的 git repo 恢复为重新安装了所有节点模块并尝试重新安装所有 pod(我运行了 thisrm - rf ~/.cocoapods/repos/master && pod setup && pod install) 然后尝试在 xcode 中重建项目,但仍然出现相同的错误。我的播客文件

platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'

target "_APP_" do
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  pod 'Firebase/Core', '~> 5.3.0'
  pod 'Firebase/Messaging', '~> 5.3.0'
end

我现在想知道,我的项目出了什么问题?



Best Answer-推荐答案


所以,经过大约一整天的调试,我找到了应用程序无法构建的原因。如果我在发布此答案之前没有解决它@Christos Koninis 评论会让我找到问题的根本原因。我再次查看日志,发现我一直在使用 React 的两个实例。一个来自 node_modules/,一个来自 ios/pods/。我缺少的是我的 Podfile 中的这个:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Credits

最后我的 Podfile 看起来像这样:

platform :ios, '9.0'

target "_APP_" do
  rn_path = '../node_modules/react-native' # This path is likely to be `../node_modules/react-native` in your own project.
  rn_maps_path = '../node_modules/react-native-maps' # This path is likely to be `../node_modules/react-native-maps` in your own project.

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

   # react-native-maps dependencies
   pod 'react-native-maps', path: rn_maps_path
   pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
   pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
   pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS

  # Firebase
  pod 'Firebase/Core', '~> 5.3.0'
  pod 'Firebase/Messaging', '~> 5.3.0'



end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

关于ios - 架构 x86_64 的 1159 个重复符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52168666/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4