Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New RN project will not build on Xcode 12.5 Beta 3 #31179

Closed
HarryGwinnell opened this issue Mar 17, 2021 · 126 comments
Closed

New RN project will not build on Xcode 12.5 Beta 3 #31179

HarryGwinnell opened this issue Mar 17, 2021 · 126 comments
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@HarryGwinnell
Copy link

HarryGwinnell commented Mar 17, 2021

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

@wilsenjaya

This comment has been minimized.

@dotconnor
Copy link

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

@ming-soon

This comment has been minimized.

@nixolas1

This comment has been minimized.

@HarryGwinnell

This comment has been minimized.

@TheSavior

This comment has been minimized.

@sunnylqm

This comment has been minimized.

@Bardiamist

This comment has been minimized.

@mhammerc

This comment has been minimized.

@tanawat-code
Copy link

I just downgrade Xcode to stable 12.4. It's work for me.
https://developer.apple.com/download/more/

@parintorn1902

This comment has been minimized.

@rdsedmundo
Copy link

rdsedmundo commented Apr 27, 2021

My temporary workaround:

  1. 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
  1. Run pod install.

Optional step:

  • Once I disabled Flipper, 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
}

@tamir61

This comment has been minimized.

@omer921

This comment has been minimized.

@MrPoulpy

This comment has been minimized.

@allenmackley

This comment has been minimized.

@felix4321

This comment has been minimized.

@TheSavior

This comment has been minimized.

@mikehardy
Copy link
Contributor

mikehardy commented Apr 27, 2021

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'

@mikehardy

This comment has been minimized.

@jboteros

This comment has been minimized.

@TheSavior

This comment has been minimized.

@HarryGwinnell
Copy link
Author

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

@balwinder4264
Copy link

balwinder4264 commented May 3, 2021

After adding these lines in pod file 'Flipper' => '0.87.0'

Now i am getting following errors: Screen Shot 2021-05-03 at 2 32 46 PM

Edit (by @kelset) to collapse the screenshot.

@mikehardy
Copy link
Contributor

@balwinder4264 this discussion has gotten long enough github is collapsing useful comments unfortunately. So this was discussed above but was hidden and easy to miss.

@smadan wrote up a wonderful summary of all the problems that may occur here #31179 (comment) and the relevant bit for you is (I think)

Once you get past both the above, you'll likely run into a linker error caused by Swift. Undefined symbols for architecture x86_64: "Swift._ArrayBuffer._copyContents..."

This requires you to remove both references to "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" from your project.pbxproj file. You need to have a Swift bridging header and also an empty swift file in your target. I had only the bridging header and not an actual Swift file, which used to work fine, but for some reason didn't suffice any more. I explicitly added an empty Swift file, and that fixed all linking issues. It looks like adding that file simply helped set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES. You could also try setting this directly.

Then you may need npx react-native-clean-project

@kelset
Copy link
Collaborator

kelset commented May 4, 2021

Hey folks, thanks for the feedback! And thanks to everyone who jumped in to help 🤗

@kompfner - thanks! I've updated my comment to use your version since it's more complete :)

@KoreanThinker, yes the fact that it doesn't work on Android is expected! I wrote about that in my previous comment.

I'm catching up with stuff today - probably we'll do the necessary patch releases tomorrow.

@arzel
Copy link

arzel commented May 4, 2021

Xcode 12.5 throw theses errors on a clean RN 0.64 build with Hermes enabled, following the Folly/Flipper hacks.

I'm on Apple Silicon.

In file included from /Users/zel/Desktop/cleanRN/ios/Pods/RCT-Folly/folly/synchronization/Rcu.cpp:17:
In file included from /Users/zel/Desktop/cleanRN/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/Rcu.h:27:
/Users/zel/Desktop/cleanRN/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/detail/ThreadCachedInts.h:71:10: error: thread-local storage is not supported for the current target
  static thread_local Integer* int_cache_;
         ^
/Users/zel/Desktop/cleanRN/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/detail/ThreadCachedInts.h:176:1: error: thread-local storage is not supported for the current target
thread_local typename detail::ThreadCachedInts<Tag>::Integer*
^
In file included from /Users/zel/Desktop/cleanRN/ios/Pods/RCT-Folly/folly/synchronization/Rcu.cpp:17:
In file included from /Users/zel/Desktop/cleanRN/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/Rcu.h:28:
/Users/zel/Desktop/cleanRN/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/detail/ThreadCachedLists.h:110:10: error: thread-local storage is not supported for the current target
  static thread_local TLHead* cache_{nullptr};
         ^
3 errors generated

@woltsu
Copy link

woltsu commented May 4, 2021

We use Hermes (RN 0.64.0) and eventually got it to work with some temporary edits to our Podfile. Our Podfile looks like this now, hopefully it'll help someone out:

# Get latest from: https://github.com/facebook/react-native/blob/master/template/ios/Podfile

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'

platform :ios, '10.0'

# fixes for last Mac updates
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

target 'X' do
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"], :hermes_enabled => true)

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })

  post_install do |installer|
    react_native_post_install(installer)
    # https://stackoverflow.com/a/67308343/10540870
    ## 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)))")

    find_and_replace("Pods/Headers/Private/RCT-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
end

After adding the changes into Podfile, do rm -rf Pods and pod install.

@kelset
Copy link
Collaborator

kelset commented May 4, 2021

@arzel @woltsu did you try the approach I described here? #31179 (comment)

it's not clear by your comments.

@gabimoncha
Copy link

@kelset @smadan your comments helped me a lot! Thank you!
I used them on RN 0.63

@jacquesdev
Copy link

I'm getting this error when using the dependencies suggested above for RN 0.63, ie
use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '~> 1.3')

[!] CocoaPods could not find compatible versions for pod "Flipper-Folly":
  In Podfile:
    Flipper-Folly (= 2.5.3)

    Flipper-RSocket (~> 1.3) was resolved to 1.4.3, which depends on
      Flipper-Folly (~> 2.6)

@woltsu
Copy link

woltsu commented May 4, 2021

@kelset I tried the 0.64 method with Hermes on and off and both seemed to work without any issues, sorry for not mentioning it in my original comment. However, I needed another solution in order to do both iOS and Android development simultaneously

@tido64
Copy link
Collaborator

tido64 commented May 4, 2021

I'm getting this error when using the dependencies suggested above for RN 0.63, ie
use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '~> 1.3')

@jacquesdev: Can you try using specifically 1.3.1? I.e.:

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

daily-autobot pushed a commit to daily-co/react-native-daily-js-playground that referenced this issue May 4, 2021
@jacquesdev
Copy link

@tido64 - thank you, that works!

@BlackForgeOne
Copy link

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

I get

[!] CocoaPods could not find compatible versions for pod "FlipperKit/FlipperKitUserDefaultsPlugin":
  In Podfile:
    FlipperKit/FlipperKitUserDefaultsPlugin (= 0.75.1)

    FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.54.0)

[!] CocoaPods could not find compatible versions for pod "FlipperKit/FBDefines":
  In Podfile:
    FlipperKit/FBDefines (= 0.75.1)

    FlipperKit/FBDefines (~> 0.54.0)

Can I please also confirm whether we are commenting out

use_flipper!
post_install do |installer|
    flipper_post_install(installer)
 end

or not? This issue has taken days off from dev work now.

@jacquesdev
Copy link

@JoeKlimcak

Not sure what version of RN you are on, but to confirm for me on 0.63, I did not have change anything regarding the flipper post install (ie I did not comment it out).

I only added the first line of your comment, ie flipper versions and those two dependencies

@tido64
Copy link
Collaborator

tido64 commented May 5, 2021

@JoeKlimcak You're hitting this issue because you have old versions pinned in Podfile.lock. You can either remove all Flipper related entries in the lock file and re-run pod install, or explicitly specify all packages/versions:

use_flipper!({
  'Flipper' => '0.75.1',
  'Flipper-DoubleConversion' => '1.1.7',
  'Flipper-Folly' => '2.5.3',
  'Flipper-Glog' => '0.3.6',
  'Flipper-PeerTalk' => '0.0.4',
  'Flipper-RSocket' => '1.3.1',
  'FlipperKit' => '0.75.1',
  'FlipperKit/Core' => '0.75.1',
  'FlipperKit/CppBridge' => '0.75.1',
  'FlipperKit/FBCxxFollyDynamicConvert' => '0.75.1',
  'FlipperKit/FBDefines' => '0.75.1',
  'FlipperKit/FKPortForwarding' => '0.75.1',
  'FlipperKit/FlipperKitHighlightOverlay' => '0.75.1',
  'FlipperKit/FlipperKitLayoutPlugin' => '0.75.1',
  'FlipperKit/FlipperKitLayoutTextSearchable' => '0.75.1',
  'FlipperKit/FlipperKitNetworkPlugin' => '0.75.1',
  'FlipperKit/FlipperKitReactPlugin' => '0.75.1',
  'FlipperKit/FlipperKitUserDefaultsPlugin' => '0.75.1',
  'FlipperKit/SKIOSNetworkPlugin' => '0.75.1',
})

@b-derksen
Copy link

b-derksen commented May 5, 2021

@tido64 I have the same error

[!] CocoaPods could not find compatible versions for pod "FlipperKit/CppBridge":
  In Podfile:
    FlipperKit/CppBridge (= 0.75.1)

    FlipperKit/CppBridge (~> 0.54.0)

I already cleaned my podfile.lock, and removed the Pods folder. I tried specifying like in your example but it still crashes. Hopefully we can figure something out.

@kelset
Copy link
Collaborator

kelset commented May 5, 2021

@b-derksen can you try to fully remove the podfile.lock and run pod install --repo-update and check the changes? It seems you haven't removed all the Flipper related lines

@b-derksen
Copy link

@b-derksen can you try to fully remove the podfile.lock and run pod install --repo-update and check the changes? It seems you haven't removed all the Flipper related lines

I deleted the podfile.lock already, also I did pod install --repo-update, I cleaned my caches before, too.

@kelset
Copy link
Collaborator

kelset commented May 5, 2021

Hey folks, update on this: based on all the conversations above it seems that the workaround work well for most scenarios, so we published a new version of 0.62 and 0.64 that will allow you to update easily to them and be able to work again.

Given that it could be that some cases are not being fully solved yet, I've opened this new issue: #31480

so that we can follow up for the cases in which the issue is still happening (this conversation has already over 100+ comments and GitHub is struggling 😅).

Thanks again to everyone for chiming in, hopefully this will be better now 🤞

@kelset kelset closed this as completed May 5, 2021
@facebook facebook locked and limited conversation to collaborators May 5, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests