question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New RN project will not build on Xcode 12.5 Beta 3

See original GitHub issue

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.

System:
    OS: macOS 11.3
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 224.71 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 15.11.0 - /var/folders/5h/g6n2qyx9781c5lwqmms28gw80000gn/T/yarn--1615999118104-0.9813238427222761/node
    Yarn: 1.22.10 - /var/folders/5h/g6n2qyx9781c5lwqmms28gw80000gn/T/yarn--1615999118104-0.9813238427222761/yarn
    npm: 7.6.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 12.5/12E5244e - /usr/bin/xcodebuild
  Languages:
    Java: javac 14 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
✨  Done in 15.64s.

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Install the above tools, Xcode 12.5 Beta 3, RN 0.64.0 etc.
  2. Create a new app (npx react-native init TestApp --version 0.64.0 --template react-native-template-typescript)
  3. cd testApp
  4. yarn install then cd iOS & pod install
  5. cd ../ & yarn ios
  6. This error also appears if you replace step 4 with launching Xcode.app and building the app that way

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 image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:72
  • Comments:126 (20 by maintainers)

github_iconTop GitHub Comments

70reactions
kelsetcommented, May 5, 2021

Hey folks - here’s the update on this issue.

First off, let me put my hands forward: we will not be doing a release today. It’s Friday afternoon and the next day me and/or @grabbou are available is Wednesday, so it’s not safe to roll out something with the risk of making the life of everyone harder than it is today.

THAT SAID: me and @tido64 spent the entire day trying to localize (and test) viable fixes and I think we got pretty much to the bottom of this - and we need your help to verify that that’s the case.

So, to test our fixes:

If you are on 0.62

  1. add this line to your podfile (or modify it if you already had it):
use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  1. change your package.json react-native dependency from
"react-native": "0.62.2"

to:

"react-native": "facebook/react-native#c6f4611dcbfbb64d5b54e242570e2a1acffcabef"
  1. do all the classic necessary cleans (node_modules, caches, pod folders, etc)(react-native-clean-project is your ally) then do yarn install and a pod install --repo-update (if pod install fails on an error about a Flipper package, just remove the relevant lines from the podfile.lock and run the pod install again)

This should allow you to correctly build RN on Xcode 12.5. Just remember that because you are pointing to an react-native hash (which in this case corresponds to the latest local commit on the 0.62-stable branch), it will make your Android side not work! So, do the changes, test them, then rollback! If Xcode 12.5 build correctly, that’s great and we mean that next week we can do a patch release of 0.62!

If you are on 0.63

If you are on 0.63, you are in luck! You just need to add this line to your podfile (or modify it if you already had it):

use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')

Then properly clean your caches (react-native-clean-project is your ally), remove pods folder and do a pod install --repo-update.

This should be enough for you to get Xcode 12.5 to work.

If you are on 0.64

On 0.64 is when Hermes comes into play, so the process closer to 0.62 - please test this with both Hermes ON and Hermes OFF:

  1. (optional) check your podfile.lock and make sure that Flipper is on 0.75 or higher, and Flipper-Folly is 2.5.3 or higher; if not, add this line to your podfile (or modify it if you already had it):
use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  1. change your package.json react-native dependency from
"react-native": "0.64.0"

to:

"react-native": "facebook/react-native#cf8a364767df830d7255339741350bb53ab1a68a"
  1. do all the classic necessary cleans (node_modules, caches, pod folders, etc)(react-native-clean-project is your ally) then do yarn install and a pod install --repo-update (if pod install fails on an error about a Flipper package, just remove the relevant lines from the podfile.lock and run the pod install again)

This should allow you to correctly build RN on Xcode 12.5. Just remember that because you are pointing to a react-native hash (which in this case corresponds to the latest local commit on the 0.64-stable branch), it will make your Android side not work! So, do the changes, test them, then rollback! If Xcode 12.5 build correctly, that’s great and we mean that next week we can do a patch release of 0.64!


If you are still experiencing issues, it’s likely that they are related to the Swift issue that @smadan was explaining above, so refer to that comment.


Ok folks, this is as far as me and @tido64 could go today - just to be clear: the instructions above should get you to be ✅ again in all cases, we tested them but we want a bigger sample size. Please test according to what described above and let us know - so that next week we can push out the patch releases for 0.62 and 0.64.

59reactions
PottyZAcommented, Apr 28, 2021

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why cant I open xcode projects in Catalina? - Apple Developer
Open Xcode's startup screen (do not open any project yet) · Open Xcode -> Preferences -> Accounts -> Remove the Github account you...
Read more >
React native 0.61.5 Build is failing on Xcode 12.5 beta
I am trying to migrate my project to Xcode 12.5 beta but the problem is that build is failing with message cannot initialise...
Read more >
command `pod install` failed. cause: /bin/bash -c - You.com
Pod Install. [ 1 ] Open terminal and type: sudo gem install cocoapods. Gem will get installed in Ruby inside the System library....
Read more >
Is anyone else finding Xcode 13 nearly unusable? - Reddit
Quit Xcode, clean your derived data folder, do a reboot and re open your project in Xcode.
Read more >
React-Native Ios Build Giving Error On Pod Install. - ADocLib
New RN project will not build on Xcode 12.5 Beta 3 /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found