React-native: After upgrading to react-native 0.59 iOS build fails

Created on 13 Mar 2019  ยท  69Comments  ยท  Source: facebook/react-native

๐Ÿ› Bug Report

After updating to react-native 0.59 and trying to build the app for iOS I get the following error:

Build input file cannot be found: '/app/node_modules/react-native/ReactCommon/yoga/yoga/YGFloatOptional.cpp'

What's strange to me is, that I can't find this file here either in the current master: react-native/tree/master/ReactCommon/yoga/yoga (only YGFloatOptional.h)

To Reproduce

We upgraded a mid sized project from 0.57.7 โ†’ 0.59.

Expected Behavior

Build should run through just fine like it did before.

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 2.95 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.1 - /var/folders/1r/ymkpxdlj21lb638kzp4jxvwm0000gn/T/yarn--1552463658468-0.20119758467048565/node
      Yarn: 1.13.0 - /var/folders/1r/ymkpxdlj21lb638kzp4jxvwm0000gn/T/yarn--1552463658468-0.20119758467048565/yarn
      npm: 6.4.1 - /usr/local/Cellar/node@10/10.15.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 24, 25, 27, 28
        Build Tools: 23.0.1, 23.0.3, 24.0.1, 25.0.0, 27.0.3, 28.0.3
        System Images: android-24 | ARM 64 v8a, android-24 | ARM EABI v7a, android-24 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.0 => 0.59.0
Bug Follow Up iOS Locked

Most helpful comment

I got the same issue..., Every time there is some issue with upgrades in react native so tired..

All 69 comments

I have just reproduced this issue with XCode: 10.1 and RN 0.59.0.

EDIT 1: I could reproduce with XCode UI build tool ; but it's working fine with react-native run-ios (make sure to have the latest 2.x cli).
EDIT 2: I managed to make it work with XCode 10.1 by enabling legacy build. Related to #19573

Hmm, I have just upgraded from 0.58.4 to 0.59, cleaned build directories in XCode and I was able to run both debug and archive the app. I am using XCode 10.1.
My upgrade strategy:

  1. Bump dependencies according to most recent stable version.
  2. Walk through each compare in https://github.com/react-native-community/rn-diff-purge and apply it manually.

Wondering if everything might work for me because I had working 0.58.4 and just applied new stuff on top of it?

EDIT: I have also ran npm ci in order to remove my node_modules (just to make sure) and I was still able to build the app from XCode ๐Ÿค”

EDIT2: And I don't have YGFloatOptional.cpp:
Screen Shot 2019-03-13 at 12 55 51

I'm getting the same issue upgrading from 0.57.8 -> 0.59.1.
Looking at a fresh 0.59.1 init there is no YGFloatOptional.cpp file.

Add these lines to your Podfile:

  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'

and run

pod install

@jpudysz Yeah that worked after migrating to cocoapod and opening the XCode project with the .xcworkspace file.
I had to react-native unlink and react-native link bridged libraries so that they use the Podfile instead.

Should legacy (no-cocoapod) linking be deprecated ?

@jpudysz Worked for me too. Surely this can't be the proper solution though right? This seriously bloats the project. Pods/boost-for-react-native is 160.8MB.

Edit: Ok seriously odd, I removed those 3 pods, ran Clean in Xcode and tried to build. This time I didn't get an error while compiling Yoga.

Thanks @jpudysz . Following your solution, I then get the following error:
'folly/Portability.h' file not found in JSBundleType.h

Does anyone know what's going on?

Many thanks.

After trying what feels like pretty much everything, RN standard upgrade, git upgrade tool, applying diff patch I ended up recreating a completely new project and doing the extremely tedious work of rebuilding the code base. They say it'll be better from 0.59 on.. hopefully they're right about that

I just upgraded from 0.59.0 to 0.59.1 and it worked for me
resolved the Yoga issue

I upgraded too but with no luck so far.

I had the exact same issue. The good old rm -rf node_modules && npm i and cleaning the build folders did it for me

After using npm audit fix, my 'react-native' are upgraded automatically to version 0.59 and I can't not build my project.
Solution: Downgrade version to lower one.
npm install react-native@<version>
example : npm install [email protected]

I've tried updating from 0.58.4 manually (following rn-diff-purge changes) but I'm also facing this problem with RN 0.59.0 or 0.59.1

Yeah we had YGFloatOptional.cpp until 0.58 https://github.com/facebook/react-native/blob/0.58-stable/ReactCommon/yoga/yoga/YGFloatOptional.cpp

What the heck is going on here?

Edit
@jpudysz 's solution leads me to another file not found error 'folly/Portability.h' file not found

Got the same issue with 'folly/Portability.h' after upgrading from 0.58.4 to 0.59.0 and 0.59.1

What is weird, is that XCode states after compile that Portability.h is not found, but in the editor, it gets all types define in the header...

image

File failing to compile is RCTJavasScriptLoader.mm in the React library.


CompileC /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTJavaScriptLoader.o /Users/xxx/Projects/xxx/node_modules/react-native/React/Base/RCTJavaScriptLoader.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target: React)
    cd /Users/xxx/Projects/xxx/ios/Pods
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c++14 -stdlib=libc++ -fobjc-arc -fobjc-weak -fmodules -fmodules-cache-path=/Users/xxx/Projects/xxx/ios/build/xxx/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/xxx/Projects/xxx/ios/build/xxx/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-c++11-extensions -DPOD_CONFIGURATION_DEBUG=1 -DDEBUG=1 -DCOCOAPODS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -mios-simulator-version-min=9.0 -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -fobjc-abi-version=2 -fobjc-legacy-dispatch -index-store-path /Users/xxx/Projects/xxx/ios/build/xxx/Index/DataStore -iquote /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/React-generated-files.hmap -I/Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/React-own-target-headers.hmap -I/Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/React-all-non-framework-target-headers.hmap -ivfsoverlay /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/all-product-headers.yaml -iquote /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/React-project-headers.hmap -I/Users/xxx/Projects/xxx/ios/build/xxx/Build/Products/Debug-iphonesimulator/React/include -I/Users/xxx/Projects/xxx/ios/Pods/Headers/Private -I/Users/xxx/Projects/xxx/ios/Pods/Headers/Private/React -I/Users/xxx/Projects/xxx/ios/Pods/Headers/Public -I/Users/xxx/Projects/xxx/ios/Pods/Headers/Public/React -I/Users/xxx/Projects/xxx/ios/Pods/Headers/Public/yoga -I/Users/xxx/Projects/xxx/node_modules/react-native/ReactCommon -I/Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/DerivedSources/x86_64 -I/Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/DerivedSources -F/Users/xxx/Projects/xxx/ios/build/xxx/Build/Products/Debug-iphonesimulator/React -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -include /Users/xxx/Projects/xxx/ios/Pods/Target\ Support\ Files/React/React-prefix.pch -MMD -MT dependencies -MF /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTJavaScriptLoader.d --serialize-diagnostics /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTJavaScriptLoader.dia -c /Users/xxx/Projects/xxx/node_modules/react-native/React/Base/RCTJavaScriptLoader.mm -o /Users/xxx/Projects/xxx/ios/build/xxx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTJavaScriptLoader.o






In file included from /Users/xxx/Projects/xxx/node_modules/react-native/React/Base/RCTJavaScriptLoader.mm:12:
/Users/xxx/Projects/xxx/node_modules/react-native/ReactCommon/cxxreact/JSBundleType.h:

info fatal error:

'folly/Portability.h' file not found

 #include <folly/Portability.h>
          ^~~~~~~~~~~~~~~~~~~~~
 1 error generated.

I got the same issue..., Every time there is some issue with upgrades in react native so tired..

The file seems to be deleted from the yoga project since 13 Dec 2018 and "inlined" into yoga/YGFloatOptional.h: https://github.com/facebook/yoga/commit/96d93f29826257ff6e9bb6c19211adb423029c29

My guess is the reference to ReactCommon/yoga/yoga/YGFloatOptional.cpp is not needed anymore.

Removing the cache and rebuilding the project didn't work for me right away.

So I tried upgrading to React Native 0.59.1 then rebuilding the project. Also didn't work.

However, THEN cleaning my node_modules, cache and build folders and rebuilding the project, did work, using:

rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && npm cache clean --force && npm cache verify && rm -rf ios/build && rm -rf node_modules/ && npm i

So, it seems cache related.

Upgrading to React Native 0.59.1 is maybe not needed, I think a part of the script did the trick for me.

Hope this helps others!

I gave up, I deleted all links to node_modules from Pods file then delete node_modules and build directory and re-installed anything then finally built successfully again.

This is so exhausting.

@jvandenaardweg I think you're right that it's a caching issue.

For me what worked was deleting my Xcode's derived data folder and restarting Xcode.
rm -rf ~/Library/Developer/Xcode/DerivedData

Once I restarted, I attempted a build and it failed and prompted me to close and reopen my xcode workspace. Once I did that, I tried to build again and it worked.

Alright folks, I think this issue is generally about build cache issues from upgrading (from reading the posts ) - so if you have issues, I think it can generally be fixed by:

  • Cleaning Derived data in Xcode
  • rm -rf node_modules; rm -rf Pods then re-install
  • Using react-native upgrade x.y.z

This is pretty much the same for every version, I bet. I would maybe look into making an issue on the react-native-cli about improving this and maybe running some of the commands itself.

Does anyone have a specific reproduction step for this?

I was also seeing the #include <folly/Portability.h> error. The issue in my case were missing subspecs in the podfile.

It builds fine for me with:

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    'RCTImage',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    # Add any other subspecs you want to use in your project
  ]

  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'

"Between react-native 0.57.8 and 0.58.5 there is one big change that was added in the Xcode project is that you have to add JavaScriptCore.Framework to the Linked FrameWorks and Libraries" - from here

PLUS

@jvandenaardweg answer:

rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && npm cache clean --force && npm cache verify && rm -rf ios/build && rm -rf node_modules/ && npm i

Did the work for me.

It's really frustrating as other have said, needing to guess what its breaking a code that was working before.

Also on Android I had to upgrade Build Gradle version to work again.

needing to guess

We know that upgrading has been a long lasting pain for the community so starting v0.59 we have introduced a new flow via the new CLI.

That said we have been writing the breaking changes in the changelog and in the releases tab so there is no real guessing needed.

Anyway, closing since this is clearly related to upgrading - also, in general you can use rn-diff-repo to check for all the necessary steps when upgrading.

Hello,

After lots of digging, I've managed to get why I got the issue. Cleaning the cache and everything didn't fix the problem for me and I was still having the #include .

It was compiling fine for the React project under my project, but failing to compile for the Pods I have.

Even after adding the Folly/glog/DoubleConversion pods, I was still having the problem.

I then amended the React.podspecs file to edit the Core subspec

After adding the Folly reference to the pod_target_xcconfig, it was compiling without any other issues.

ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"  \"$(PODS_ROOT)/Folly\"" }

And here is the full podfile I have

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

target 'CryptoReact' do
  platform :ios, '9.0'

  pod 'CodePush', :path => '../node_modules/react-native-code-push'
  pod 'Firebase/Core', '~> 5.14.0'


  pod 'react-native-sqlite-storage', :path => '../node_modules/react-native-sqlite-storage'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/yoga.podspec'
  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 'react-native-randombytes', :path => '../node_modules/react-native-randombytes'
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
  pod 'RNLocalize', :path => '../node_modules/react-native-localize/ios'
  pod 'react-native-camera', :path => '../node_modules/react-native-camera'
  pod 'RNPermissions', :path => '../node_modules/react-native-permissions'
  pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
  pod 'SwiftyJSON', '4.2.0'
  pod 'Charts', '3.1.1' 
  pod 'Fabric', '~> 1.9.0'
  pod 'Crashlytics', '~> 3.12.0'
  pod 'Firebase/Performance', '~> 5.14.0'
  pod 'Firebase/Auth', '~> 5.14.0'
  pod 'lottie-ios', :path => '../node_modules/lottie-ios'
  pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
  pod 'react-native-webview', :path => '../node_modules/react-native-webview'
  pod 'RNScreens', :path => '../node_modules/react-native-screens'
  pod 'ReactNativeExceptionHandler', :podspec => '../node_modules/react-native-exception-handler/ReactNativeExceptionHandler.podspec'
  pod 'RCTRestart', :path => '../node_modules/react-native-restart/ios'
  pod 'react-native-version-number', :path => '../node_modules/react-native-version-number'
  pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'

  pod 'React', :path => '../node_modules/react-native', :subspec => [
    'Core',
    'ART',
    'cxxreact',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    'RCTImage',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    'RCTPushNotification',
    # Add any other subspecs you want to use in your project
  ]
end

swift4 = ['Charts']

post_install do |installer|
installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    if swift4.include?(target.name)
      config.build_settings['SWIFT_VERSION'] = '4.1'
    end
  end
end
end

I'm in the same situation. I've upgraded from 0.57 to 0.59 following react native diff and everything worked perfectly until I upgraded 0.58.6 to 0.59.

I've tried everything on this thread with no luck, the 'folly/Portability.h' file not found error just doesn't want to go away.

Rolling back to 0.58.6 works perfectly but the moment I update to 0.59.0 or 0.59.1 the error appears.

Edit: I found the file in node_modules/react-native/third-party/folly-2018.10.22.00/folly/Portability.h but it still says it's not there.

I realize that my post was very unclear... Sorry about that. Here is the diff file that should make it more explicit for people having issue with 'folly/Portability.h'

Try making the following modification to nodes_modules/react-native/React.podspec file, at least in my case it has worked ! I can now compile my project and launch it without problems.

diff --git a/node_modules/react-native/React.podspec b/node_modules/react-native/React.podspec

s.subspec "Core" do |ss|
[...]
     ss.header_dir           = "React"
     ss.framework            = "JavaScriptCore"
     ss.libraries            = "stdc++"
-    ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
+    ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"  \"$(PODS_ROOT)/Folly\"" }
   end

Doing what @aaska said plus adding
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'

to the Podfile and pod installing them worked for me.

After using @jpudysz, @jvandenaardweg and @johnryan tips, it build for me also.
Thanks guys!

@th3ac3 that solved the issue for me. Thank you!

none of them worked

@jvandenaardweg I think you're right that it's a caching issue.

For me what worked was deleting my Xcode's derived data folder and restarting Xcode.
rm -rf ~/Library/Developer/Xcode/DerivedData

Once I restarted, I attempted a build and it failed and prompted me to close and reopen my xcode workspace. Once I did that, I tried to build again and it worked.

Thanks, I did that and it worked again.

So after following the upgrade diff to 59.4 (using rn-diff-purge), I still had the same issues as everyone here (YGFloatOptional.cpp error first, and then the folly/Portability.h error). However, none of the solutions worked by itself, so this is what I did to resolve the issues:

# Clean caches/build folder/existing pods
rm -rf node_modules
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ios/build
rm -rf ios/Pods

# Reinstall deps
npm install

Then updated my Podfile to the following:

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

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

  pod 'React', :path => '../node_modules/react-native', subspecs: [
    # Comment out any unneeded subspecs to reduce bundle size.
    'Core',
    'CxxBridge', # --> I was missing Cxxbridge here, may have resolved the issue for me as well
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTCameraRoll',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTPushNotification',
    'RCTSettings',
    'RCTTest',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'RCTLinkingIOS'
  ]

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

  # Third party --> This bit is also new
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'


end

After that I reinstalled the pods

cd ios
pod install

Only then the project started building successfully again

In my case i just forgot to did the step:

if you are an iOS developer, you'll need to manually link JavaScriptCore.framework when upgrading; this can be done via Xcode, and following the steps shown here.

example

after i did that, xcode just compile ok

None of the above worked for me

check this out: https://github.com/facebook/react-native/issues/18408#issuecomment-386696744
it solved the issue for me.

put this in console -> xcrun -k --sdk iphoneos --show-sdk-path
if the answer is
xcrun:_ error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'

then put this sudo xcode-select --switch /Applications/Xcode.app

Then install pod again

This answer worked for me. On top of all the things mentioned above in this thread, I needed re-open the terminal that my metro bundler was running.

downgrade to "react-native": "0.57.4", than it works again

downgrade to "react-native": "0.57.4", than it works again

I don't think downgrading to this version is the best way @miukki. This version (0.59) brings 64-bit support for Android apps and you need it as a future requirement to publish apps (info here).

Hey after approaching all of solutions above i caught another error

ld: warning: directory not found for option '-F/Users/pumeo/Library/Developer/Xcode/DerivedData/GreenPlanet-cekcooliietupofcqlsnkupeolal/Build/Products/Debug-iphonesimulator/React'
ld: framework not found React
clang: error: linker command failed with exit code 1 (use -v to see invocation)

when I inserted the post_install

anyone can help please?
Im using hackintosh

@Pumeo1010, please stay on topic.

On topic: if this issue is closed, what's the resolution? I've tried everything above and got it working somehow (don't know what did the trick). Now I had to re-built and ran into the same issue once again and whatever I try can't get it to work anymore.

Update: finally got it to work again! I'm not entirely sure but I think removing the Xcode derived data, removing Podfile.lock, remove/re-installing the pods-dir, cleaning the Xcode build folder and a system reboot ended up doing the trick.

I am trying to upgrade React Native almost two days from 0.57.8 to 0.59.9. I have tried all the solutions above this comment but still got same errors. Duplicate symbols, headers not found, YGFloatOptional.cpp not found.... I created a new React Native project and then copy my existing project files to the new project and i applied the differences with the help of rn-diff-purge. Again with this way too i got many different build errors and finally I gave up! I love v0.57.8

So after following the upgrade diff to 59.4 (using rn-diff-purge), I still had the same issues as everyone here (YGFloatOptional.cpp error first, and then the folly/Portability.h error). However, none of the solutions worked by itself, so this is what I did to resolve the issues:

# Clean caches/build folder/existing pods
rm -rf node_modules
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ios/build
rm -rf ios/Pods

# Reinstall deps
npm install

Then updated my Podfile to the following:

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

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

  pod 'React', :path => '../node_modules/react-native', subspecs: [
    # Comment out any unneeded subspecs to reduce bundle size.
    'Core',
    'CxxBridge', # --> I was missing Cxxbridge here, may have resolved the issue for me as well
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTCameraRoll',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTPushNotification',
    'RCTSettings',
    'RCTTest',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'RCTLinkingIOS'
  ]

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

  # Third party --> This bit is also new
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'


end

After that I reinstalled the pods

cd ios
pod install

Only then the project started building successfully again

@Hless Hi. I tried your solution. Here is my Podfile

target '..' do
   # this is very important to have!
   rn_path = '../node_modules/react-native'
   pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
   pod 'React', path: rn_path, subspecs: [
     'Core',
     'CxxBridge',
     'RCTActionSheet',
     'RCTAnimation',
     'RCTGeolocation',
     'RCTImage',
     'RCTLinkingIOS',
     'RCTNetwork',
     'RCTSettings',
     'RCTText',
     'RCTVibration',
     'RCTWebSocket'
   ]

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

   pod 'AppCenter/Crashes', '~> 1.12.0'
   pod 'AppCenter/Analytics', '~> 1.12.0'
   pod 'AppCenterReactNativeShared', '~> 1.11.0'
   pod 'Fabric'
   pod 'Crashlytics'
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  platform :ios, '9.0'
  pod 'react-native-webview', :path => '../node_modules/react-native-webview'
  pod 'react-native-document-picker', :path => '../node_modules/react-native-document-picker'

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

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

  pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

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

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

end

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

But this time build fails because of duplicate symbols error. I found this solution and now it builds successfully. But now I have another problem. Once I run the application it crashes immediately. I found the error reason in debug area of Xcode and it is
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTRootView reactTag]: unrecognized selector sent to instance 0x7fbf02c05530'
the solution to this problem is the opposite of the other solution. What a bad upgrading story. :(

Finally I successfully built iOS project and run it on simulator without any errors after hard working on upgrade progress. First I applied diffs with the help of rn-diff-purge then I applied @Hless' solution at the end I faced with duplicate symbols error and by following steps on this solution I fixed them also now project is working correctly.

Resolved with the following :

rm -rf node_modules
rm -rf ios/Pods
rm ios/Podfile.lock 
rm -rf ~Library/Developer/Xcode/DerivedData

Then I reinstalled my dependencies (npm & pod) and it worked :)

rm -rf ~Library/Developer/XCode/DerivedData

the right line will be: rm -rf ~/Library/Developer/Xcode/DerivedData

Every time I encounter a hair-pulling issue with RN giving me some nonsense error message, I go on a desperate github hunt for solutions. Most of the time the solution is delete cache, delete derived data, reopen Xcode, clear build folders etc. Over the years I've put together this bash script that I've added as an npm script in my package.json. Now my first goto solution for most issues is npm run clear.

// package.json
{
  "scripts": {
    "clear": ". scripts/Clear.sh",
  }
}
// scripts/Clear.sh
#!/bin/bash

echo "rm -rf ios/build..."
rm -rf ios/build

echo "rm -rf android/app/build..."
rm -rf android/app/build

echo "Removed all Xcode derived data..."
rm -rf ~/Library/Developer/Xcode/DerivedData

echo "rm -rf lib... (for Flow)"
rm -rf lib

echo "watchman watch-del-all..."
watchman watch-del-all

echo "rm -rf node_modules..."
rm -rf node_modules

echo "npm install..."
npm install

echo "rm -rf $TMPDIR/react-*..."
rm -rf $TMPDIR/react-*

echo "rm -rf $TMPDIR/haste-map-react-native-packager-*..."
rm -rf $TMPDIR/haste-map-react-native-packager-*

PS. And it solved this problem for me too :D

just pod install did work for me

please. downgraded Xcode 10.1

Another react-native link helped me. :(

React Native is unsustainable, 100 resolutions offered for every bug someone encounters. One change and the entire build process, boilerplate and reason to use react native falls apart. How can companies truly add this development process to a product pipeline. ridiculous!!!!

They say it'll be better from 0.59 on.. hopefully they're right about that

@philipaarseth I hope you ate your words when 0.60 came out ๐Ÿ˜†

I have seen this in other threads before, but running the following solved the issue for me:

cd node_modules/react-native/scripts
./ios-install-third-party.sh

I thought this had been fixed in 0.59 or before and I remember seeing it running automatically in some builds, but looks like there are still cases where it's missing.

Definitely worth including in the troubleshooting section of your project, since this is not the first time I see this happening.

Run this command: $ conda deactivate

@jpudysz thanks, it works for me. but why rn yoga build error have relationshop with folly/glog/doubleConversion ?

my error log is :
The following commands produced analyzer issues:
Analyze /Users/superqa/jenkins/workspace/xxxxx-xxxx-iOS-new/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal arm64
Analyze Base/RCTModuleMethod.mm normal arm64
(2 commands with analyzer issues)

Android works really perfectly, just iOS... :-(

The only promising work around might be downgrading RN version unfortunately

It gets fairly difficult when having lots of 3rd party dependencies.

in my case, Xcode just did an automatic update and produced such problem.
what i did to solve the problem was:
cd ios
rm -fr Pods
rm Podfile.lock
pod install

reinstall the Pods and Podfile solved my problem

Delete derived data
cd ios
remove Pods and Podfile.lock
pod install

I've done all of the above steps, gotten the build working, and now I get this error. FWIW I am upgrading from Xcode 10.1 -> 11.1 AND i am upgrading react native from 0.57.8 -> 0.59.9

dyld: Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /Users/par/Library/Developer/CoreSimulator/Devices/2B68242E-D2AF-49A4-9AEA-C320820D8D2F/data/Containers/Bundle/Application/E665681B-C213-42C0-9A51-746B4CA17599/Kismet.app/Kismet
  Reason: image not found

edit: I removed RCTTest from the podfile and it was good after that.

I was also seeing the #include <folly/Portability.h> error. The issue in my case were missing subspecs in the podfile.

It builds fine for me with:

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    'RCTImage',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    # Add any other subspecs you want to use in your project
  ]

  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'

I had an issue getting glog to install, ended up having to issue this command sudo xcode-select --switch /Applications/Xcode.app/ pretty sure because I was running Xcode from a different directory, then moved it into my /Applications directory, and the tooling was all messed up.

@jenskuhrjorgensen your rm command is removing the whole $TMPDIR because of a space you have in there.

@jduffy7 That's probably a bit overkill ๐Ÿ˜„ Thx, it's been corrected!

@jenskuhrjorgensen Thank you!!!!!

Running pod update worked for me.

Any update .. ?

Above solutions did not work, the following helped my project to build again.

cd ios
pod repo update
pod update

After running these commands, I was able to build on xcode but not using react-native run-ios. I then ran these commands (thanks https://github.com/facebook/react-native/issues/23886#issuecomment-509528212):

rm -rf ios/build
rm -rf ~/Library/Developer/Xcode/DerivedData
watchman watch-del-all
rm -rf node_modules
npm install

which helped me build using react-native run-ios again.

@khanguslee I do it but sadly it's won't build

and got this error

* BUILD FAILED *

The following build commands failed:
PhaseScriptExecution [CP] Check Pods Manifest.lock /../ios/build/music/Build/Intermediates.noindex/music.build/Debug-iphonesimulator/music.build/Script-C5D676D55145145333E00AC9.sh
(1 failure)

Showing All Messages
:-1: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

A quick google search with your error message gives me a solution here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aniss picture aniss  ยท  3Comments

oney picture oney  ยท  3Comments

ghost picture ghost  ยท  3Comments

despairblue picture despairblue  ยท  3Comments

lazywei picture lazywei  ยท  3Comments