Taylor Johnson
Taylor Johnson

Reputation: 1953

Undefined symbols for architecture, react native cocoapod issues

I have an existing react native application and I'd like to use react-native link with new dependencies that contain PodSpecs. However, this poses an issue since they each have a dependency on React.

I have added the following within my Podfile:

pod 'React', :path => '../node_modules/react-native'

# Explicitly include Yoga
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

This resolves the dependency problems from the PodSpecs of other modules, but introduces the following new error:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_RCTCxxBridge", referenced from:
     objc-class-ref in libReact.a(RCTBridge.o)
ld: symbol(s) not found for architecture arm64

This error seems to be from the fact that I do not list any of the subspecs for React (specifically, 'CxxBridge'). When I do add CxxBridge to the Podfile, I am forced to add the following dependencies since 'CxxBridge' depends on Folly:

# 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'

I have no problem adding these dependencies, but their source already exists in node_modules/react-native/third-party. I would ideally like to specify the path within the Podfile so I don't have to commit a massive amount of boilerplate code, but have not been able to do so since the source files do not have a PodSpec.

Is there any way to link CxxBridge into the project without having to add the extra code that already exists within node_modules? How have others been using the PodSpecs in third party dependencies (with react-native link)? Would appreciate any help and or Podfile examples

react-native: 0.57.1
xcode: 9.4.1

Upvotes: 3

Views: 1451

Answers (1)

Taylor Johnson
Taylor Johnson

Reputation: 1953

Posting the answer in case anyone else runs into something similar. It turns out that the linked libraries were wrong, since some may have been referencing the libraries in the React project from node_modules, while some may have been referencing the libraries from the React Pod.

Steps to fix:

  • Remove the links to React and any of the subspecs contained within the React project.
  • Remove all previously generated Pod files
  • add post install script to Podfile
  • run pod install
  • link all necessary React dependencies

Post install script:

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

Upvotes: 2

Related Questions