Closed HarryGwinnell closed 3 years ago
+1
React Native and Flipper currently rely on Folly https://github.com/facebook/folly/tree/v2020.01.13.00 and https://github.com/facebook/folly/tree/vv2020.04.06.00 respectfully, this bug was fixed in https://github.com/facebook/folly/commit/8477e25603f131c0400b6964609c76b438826788 and released in https://github.com/facebook/folly/tree/v2021.03.08.00.
As a workaround I backported the commit to the v2020.01.13.00
release here: https://github.com/indaq-cloud/folly, and you can change your RCT-Folly podspec locally to source from that repository and disable Flipper.
Pod::Spec.new do |spec|
spec.name = 'RCT-Folly'
spec.version = '2020.01.13.00'
spec.license = { :type => 'Apache License, Version 2.0' }
spec.homepage = 'https://github.com/facebook/folly'
spec.summary = 'An open-source C++ library developed and used at Facebook.'
spec.authors = 'Facebook'
spec.source = { :git => 'https://github.com/indaq-cloud/folly.git',
:tag => "v#{spec.version}" }
...
@HarryGwinnell Were you able to solve this issue?
Hi, is this not a big issue? iOS 14.5 will be released next week, and react native cant be built without hacking podspecs.
@HarryGwinnell Were you able to solve this issue?
This is still occurring as far as I can tell. I didn't use the workaround and we have just been avoiding the latest Xcode for the time being (though that will not be an option soon)
Is the solution here just that Flipper and React Native need to bump their Folly dependency? Or is something else needed?
@TheSavior Since it's a low level dependency, we expect the update may need more regression test
I updated Xcode to stable 12.5 and can't build my project now.
ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable
React Native and Flipper currently rely on Folly https://github.com/facebook/folly/tree/v2020.01.13.00 and https://github.com/facebook/folly/tree/vv2020.04.06.00 respectfully, this bug was fixed in facebook/folly@8477e25 and released in https://github.com/facebook/folly/tree/v2021.03.08.00.
As a workaround I backported the commit to the
v2020.01.13.00
release here: https://github.com/indaq-cloud/folly, and you can change your RCT-Folly podspec locally to source from that repository and disable Flipper.Pod::Spec.new do |spec| spec.name = 'RCT-Folly' spec.version = '2020.01.13.00' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' spec.authors = 'Facebook' spec.source = { :git => 'https://github.com/indaq-cloud/folly.git', :tag => "v#{spec.version}" } ...
It works! Thanks 👍
I just downgrade Xcode to stable 12.4. It's work for me. https://developer.apple.com/download/more/
I just downgrade Xcode to stable 12.4. It's work for me. https://developer.apple.com/download/more/
That works for me too.
My temporary workaround:
Comment Flipper lines on Podfile.
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
Run pod install
.
Optional step:
FB_SONARKIT_ENABLED
was not set, causing the app trying to reach for the main.jsbundle
, even though I didn't want it to do so, as I want to use the local Metro server, so I momentarily changed the condition from #ifdef
to #ifndef
on AppDelegate.m
, here:- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
// before: #ifdef FB_SONARKIT_ENABLED
#ifndef FB_SONARKIT_ENABLED
return
[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"
fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main"
withExtension:@"jsbundle"];
#endif
}
I just downgrade Xcode to stable 12.4. It's work for me. https://developer.apple.com/download/more/
it's not a real solution for everyone. I have to work with 12.5 since my device is with iOS 14.5
+1
I cannot build my project without hacking the podfiles or downgrading xcode.
Same problem. I can't build anymore on stable 12.5. I can't work with 12.4 since my devices are on iOS 14.5
After trying @rdsedmundo workaround, I still got the error until disabling hermes.
:hermes_enabled => false
After disabling hermes it also worked for me. With the other workaround I still got the error like @allenmackley.
If someone wants to send a PR to update Folly, that would be greatly appreciated.
You can use this PR as an example from when @Kudo upgraded it previously: https://github.com/facebook/react-native/pull/27810.
The biggest challenge is probably updating third-party-podspecs/Folly.podspec
and making sure RNTester still builds.
Here's a patch-package patch that seems to work with Hermes on iOS after purging build / Pods and reinstalling
This is based on the fork @dotconnor made (:trophy: @dotconnor !)
I do not use Flipper but have been using Hermes on iOS and I could not build without this.
File is patches/react-native+0.64.0.patch
in my react-native project
diff --git a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
index cacafb8..c8ea92f 100644
--- a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
+++ b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
@@ -10,8 +10,8 @@ Pod::Spec.new do |spec|
spec.homepage = 'https://github.com/facebook/folly'
spec.summary = 'An open-source C++ library developed and used at Facebook.'
spec.authors = 'Facebook'
- spec.source = { :git => 'https://github.com/facebook/folly.git',
- :tag => "v#{spec.version}" }
+ spec.source = { :git => 'https://github.com/indaq-cloud/folly.git',
+ :commit => "660e964e073b65b3a5890819f393daca1e3f8120" } # commit hash for 2020.01.13.00 + fix on fork
spec.module_name = 'folly'
spec.header_mappings_dir = '.'
spec.dependency 'boost-for-react-native'
@TheSavior perhaps Folly folks could be convinced to branch from the current RN dependency release point of 2020.01.13.00
and commit the same fix (that appears to work above :point_up: ) and re-tag as a 2020.01.13.01
or similar at which point a cherry-pick to release-0.64 would be trivial to contemplate ?
Hello, My temporary workaround is to change the Command Line Tools
to a previous version on Xcode 12.5.
As moving forward is going to be necessary anyways, a PR to React Native bumping it to the latest Folly release is probably best.
As moving forward is going to be necessary anyways, a PR to React Native bumping it to the latest Folly release is probably best.
I did start a quick fork to bump to the latest package and see what issues would pop up. Looks like a bump to flipper-folly will also be needed, as they also rely on the non-functional version of Folly
React Native and Flipper currently rely on Folly https://github.com/facebook/folly/tree/v2020.01.13.00 and https://github.com/facebook/folly/tree/vv2020.04.06.00 respectfully, this bug was fixed in facebook/folly@8477e25 and released in https://github.com/facebook/folly/tree/v2021.03.08.00.
As a workaround I backported the commit to the
v2020.01.13.00
release here: https://github.com/indaq-cloud/folly, and you can change your RCT-Folly podspec locally to source from that repository and disable Flipper.Pod::Spec.new do |spec| spec.name = 'RCT-Folly' spec.version = '2020.01.13.00' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' spec.authors = 'Facebook' spec.source = { :git => 'https://github.com/indaq-cloud/folly.git', :tag => "v#{spec.version}" } ...
Diasabling Flipper won't work for devs that use Firebase because it seems Firebase relies on it. At least for me, when I disabled Flipper, AppDelegate.m won't recognize when I import Firebase. :(
+1
@gcrozariol +1
** BUILD FAILED **
The following build commands failed:
CompileC /Users/#####/Library/Developer/Xcode/DerivedData/app-guuqrbjffbrgdsetejjriypxvdfd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/#####/Development/ReactNative/app-dir/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Here is my Podfile :
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'app' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
##to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
##Pods for app
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
target 'appTests' do
inherit! :complete
# Pods for testing
end
use_native_modules!
pod 'ReactNativeART', :path => '../node_modules/@react-native-community/art'
##Enables Flipper.
##Note that if you have use_frameworks! enabled, Flipper will not work and
##you should disable these next few lines.
use_flipper!
post_install do |installer|
react_native_post_install(installer)
end
end
target 'SkyMD-tvOS' do
##Pods for SkyMD-tvOS
target 'SkyMD-tvOSTests' do
inherit! :search_paths
##Pods for testing
end
end
"react": "17.0.1",
"react-native": "0.64.0",
Xcode Version 12.5 (12E262)
Node Version 14.16.1
1) use_flipper!({"Flipper": "latest version"})
2) use_flipper!({"Flipper-Folly": "latest version"})
3) commented use_flipper!
all the above steps didn't fix the error.
For all those steps I deleted the pod-lock file and did pod install.
+1
Diasabling Flipper won't work for devs that use Firebase because it seems Firebase relies on it. At least for me, when I disabled Flipper, AppDelegate.m won't recognize when I import Firebase. :(
react-native-firebase maintainer here :wave: - this is not true. You are likely just importing your firebase inside the ifdefs for flipper instead of outside of them. I specifically disable flipper in my stock react-native-firebase demo script and it works fine. https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh
I'm not saying that's a great solution, just saying what you are seeing is unrelated and others should not worry about temporarily disabling flipper if they need to.
As moving forward is going to be necessary anyways, a PR to React Native bumping it to the latest Folly release is probably best.
without disagreeing, this will leave all the people on 0.63 etc in the lurch unless/until someone makes a similar fork for the folly version Flipper-Folly needs and people patch that. I'm all in on moving the current state of the art but I'm sensitive to devs stuck in the lurch and was looking for ideas for cherry-picks back on release branches if possible is all
I'm not against a fix on the old branch of folly that we can patch to older releases. I see and agree with the value there. 0.65 isn't ready to be released yet so we can't strictly move forward. This will have to get fixed for at least 0.64. The challenge is that there isn't a Folly team, so this will need additional support from the community to make happen (by submitting PRs).
react-native-windows has hit a similar problem a few times, where MSVC updates break with older versions of Folly. We try to keep our master branch up to date with Folly, but like what is mentioned, we realistically need to allow some level of support for building older branches.
We transparently do some patching in native build logic to just replace entire files in Folly source. IIRC RN core OSS build logic has similar steps of "download the folly GitHub archive and unzip it", so Android/iOS might be able to use the same approach of mutating the Folly copy. This helps to avoid needing to publish a new version of Folly, without needing to do something user-facing like patch-package.
@mganandraj had previously mentioned it might be challenging to bump Folly in RN for Android at least. Recent versions of it add a dependency on libuv (or maybe it was libevent?), which is apparently decently chunky. Android/iOS build support should hopefully be smoother than UWP though.
Folly also recently added a dependency on fmt
which seems to be separately statically linked. There is likely some work here for OSS build logic as well.
Here's a patch-package patch that seems to work with Hermes on iOS after purging build / Pods and reinstalling
This is based on the fork @dotconnor made (🏆 @dotconnor !)
I do not use Flipper but have been using Hermes on iOS and I could not build without this.
File is
patches/react-native+0.64.0.patch
in my react-native projectdiff --git a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec index cacafb8..c8ea92f 100644 --- a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec +++ b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec @@ -10,8 +10,8 @@ Pod::Spec.new do |spec| spec.homepage = 'https://github.com/facebook/folly' spec.summary = 'An open-source C++ library developed and used at Facebook.' spec.authors = 'Facebook' - spec.source = { :git => 'https://github.com/facebook/folly.git', - :tag => "v#{spec.version}" } + spec.source = { :git => 'https://github.com/indaq-cloud/folly.git', + :commit => "660e964e073b65b3a5890819f393daca1e3f8120" } # commit hash for 2020.01.13.00 + fix on fork spec.module_name = 'folly' spec.header_mappings_dir = '.' spec.dependency 'boost-for-react-native'
I am using Hermes and this solution didn't work. My react native version 0.64, Xcode version 12.5 and currently i need two things to a successful build:
However i want to use Hermes, so i think i will go with "downgrade the Xcode" solution for now. Edit: Ops, it seems Xcode 12.4 does not support IOS 14.5 ? My device is 14.5 so this is not an option anymore. It seems i will keep disabled hermes until you guys deploy a fix.
I solved this issue with this solution: https://github.com/facebook/react-native/issues/31441#issuecomment-827585200
Update a finding: Besides the folly version in RCT-Folly.podspec, there is also another folly version listed inside Flipper-Folly. We could try to create a PR for Flipper to update their podspec but that would also require flipper team to push the update to CocoaPods repo.
Wow, https://github.com/facebook/react-native/issues/31441#issuecomment-827585200 seems work. He suggested to patch
{project-name}/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
as
but i also patched
{project-name}/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h
same way.
too. After patched these two files, it worked like a charm with Hermes, React Native 0.64, Xcode 12.5. Without any extra thing. Thanks @robbiemccorkell and also @j2teamlbh , I moved screenshot here, can be seen in pinned issue.
No need to thank me. I lifted it from @j2teamlbh here: https://github.com/facebook/flipper/issues/2215#issuecomment-827422023
Wow, #31441 (comment) seems work. He suggested to patch
{project-name}/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
but i also patched{project-name}/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h
too. After patched these two files, it worked like a charm with Hermes, React Native 0.64, Xcode 12.5. Without any extra thing. Thanks @robbiemccorkell
This is also what I did. App running on ios sim again 👌
Wow, #31441 (comment) seems work. He suggested to patch
{project-name}/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
asbut i also patched
{project-name}/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h
same way. too. After patched these two files, it worked like a charm with Hermes, React Native 0.64, Xcode 12.5. Without any extra thing. Thanks @robbiemccorkell and also @j2teamlbh , I moved screenshot here, can be seen in pinned issue.
Thank you very much.
I've implemented a "automated" way of doing the above Folly patch (inspired by this comment on another issue that we were experiencing):
Add this to your post_install
in your Podfile:
## Fix for Flipper-Folly on iOS 14.5
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_notify_one(state)", "folly::atomic_notify_one(state)")
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
You'll also need to add the function def for this find_and_replace
function:
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
Run pod install
again and it should work. If you get an error relating to permissions while accessing the DistributedMutex-inl.h
file, delete your /pods
folder and run pod install
again
You should see text print out that says Fix: Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
, etc. If you don't, double check the path in the find_and_replace
call.
For others' reference, this is what our full post install looks like now:
post_install do |installer|
flipper_post_install(installer)
## Fix for XCode 12.5 & RN 0.62.2 - See https://github.com/facebook/react-native/issues/28405
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
## Fix for Flipper-Folly on iOS 14.5
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_notify_one(state)", "folly::atomic_notify_one(state)")
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
end
## Fix for Flipper-Folly on iOS 14.5 find_and_replace("pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
I had to change this to find_and_replace("Pods/Flip.... before it worked.
## Fix for Flipper-Folly on iOS 14.5 find_and_replace("pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
I had to change this to find_and_replace("Pods/Flip.... before it worked.
Thanks! Will update for others (mine seems to work both ways)
I've implemented a "automated" way of doing the above Folly patch (inspired by this comment on another issue that we were experiencing):
Add this to your
post_install
in your Podfile:## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
You'll also need to add the function def for this
find_and_replace
function:def find_and_replace(dir, findstr, replacestr) Dir[dir].each do |name| text = File.read(name) replace = text.gsub(findstr,replacestr) if text != replace puts "Fix: " + name File.open(name, "w") { |file| file.puts replace } STDOUT.flush end end Dir[dir + '*/'].each(&method(:find_and_replace)) end
Run
pod install
again and it should work. If you get an error relating to permissions while accessing theDistributedMutex-inl.h
file, delete your/pods
folder and runpod install
againYou should see text print out that says
Fix: Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
, etc. If you don't, double check the path in thefind_and_replace
call.For others' reference, this is what our full post install looks like now:
post_install do |installer| flipper_post_install(installer) ## Fix for XCode 12.5 & RN 0.62.2 - See https://github.com/facebook/react-native/issues/28405 find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules") find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))") ## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)") end
I'm just wondering how these guys are coming up with these solutions. This inspires me to learn more. Thanks
Well I do not have much expectation for fb, but I really learned a lot from them. I do not have the wild wish that I can have that coding skill but wish I can talk like them one day.
"Yes the error are caused by folly, flipper, which are indeed facebook projects. Thanks for reporting. We know how to fix them, but please do not force us to do it in person" "Yes, we love open source and already contributed the best. Some modules may be broken but who cares, it's totally fine on my machine". "Yes we do not have any obligation to fix bugs, add features, answer questions, review and merge prs. We may consider that after we return from a 3-month vacation"
Diasabling Flipper won't work for devs that use Firebase because it seems Firebase relies on it. At least for me, when I disabled Flipper, AppDelegate.m won't recognize when I import Firebase. :(
react-native-firebase maintainer here 👋 - this is not true. You are likely just importing your firebase inside the ifdefs for flipper instead of outside of them. I specifically disable flipper in my stock react-native-firebase demo script and it works fine. https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh
I'm not saying that's a great solution, just saying what you are seeing is unrelated and others should not worry about temporarily disabling flipper if they need to.
Thank you for clarifying!
I've implemented a "automated" way of doing the above Folly patch (inspired by this comment on another issue that we were experiencing):
Add this to your
post_install
in your Podfile:## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
You'll also need to add the function def for this
find_and_replace
function:def find_and_replace(dir, findstr, replacestr) Dir[dir].each do |name| text = File.read(name) replace = text.gsub(findstr,replacestr) if text != replace puts "Fix: " + name File.open(name, "w") { |file| file.puts replace } STDOUT.flush end end Dir[dir + '*/'].each(&method(:find_and_replace)) end
Run
pod install
again and it should work. If you get an error relating to permissions while accessing theDistributedMutex-inl.h
file, delete your/pods
folder and runpod install
againYou should see text print out that says
Fix: Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
, etc. If you don't, double check the path in thefind_and_replace
call.For others' reference, this is what our full post install looks like now:
post_install do |installer| flipper_post_install(installer) ## Fix for XCode 12.5 & RN 0.62.2 - See https://github.com/facebook/react-native/issues/28405 find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules") find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))") ## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)") end
Thanks for this great fix. I modified your find_and_replace
function so the fix only applies on first install (otherwise with every pod install
the fix adds another folly::
prefix like this folly::folly::atomic_notify_one(state)
):
# Define find-and-replace function
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
replaced = text.index(replacestr)
if replaced == nil && text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
I've implemented a "automated" way of doing the above Folly patch (inspired by this comment on another issue that we were experiencing):
Add this to your
post_install
in your Podfile:## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
You'll also need to add the function def for this
find_and_replace
function:def find_and_replace(dir, findstr, replacestr) Dir[dir].each do |name| text = File.read(name) replace = text.gsub(findstr,replacestr) if text != replace puts "Fix: " + name File.open(name, "w") { |file| file.puts replace } STDOUT.flush end end Dir[dir + '*/'].each(&method(:find_and_replace)) end
Run
pod install
again and it should work. If you get an error relating to permissions while accessing theDistributedMutex-inl.h
file, delete your/pods
folder and runpod install
againYou should see text print out that says
Fix: Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
, etc. If you don't, double check the path in thefind_and_replace
call.For others' reference, this is what our full post install looks like now:
post_install do |installer| flipper_post_install(installer) ## Fix for XCode 12.5 & RN 0.62.2 - See https://github.com/facebook/react-native/issues/28405 find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules") find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))") ## Fix for Flipper-Folly on iOS 14.5 find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)") end
Lifesaver!
Besides the wonderful "get everyone back off the ground with a quick HACK" approaches 🙇 , I just wanted to emphasize the need to consider a solution for 0.63.x as well. As mentioned in https://github.com/facebook/react-native/issues/31179#issuecomment-828172879 , we have the upgrade to 0.64 in our roadmap, but first have to address some critical feature role-out and some iOS 14.5 related aspects.
So a proper patch release, would be greatly appreciated for such a fundamental build breaker. Cheers.
EDIT (by @kelset): Please read the current status of things at this comment.
Description
Running the latest Xcode/React Native etc. Upgrading an existing project failed so I tested with a new RN project (npx react-native init TestApp --version 0.64.0 --template react-native-template-typescript). It will build and run under Xcode 12.4, but fails when attempting to build with Xcode 12.5 Beta 3 (12E5244e). It's unlikely to be relevant, but the app is targeting an iPhone 12 Simulator running iOS 14.5
React Native version:
Run
react-native info
in your terminal and copy the results here.Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
cd testApp
yarn install
thencd iOS & pod install
cd ../ & yarn ios
Expected Results
Describe what you expected to happen.
A successful build of the example app, running on the simulator.
Snack, code example, screenshot, or link to a repository:
Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
The following build commands failed: CompileC /Users/harrygwinnell/Library/Developer/Xcode/DerivedData/testApp-hgqgknryyegjzjbbjfnfzrcyijmv/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/harrygwinnell/Desktop/Git.nosync/testApp/testApp/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (1 failure)
This is the error that comes from
yarn ios
. A similar error comes from Xcode.app, reporting an error building flipper-folly.Full console output available on request, but it was too big for pastern.
Xcode.app output is below