React-native-background-geolocation: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_TSBackgroundFetch", referenced from: objc-class-ref in TSLocationManager(TSLocationManager.o)

Created on 2 May 2019  路  33Comments  路  Source: transistorsoft/react-native-background-geolocation


[UPDATE]: See solution here re: use_frameworks!


Your Environment

  • Platform: iOS
  • OS version:12.2
  • Device manufacturer / model: iPhone X
  • React Native version (react-native -v): 0.58.5
  • Plugin config

Expected Behavior


Project should compile

Actual Behavior


On build, error thrown:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_TSBackgroundFetch", referenced from:
objc-class-ref in TSLocationManager(TSLocationManager.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to Reproduce

  1. Follow Pod Install instructions (including react-native link cocoa-lumberjack)
  2. Attempt to build
  3. Suffer

Context


Build the project.

Most helpful comment

Did you:

$ cd ios
$ pod install

?

All 33 comments

I have linked react-native-background-fetch, as well.

Building RNBackgroundFetch individually succeeds, building RNBackgroundGeolocation fails with the above error.

Did you:

$ cd ios
$ pod install

?

Did that just now, same error:

ld: warning: Could not find auto-linked framework 'TSBackgroundFetch' (<- This was here before, I just missed it with my copy pasta, sorry!)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_TSBackgroundFetch", referenced from:
objc-class-ref in TSLocationManager(TSLocationManager.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Show me your Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'VoximplantDemo' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

rn_path = '../node_modules/react-native'

pod 'React', path: rn_path, subspecs: [
'Core',
'CxxBridge',
'DevSupport',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
]

  # Demo project dependencies
  pod 'react-native-voximplant', path: '../node_modules/react-native-voximplant'
  pod 'react-native-notifications', path: '../node_modules/react-native-notifications'
  pod 'RNCallKit', path: '../node_modules/react-native-callkit'

  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNSecureStorage', :path => '../node_modules/react-native-secure-storage'

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  pod 'RNBackgroundGeolocation', :path => '../node_modules/react-native-background-geolocation'

  pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'React'
        target.build_configurations.each do |config|
          xcconfig_path = config.base_configuration_reference.real_path
          xcconfig = File.read(xcconfig_path)
          new_xcconfig = xcconfig.sub('HEADER_SEARCH_PATHS = $(inherited)', 'HEADER_SEARCH_PATHS = $(inherited) "$(PODS_TARGET_SRCROOT)/ReactCommon/jsiexecutor"')
          File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
        end
      end
      target.build_configurations.each do |config|
        config.build_settings['ENABLE_BITCODE'] = 'NO'
      end
    end
  end

  target 'VoximplantDemoTests' do
    inherit! :search_paths
  end

end

$ cd ios
$ rm Podfile.lock
$ pod install

Show me the entire output of running pod install

Apples-iMac:ios appledeveloper$ rm Podfile.lock
Apples-iMac:ios appledeveloper$ pod install
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `RNBackgroundFetch` from `../node_modules/react-native-background-fetch`
Fetching podspec for `RNBackgroundGeolocation` from `../node_modules/react-native-background-geolocation`
Fetching podspec for `RNCallKit` from `../node_modules/react-native-callkit`
Fetching podspec for `RNSecureStorage` from `../node_modules/react-native-secure-storage`
Fetching podspec for `RNVectorIcons` from `../node_modules/react-native-vector-icons`
Fetching podspec for `React` from `../node_modules/react-native`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/GLog.podspec`
Fetching podspec for `react-native-notifications` from `../node_modules/react-native-notifications`
Fetching podspec for `react-native-voximplant` from `../node_modules/react-native-voximplant`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga`
Downloading dependencies
Using CocoaLumberjack (3.4.2)
Using DoubleConversion (1.1.6)
Using Folly (2018.10.22.00)
Using RNBackgroundFetch (2.5.4)
Using RNBackgroundGeolocation (3.0.2)
Using RNCallKit (1.3.4)
Using RNSecureStorage (0.1.2)
Using RNVectorIcons (6.1.0)
Using React (0.58.5)
Using SocketRocket (0.5.1)
Using VoxImplantSDK (2.18.0)
Using VoxImplantWebRTC (66.0.3)
Using boost-for-react-native (1.63.0)
Using glog (0.3.5)
Using react-native-notifications (1.2.51)
Using react-native-voximplant (1.5.0)
Using yoga (0.58.5.React)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 24 dependencies from the Podfile and 17 total pods installed.

[!] The `VoximplantDemoTests [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-VoximplantDemoTests/Pods-VoximplantDemoTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `VoximplantDemoTests [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-VoximplantDemoTests/Pods-VoximplantDemoTests.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

Boot a new "Hello World" RN app $ react native init Foo.

Set it up in isolation.

And of course this could be causing your issues:

[!] The `VoximplantDemoTests [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-VoximplantDemoTests/Pods-VoximplantDemoTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `VoximplantDemoTests [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-VoximplantDemoTests/Pods-VoximplantDemoTests.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

Here's what my SampleApp shows for Other Linker Flags:

Hrm, the Foo app seemed to build with just the geolocation plugin in isolation. Let me take a look at the other linker flags, maybe something weird with that.

Updating my Other Linker Flags to match yours removed the warning popping up with Pod Install when rerunning the rm Podfile.lock, pod install commands. Still the same error on trying to build, though.馃槗

How about your Framework Search Paths?

Screen Shot 2019-05-02 at 11 59 16 AM

Hrm, mine seems a bit... cluttered, ha. Should it only be the $(inherited)?

Should it only be the $(inherited)?

Yes.

Screen Shot 2019-05-02 at 12 06 06 PM
Same result. 馃槗

Header Search Paths?

I'm beginning to sense a pattern here...馃槄

I've checked the header paths and matched them to yours, still the same result. :cry:

  • Do an XCode -> Product -> Clean
  • Restart XCode.

Same thing 馃槥

Does RNBackgroundFetch appear in /Development Pods as shown below?

Oh, wait: I see the problem in your Podfile:

target 'VoximplantDemo' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!     #<---------- YOU CANNOT USE THIS.  It must be commented out.

Oh, of course. 馃槄
Removing that seems to have removed the error! I'm getting a different run time complaint about CocoaLumberjack, "Library not loaded, reason image not found", but that might be unrelated so I'll go dig around for it.

Actually, let's try a trick I learned from my flutter version.

Manually edit the react-native-background-geolocation .podspec:
node_modules/react-native-background-geolocation/RNBackgroundGeolocation.podspec

.
.
.
Pod::Spec.new do |s|
  .
  .
  .
+s.static_framework = true
end
$ cd ios
$ pod install

After setting this back to what it was:

target 'VoximplantDemo' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!   #<-------- uncomment once again

That also seems to have worked 馃榿Both ways build on my device. 馃帀

Ok, I'm going to add s.static_framework = true to the plugin's .podspec in next release.

But still, you should only use_frameworks! if some 3rd-party module specifically requested it.

I just saw this come across in react-native-firebase, as it has known problems with use_frameworks (owing to the firebase libraries themselves) but FirebaseUI specifically needs it. It appears switching to the legacy build system might make your build work, even though that's not a great workaround it might be worth trying? https://github.com/invertase/react-native-firebase/issues/252#issuecomment-488877222

Adding s.static_framework = true to background-geolocation.podspec should allow it to work with use_frameworks!

What use_frameworks! does is shrink-wraps each Pod into a Cocoa.framework. Unfortunately, the plugin鈥檚 TSLocationManager.framework relies upon being able to reference TSBackgroundFetch.framework. But once RNBackgroundFetch gets shrink-wrapped, it no longer exposes its TSBackgroundFetch.framework to the outside world.

s.static_framework = true seems to fix all that.

I still get error even with latest versions.... XCode 10.3, Node 10.15.3

ld: warning: Could not find auto-linked framework 'TSBackgroundFetch'
Undefined symbol: _OBJC_CLASS_$_TSBackgroundFetch

Here is my POD file...

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'LocationApp' do
  use_frameworks!

  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'AWSCognito'
  pod 'AWSS3'
  pod 'AFNetworking'
  pod 'GoogleMaps'

  target 'FluteTests' do
    inherit! :search_paths
    # Pods for testing
  end
  use_native_modules!
end

Package.json uses "react-native-background-geolocation": "3.2.2",&& "react-native": "0.61.1", which uses s.static_framework = true

Was this page helpful?
0 / 5 - 0 ratings