2

I've been having a strange issue lately with react-native-maps. When trying to compile the app via xcode, I get the following error

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

Whole stacktrace

I have tried everything so far. For example these posts first second

This is my 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

I have also tried to use the exact same Podfile that is specified in the Readme file in the react-native-maps repository (with the same results) and also tried to remove the -ObjC flag from Other Linker Flags and that resulted in the app building but it crashed with Thread 1: signal SIGABRT in main.m file when I tried to launch it. Thread 1: signal SIGABRT

EDIT:

I have reverted my git repo to before installing react-native-maps re-installed all node modules and tried to re-install all pods (I ran this and rm -rf ~/.cocoapods/repos/master && pod setup && pod install) then tried to rebuild the project in xcode and still got the same error. My Podfile

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

I now wonder, what went wrong with my project?

Device
  • 574
  • 4
  • 19
  • What version of Xcode? There was a problem with Xcode 10 beta 5 that caused erroneous duplicate symbol issues when linking libraries built with old Xcode version. – Paul Beusterien Sep 04 '18 at 22:12
  • I'm using xcode version 9.4.1 – Device Sep 05 '18 at 13:11
  • Looking at the build log it seems it tries to link against libReact AND libReact-13cd854a, and that is the cause of your problem. However trying to create an empty app with your Podfile it did not compile, can you try this one. Also can you add a list of all the Pods Project targets and the Pods-HlaseniRozhlasu.debug.xcconfig file? – Christos Koninis Sep 05 '18 at 15:08
  • I posted an answer – Device Sep 05 '18 at 16:27

1 Answers1

3

So, after about a whole day of debugging I found the reason the app was not building. If I didn't solve it before posting this answer @Christos Koninis comment would have lead me to the root cause of the issue. I looked in to the logs once more and saw that I have been using two instances of React. One from node_modules/ and one from ios/pods/. The thing that I was missing was this in my Podfile:

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

Credits

In the end my Podfile looks like this:

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
Device
  • 574
  • 4
  • 19