folly: 'folly/experimental/coro/Coroutine.h' file not found after upgrading to > RN 0.74

Currently upgrading to RN 0.75.2 from 0.73.x and encountered the error below on IOS, downgraded to RN 0.74.5 and had the same issue. Extensive research online seems to indicate that “folly/experimental” is deprecated and should no longer be available however it’s still being called somewhere. Not completely sure if this is the issue though. Uninstalling/removing RNBranch still gives the same error

Xcode version 15.3 Pod version 1.15.2 ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]

❌  /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/Oreille-bxxuvxrzbbojtictzbxfgyypfvxf/Build/Intermediates.noindex/ArchiveIntermediates/Oreille/BuildProductsPath/Release-iphoneos/RCT-Folly/folly.framework/Headers/folly/Optional.h:667:10: 'folly/experimental/coro/Coroutine.h' file not found
#include <folly/experimental/coro/Coroutine.h>
                                                           ^
❌  /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/Oreille-bxxuvxrzbbojtictzbxfgyypfvxf/Build/Intermediates.noindex/ArchiveIntermediates/Oreille/BuildProductsPath/Release-iphoneos/RCT-Folly/folly.framework/Headers/folly/Optional.h:667:10: 'folly/experimental/coro/Coroutine.h' file not found
#include <folly/experimental/coro/Coroutine.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❌  /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/Oreille-bxxuvxrzbbojtictzbxfgyypfvxf/Build/Intermediates.noindex/ArchiveIntermediates/Oreille/BuildProductsPath/Release-iphoneos/React-RCTAppDelegate/React_RCTAppDelegate.framework/Headers/RCTAppDelegate.h:8:9: could not build module 'React'
#import <React/RCTBridgeDelegate.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❌  /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/Oreille-bxxuvxrzbbojtictzbxfgyypfvxf/Build/Intermediates.noindex/ArchiveIntermediates/Oreille/BuildProductsPath/Release-iphoneos/react-native-branch/RNBranch.framework/Headers/RNBranch.h:2:9: could not build module 'React'
#import <React/RCTBridgeModule.h>
 ~~~~~~~^
 
 The following build commands failed:
	CompileC /Users/[REDACTED]/Library/Developer/Xcode/DerivedData/Oreille-bxxuvxrzbbojtictzbxfgyypfvxf/Build/Intermediates.noindex/ArchiveIntermediates/Oreille/IntermediateBuildFilesPath/Oreille.build/Release-iphoneos/Oreille.build/Objects-normal/arm64/AppDelegate.o /Users/[REDACTED]/git/ios/Oreille/AppDelegate.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Oreille' from project 'Oreille')
(1 failure)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 18

Most upvoted comments

Adding this to the Podfile works for me, as a way to automate the fix on CI:

post_install do |installer|
  system("chmod -R u+w Pods/RCT-Folly")
  Dir.glob("Pods/RCT-Folly/folly/Portability.h").each do |file|
    text = File.read(file)
    new_contents = text.gsub('#define FOLLY_HAS_COROUTINES 1', '#define FOLLY_HAS_COROUTINES 0')
    File.open(file, "w") { |file| file.puts new_contents }
  end
end

@p29hieu @dylanmaryk I may have fixed it by updating the post_install script

post_install do |installer|
  # ... your other post_install scripts

  # Modify RCT-Folly Portability.h to disable coroutines
  Dir.glob(installer.sandbox.root + "RCT-Folly/folly/Portability.h") do |file|
    begin
      # First try to make the file writable
      system "chmod +w #{file}"
      
      contents = File.read(file)
      modified_contents = contents.gsub(/#define FOLLY_HAS_COROUTINES 1/, '#define FOLLY_HAS_COROUTINES 0')
      
      # Try writing with elevated privileges if needed
      if !File.writable?(file)
        system "sudo chmod +w #{file}"
      end
      
      File.write(file, modified_contents)
      
      # Optionally restore original permissions
      system "chmod -w #{file}"
    rescue => e
      Pod::UI.warn "Failed to modify Portability.h: #{e.message}"
    end
  end
end

same problem, adding “-DFOLLY_CFG_NO_COROUTINES=1” to pbxproj NOT solved the issue

image

Upgrading to react native 0.77 fixes this for me.

0.77 updates RCT-Folly from 2024.01.01.00 to 2024.11.18.00 (here is the diff). Version 2024.11.18.00 has the missing folly/experimental/coro/Coroutine.h file.

I upgraded to React Native 0.77 which builds fine normally, but when trying to integrate the Expo SDK with my RN app I get this:

Image

I’ve confirmed in my Podfile.lock that I’m on 2024.11.18.00, at least that version is present in a lot of places as a dependency like:

    - RCT-Folly (= 2024.11.18.00)

My ios/Pods/folly directory does not contain a coro folder.


I also just created a brand new RN project with:

npx @react-native-community/cli@latest init RNTest

that definitely uses RN 77, and installed cocoapods there, but there is also neither a experimental folder nor a coro folder:

~/Development/RNTest 🦄 ls ios/Pods/RCT-Folly/folly
AtomicHashArray-inl.h		DynamicConverter.h		Indestructible.h		Range.h				Uri.h
AtomicHashArray.h		Exception.h			IndexedMemPool.h		Replaceable.h			Utility.h
AtomicHashMap-inl.h		ExceptionString.h		IntrusiveList.h			ScopeGuard.cpp			Varint.h
AtomicHashMap.h			ExceptionWrapper-inl.h		Lazy.h				ScopeGuard.h			VirtualExecutor.h
AtomicIntrusiveLinkedList.h	ExceptionWrapper.h		Likely.h			SharedMutex.cpp			algorithm
AtomicLinkedList.h		Executor.h			MPMCPipeline.h			SharedMutex.h			base64.h
AtomicUnorderedMap.h		Expected.h			MPMCQueue.h			Singleton-inl.h			chrono
Benchmark.h			FBString.h			MacAddress.h			Singleton.h			concurrency
BenchmarkUtil.h			FBVector.h			MapUtil.h			SingletonThreadLocal.h		container
Bits.h				File.h				Math.h				SocketAddress.h			detail
CPortability.h			FileUtil.cpp			MaybeManagedPtr.h		SpinLock.h			dynamic-inl.h
CancellationToken-inl.h		FileUtil.h			Memory.h			String-inl.h			dynamic.h
CancellationToken.h		Fingerprint.h			MicroLock.h			String.cpp			functional
Chrono.h			FixedString.h			MicroSpinLock.h			String.h			hash
ClockGettimeWrappers.h		FollyMemcpy.h			MoveWrapper.h			Subprocess.h			json
ConcurrentBitSet.h		FollyMemset.h			ObserverContainer.h		Synchronized.h			json.h
ConcurrentLazy.h		Format-inl.h			Optional.h			SynchronizedPtr.h		json_patch.h
ConcurrentSkipList-inl.h	Format.cpp			Overload.h			ThreadCachedInt.h		json_pointer.h
ConcurrentSkipList.h		Format.h			PackedSyncPtr.h			ThreadLocal.h			lang
ConstexprMath.h			FormatArg.h			Padded.h			TimeoutQueue.h			memory
ConstructorCallbackList.h	FormatTraits.h			Poly-inl.h			TokenBucket.h			net
Conv.cpp			Function.h			Poly.h				Traits.h			observer
Conv.h				GLog.h				PolyException.h			Try-inl.h			poly
CppAttributes.h			GroupVarint.h			Portability.h			Try.h				portability
CpuId.h				Hash.h				Preprocessor.h			UTF8String.h			small_vector.h
DefaultKeepAliveExecutor.h	IPAddress.h			ProducerConsumerQueue.h		Unicode.cpp			sorted_vector_types.h
Demangle.cpp			IPAddressException.h		RWSpinLock.h			Unicode.h			stop_watch.h
Demangle.h			IPAddressV4.h			Random-inl.h			Unit.h				synchronization
DiscriminatedPtr.h		IPAddressV6.h			Random.h			Uri-inl.h			system

but there are files that reference that 🤔

~/Development/RNTest 🦄 cat ./ios/Pods/RCT-Folly/folly/Expected.h | grep /coro/
#include <folly/coro/Coroutine.h>

how is that supposed to work? I see the file present in the source for that tag, but it doesn’t seem to be in my system

Edit: I’ve restored the Podfile patch to set FOLLY_HAS_COROUTINES 0 in Portability.h, that builds successfully.

I’have managed to solve this error coming from Optional.h header in RCT-Folly:

  • XCode 15.3
  • ruby 2.7.5p203
  • pod 1.15.2
  • react native 0.72.13

Problem

/Users/<user>/dev/walnuts/ios/Pods/Headers/Public/RCT-Folly/folly/Optional.h:614:10
'folly/experimental/coro/Coroutine.h'
file not found

because of this code with import ./ios/Pods/Headers/Public/RCT-Folly/folly/Optional.h

image

because FOLLY_HAS_COROUTINES is 1 and there is no experimental directory in folly

Solution

Hardcode FOLLY_HAS_COROUTINES to define always to 0 (line 549)

open ./ios/Pods/RCT-Folly/folly/Portability.h
open ./ios/Pods/Flipper-Folly/folly/Portability.h
image

(potentially after this commit)

And also comment some not important assertion:

open ./ios/Pods/Headers/Public/Flipper-Folly/folly/concurrency/CacheLocality.h
image

Pumping react-native-gesture-handler, and react-native-screens versions fixed the issue for me

still same issue

Pumping react-native-gesture-handler, and react-native-screens versions fixed the issue for me

hey @dylanmaryk I’ve implemented the Podfile post_install script and it works locally but when using xcode cloud for example it fails with the 'folly/experimental/coro/Coroutine.h' file not found error.

/Volumes/workspace/repository/ios/Pods/Headers/Public/RCT-Folly/folly/Optional.h:614:10: fatal error: 'folly/experimental/coro/Coroutine.h' file not found #include <folly/experimental/coro/Coroutine.h>

This only happens on the CI/CD part. Do you have any clue on what could it be?

Adding "-DFOLLY_CFG_NO_COROUTINES=1" to pbxproj solved the issue

hey @dylanmaryk I’ve implemented the Podfile post_install script and it works locally but when using xcode cloud for example it fails with the 'folly/experimental/coro/Coroutine.h' file not found error.

/Volumes/workspace/repository/ios/Pods/Headers/Public/RCT-Folly/folly/Optional.h:614:10: fatal error: 'folly/experimental/coro/Coroutine.h' file not found #include <folly/experimental/coro/Coroutine.h>

This only happens on the CI/CD part. Do you have any clue on what could it be?

I got same issue. This only happens on CI/CD. I’m using CircleCI. This is my resource

macos:
    xcode: 15.0.0
resource_class: macos.m1.medium.gen1