架构x86_64

时间:2018-09-04 14:34:26

标签: ios xcode react-native cocoapods

我最近在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(具有相同的结果),并且还尝试从{{1 }},这导致了应用程序的构建,但是当我尝试启动它时,main.m文件中的-ObjC崩溃了。 Thread 1: signal SIGABRT

编辑:

在安装Other Linker Flags之前,我已将git repo还原为重新安装所有节点模块,并尝试重新安装所有pod(我运行thisThread 1: signal SIGABRT),然后尝试重建xcode中的项目,仍然出现相同的错误。我的Podfile

react-native-maps

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

1 个答案:

答案 0 :(得分:1)

因此,经过大约整天的调试,我发现了该应用无法构建的原因。如果我在发布此答案之前没有解决问题,则@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