0

I'm trying to run my first React-Native app on a device but the build always fails with the following error:

ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'

ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'

ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'

ld: warning: ignoring file /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a, file was built for archive which is not the architecture being linked (arm64): /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_RCTBridge", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTBundleURLProvider", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTConvert", referenced from:
      objc-class-ref in libRNGestureHandler.a(RNFlingHandler.o)
      objc-class-ref in libRNGestureHandler.a(RNForceTouchHandler.o)
      objc-class-ref in libRNGestureHandler.a(RNLongPressHandler.o)
      objc-class-ref in libRNGestureHandler.a(RNNativeViewHandler.o)
      objc-class-ref in libRNGestureHandler.a(RNPanHandler.o)
      objc-class-ref in libRNGestureHandler.a(RNGestureHandlerModule.o)
      objc-class-ref in libRNGestureHandler.a(RNGestureHandler.o)
      ...

React directory not found error

A few things up front:

The project runs fine on the XCode emulator.

I am using cocoapods and am trying to run the build from the xcWorkspace instead of project (though the full path of the target is /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/nigh.xcodeproj which confuses me a little).

I've removed and reinstalled node-modules, linked, and done new pod installs.

It looks like all I have to do is add React to the Debug-iphoneos folder, but I'm not sure how to do that or if that's the solution. My first attempt was to make sure React was in the Scheme's Build Targets. It was the first on the list with all boxes checked, except for some reason it said React(missing). Per React Native / Xcode Upgrade and now RCTConvert.h not found I removed React(missing) from the Targets list and attempted to add React again, but React does not even show up in the list. Also, the Pods/Products folder shows libReact.a differently than the other .a files, without the Archive(?) icon:

List of Pod/Products

Here's the podfile:


require_relative '../node_modules/react-native-unimodules/cocoapods'

target 'nigh' do
  # Pods for nigh
  use_frameworks!

    # pod 'AWSCore', '~> 2.12.0'
    pod 'AWSCore', '~> 2.10.2'
    pod 'AWSAppSync', '~> 2.14.2'

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  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 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  pod 'RNReanimated', :podspec => '../node_modules/react-native-reanimated/RNReanimated.podspec'
  pod 'react-native-google-maps', path: '../node_modules/react-native-maps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS

  use_unimodules!


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

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

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

  pod 'react-native-slider', :path => '../node_modules/@react-native-community/slider'

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

  pod 'react-native-cameraroll', :path => '../node_modules/@react-native-community/cameraroll'

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

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

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 commented out the if target.name == "React" block, but the error shows up either way.

Am I right in assuming the problem is that React is not in the scheme's build targets, and if so does anyone know how to include it? If not, does anyone know what the real cause could be/how to fix/work around it?

Ben d'Straw
  • 141
  • 2
  • 9

1 Answers1

0

I believe your issue is come from use_frameworks!, try to remove that line, remove DerivedData, Pods, xcworkspace, Podfile.lock and pod install again.

I got this issue last month when upgrading my RN version. This stupid thing took me 1 weeks to know the issue and 20mins to resolve.

Hope this help

  • Well the bad news is it exploded pretty hard, but the good news is I git reset to an an earlier commit where use_frameworks! is not included in the podfile and now I'm getting a different but similar error on the build: `ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React' ld: library not found for -lReact clang: error: linker command failed with exit code 1 (use -v to see invocation)` Also React is back in the targets but still (missing) – Ben d'Straw Nov 08 '19 at 10:45
  • Yes, I got this one too, don't remember exactly how I resolve it but I do something like remove `libReact.a` from `Linked frameworks and libraries` and add it again. There will be a more error like this for others library but you resolve it by the same way. Watchout your Frameworks folder in XCode, there might some duplicate *.framework, if not so it's ok – Nguyễn Khương Nov 08 '19 at 11:32
  • libReact.a doesn't appear as an option for adding to linked frameworks and libraries, unless I click the add other button and select it from Build/Products/Debug-iphonesimulator/React/libReact.a which seems strange. Doing so gave me the same error, plus one saying: ignoring file /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a, file was built for archive which is not the architecture being linked (arm64): /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a – Ben d'Straw Nov 08 '19 at 12:17
  • It's strange if libReact.a is not appear as an option, check if you already have it in the list, I added it in both `linked libraries and framewoks` and `Framework` folder – Nguyễn Khương Nov 11 '19 at 07:00