facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.09k stars 24.31k forks source link

After upgrading to react-native 0.59 iOS build fails #23886

Closed dan-lee closed 5 years ago

dan-lee commented 5 years ago

🐛 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
jsamr commented 5 years ago

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

darekg11 commented 5 years ago

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

philipaarseth commented 5 years ago

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.

jpudysz commented 5 years ago

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
jsamr commented 5 years ago

@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 ?

lukefanning commented 5 years ago

@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.

RaphArbuz commented 5 years ago

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.

philipaarseth commented 5 years ago

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

Ericky14 commented 5 years ago

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

RaphArbuz commented 5 years ago

I upgraded too but with no luck so far.

matthias-pichler commented 5 years ago

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

tungduonghgg123 commented 5 years ago

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 react-native@0.57.8

thiagoferolla commented 5 years ago

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

shunsuke1watanabe commented 5 years ago

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

aaska commented 5 years ago

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.
codler commented 5 years ago

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

jvandenaardweg commented 5 years ago

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!

shunsuke1watanabe commented 5 years ago

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.

rob-not-bob commented 5 years ago

@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.

orta commented 5 years ago

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:

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.

rickhanlonii commented 5 years ago

Does anyone have a specific reproduction step for this?

johnryan commented 5 years ago

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'
cassmtnr commented 5 years ago

"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.

kelset commented 5 years ago

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.

aaska commented 5 years ago

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 <folly/Portability.h>.

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
ja-bravo commented 5 years ago

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.

aaska commented 5 years ago

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
ja-bravo commented 5 years ago

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.

diogomgbrito commented 5 years ago

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

weishengwu commented 5 years ago

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

gunduzcihat commented 5 years ago

none of them worked

xtlog commented 5 years ago

@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.

Hless commented 5 years ago

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

pabloearg commented 5 years ago

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

pavermakov commented 5 years ago

None of the above worked for me

lunatolun commented 5 years ago

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

kusakusakusa commented 5 years ago

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.

miukki commented 5 years ago

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

diogomgbrito commented 5 years ago

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).

Pumeo1010 commented 5 years ago

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

HansBouwmeester commented 5 years ago

@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.

tsdmrfth commented 5 years ago

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

tsdmrfth commented 5 years ago

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. :(

tsdmrfth commented 5 years ago

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.

Sangrene commented 5 years ago

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 :)

vforvasile commented 5 years ago

rm -rf ~Library/Developer/XCode/DerivedData

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

jenskuhrjorgensen commented 5 years ago

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

hasgar-aot commented 5 years ago

just pod install did work for me

narendraksp commented 5 years ago

please. downgraded Xcode 10.1

coderdave commented 5 years ago

Another react-native link helped me. :(