react-native-background-geolocation: IOS build error duplicate symbols for architecture x86_64

Your Environment

  • Plugin version: 0.5.0-alpha.47
  • Platform: iOS
  • OS version: 12.1
  • Device manufacturer and model: iPhone 8
  • Running in Simulator: yes
  • React Native version: 0.55.4
  • Plugin configuration options: default from README.md example
  • Link to your project: private project, sorry

Context

I have ejected my expo app from SDK30 and then try to manually install your library as described in readme. When I trying to build my application for IOS, I am getting the error:

duplicate symbol _OBJC_IVAR_$_DDLogMessage._threadID in:
    /Users/alekseyrebenkov/Library/Developer/Xcode/DerivedData/--------------------bhfjsybpbrvoqjfqvfadebydyiwd/Build/Products/Debug-iphonesimulator/CocoaLumberjack/libCocoaLumberjack.a(DDLog.o)
    /Users/alekseyrebenkov/Library/Developer/Xcode/DerivedData/--------------------bhfjsybpbrvoqjfqvfadebydyiwd/Build/Products/Debug-iphonesimulator/libRCTBackgroundGeolocation.a(CocoaLumberjack.o)
ld: 116 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

In fact, I have more longer error log, I can give it to you, if it really need.

Expected Behavior

The application built without errors.

Actual Behavior

I am getting the error.

Possible Fix

I don’t know 😦

Steps to Reproduce

I don’t sure because of my app was developing a long time and I don’t know how exactly reproduce my error.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (16 by maintainers)

Most upvoted comments

But it should be possible to hack your app to use lumberjack installed by Expokit.

I would:

  1. delete CocoaLumberjack.h and CocoaLumberjack.m in Libraries/RCTBackgroundGeolocation.xcodeproj screenshot 2018-11-09 at 16 36 13

  2. change import in MaurLogging.h to (look at ExpoKit)

#import "CocoaLumberjack/CocoaLumberjack.h"
  1. change import in FMDBLogger.h to:
#import "CocoaLumberjack/CocoaLumberjack.h"
#import "CocoaLumberjack/DDAbstractDatabaseLogger.h"
  1. for Libraries/RCTBackgroundGeolocation.xcodeproj -> Add Link to Binary with Libraries

add lib or framework CocoaLumberjack (again it depends on ExpoKit)

Edit: step 4. is probably not necessary as Expokit should link CocoaLumberjack framework (or static lib) for you.

@iwantooxxoox I got the same problem and managed to fix it. I got a solution working here. You can add it like this in your package.json: "react-native-mauron85-background-geolocation": "https://github.com/alexbuicescu/react-native-background-geolocation#a295dbba40174d3c428cd437697ab0c1876ea4e6" (instead of "react-native-mauron85-background-geolocation": "0.5.0"). I use this solution with jenkins as I don’t have to do anything manually. If you want a manual fix:

  1. do steps 1, 2 and 3 from this comment
  2. Add ${SRCROOT}/../../../../ios/Pods/Headers/Public to System Header Search Paths on Libraries/RCTBackgroundGeolocation.xcodeproj/BackgroundGeolocation.xcodeproj (see Build Settings tab), same as here but without the trailing /CocoaLumberjack

We need better solution for this. I believe RN team is also looking for universal solution. I’ve already started discussion related to this issue.

https://github.com/react-native-community/discussions-and-proposals/issues/60

This is exactly same error as described here https://github.com/mauron85/react-native-background-geolocation/issues/60/ and also you can find many links on stackoverflow. I’m pretty sure it’s related to background modes and usage descriptions (even though your settings seems ok). Not sure but I see “Required background modes” as string, and IMO it should be array. Try right click on Info.plist -> Edit as source code and check if it’s array

    <key>UIBackgroundModes</key>
    <array>
      <string>location</string>
    </array>

You can also enable same thing in Project -> Capabilities -> Background Modes -> Location Updates

Hi @mauron85, I followed your hack way above, but got ‘CocoaLumberjack/CocoaLumberjack.h’ file not found’, do you have any idea on this? thanks

Edit: I’m a little confused about step4, can you kindly provide details, thanks.