React Native iOS build failing for the following e

2019-08-27 03:16发布

问题:

Hi I am trying to build a React Native project on iOS it has react-native-maps with it.

My podfile looks like this

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

target 'APP_NAME' do
    # Pods for APP_NAME
    rn_path = '../node_modules/react-native'
    rn_maps_path = '../node_modules/react-native-maps'

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

    # Pods for APP_NAME
    pod 'Firebase/Core', '~> 5.11.0'
    pod 'Firebase/Firestore', '~> 5.11.0'
    pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
    pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'
    pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
    pod 'Interactable', :path => '../node_modules/react-native-interactable'

    target 'APP_NAME-tvOSTests' do
        inherit! :search_paths
        # Pods for testing
        pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'

    end

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

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


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

    # Pods for APP_NAME-tvOS

    #target 'APP_NAME-tvOSTests' do
 #   inherit! :search_paths
        # Pods for testing
#  end

end

I am getting the below error each time.

I have tried all the solutions listed here Undefined symbols for architecture arm64

But none of them is working for me.

Undefined symbols for architecture arm64:
  "YGConfig::YGConfig(int (*)(YGConfig*, YGNode*, YGLogLevel, char const*, char*))", referenced from:
      _YGConfigNew in libyoga.a(Yoga.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

回答1:

I had similar errors when upgrading React Native to 0.58.6

To fix all the symbol not found errors I had to add/re-add all the libraries with problems in project target Linked frameworks and libraries in xCode:

I also noticed that for RN 0.58 there is no need to have any React or RN dependency in pod file.

More info about my pod file here:

https://stackoverflow.com/a/54999642/1979861

Also check a possible script issue here:

https://stackoverflow.com/a/48953119/1979861