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

Xcode 12.5 troubleshooting guide (RN 0.61/0.62/0.63/0.64) #31480

Closed
kelset opened this issue May 5, 2021 · 147 comments
Closed

Xcode 12.5 troubleshooting guide (RN 0.61/0.62/0.63/0.64) #31480

kelset opened this issue May 5, 2021 · 147 comments
Labels
Contributor A React Native contributor. DX Issues concerning how the developer experience can be improved. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Tool: Xcode Type: Discussion Long running discussion.

Comments

@kelset
Copy link
Contributor

kelset commented May 5, 2021

Hey folks.

This issue wants to be a follow up to #31179; that issue has become really long so opening a new one to try and reduce the noise and confusion around it.

Here is how to fix the Xcode 12.5 iOS build breaks with errors related to "atomic_wait_until is unavailable" (and similar messages).

(sidenote: make sure you are using cocoapods 1.10.x)

If you are on 0.61

Note well: this has only been tested by a few members of the community, not by me, so I can't ensure it will work.

If you are still using RN 0.61, you can refer to this comment #28405 (comment) from @edgarbonillag.

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 to
"react-native": "0.62.3"
  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)

If you are on 0.63

Note well: you need to be on latest 0.63.x release, at the time of writing 0.63.3.

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

  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 to:
"react-native": "0.64.1" // or higher
  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)

These scenario have all been tested and ✅ so if you are still experiencing issues, it's likely that it's caused by some local configuration getting in the way. If that's the case, please refer to this comment by @smadan.


If none of the above helped you, and you can reproduce your issue consistently - even on a freshly init'd project, then post a comment below with how to repro so that this can be investigated further.

@kelset kelset added Platform: iOS iOS applications. Type: Discussion Long running discussion. DX Issues concerning how the developer experience can be improved. Tool: Xcode labels May 5, 2021
@facebook-github-bot facebook-github-bot added the Contributor A React Native contributor. label May 5, 2021
@kelset kelset pinned this issue May 5, 2021
@Dag0n
Copy link

Dag0n commented May 5, 2021

Debugger/DevTools is still not loading with these fixes in place.

info Opening flipper://null/Hermesdebuggerrn?device=React%20Native...
info Opening flipper://null/React?device=React%20Native...

appears in the terminal window but no windows open.
Device M1 Macbook Pro

    "react": "17.0.1",
    "react-native": "0.64.1",
  - Flipper (~> 0.75.1)
  - Flipper-Folly (~> 2.5.3)
  - Flipper-RSocket (1.3.1):

E: If anyone has any workaround that'd be good as idb facebook/idb#649 hasn't been updated to run on M1 and hermes is not supported on iOS simulator.

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue May 5, 2021
…2.5.

Following the outlined solution for projects using RN v0.63, in
facebook/react-native#31480.

The "properly clean your caches" step didn't seem to be necessary
for me, but possibly that's different between environments.

Done without looking for breaking changes (there could be a lot
between Flipper 0.54.0 and 0.75.1) because we don't use Flipper yet
(that's zulip#4255) and we don't have anything like a Flipper config file
for iOS.
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue May 5, 2021
…2.5.

Following the outlined solution for projects using RN v0.63, in
facebook/react-native#31480.

The "properly clean your caches" step didn't seem to be necessary
for me, but possibly that's different between environments.

Done without looking for breaking changes, beyond confirming that
the build succeeds on Xcode 12.5. There could be a lot of breaking
changes between Flipper 0.54.0 and 0.75.1 -- but we don't use
Flipper yet (that's zulip#4255) and we don't have anything like a Flipper
config file for iOS.
@rbackhouse
Copy link

My experience with following the instructions for a 0.62.2 project did not match what I actually had to do

  1. My Podfile did not have a "use_flipper!" call but instead a "add_flipper_pods!" call.
  2. The add_flipper_pods def is embedded in the Podfile.

For it to work I had to

  1. Add require_relative '../node_modules/react-native/scripts/autolink-ios'

  2. Remove the whole "def add_flipper_pods!(versions = {})" block and "def flipper_post_install(installer)" block

  3. Change add_flipper_pods! to add_flipper_pods!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')

With these change project now builds again.

@mikehardy
Copy link
Contributor

Just a note for people running react-native builds on BitRise - it appears that BitRise restores caches as read-only by default and you need to delete the build cache after updating to 0.64.1 before the build will work, but then it will work repeatedly

That guess is based on this evidence

  • the build failed there during the pod post install hook, where the method signatures are patched to fix the build. The specific failure was an rb.sys_open failure with permission denied
  • knowing what the patch release was trying to do (edit files in the Pods directory in the post install hook), and guessing about the read-only restore hypothesis, the cache was deleted
  • rebuild then worked, and subsequent builds worked.

Hope this helps !

gnprice pushed a commit to chrisbobbe/zulip-mobile that referenced this issue May 6, 2021
…2.5.

Following the outlined solution for projects using RN v0.63, in
facebook/react-native#31480.

The "properly clean your caches" step didn't seem to be necessary
for me, but possibly that's different between environments.

Done without looking for breaking changes, beyond confirming that
the build succeeds on Xcode 12.5. There could be a lot of breaking
changes between Flipper 0.54.0 and 0.75.1 -- but we don't use
Flipper yet (that's zulip#4255) and we don't have anything like a Flipper
config file for iOS.
@azuxx

This comment has been minimized.

@teajohnson90

This comment has been minimized.

@drac94

This comment has been minimized.

@phithu

This comment has been minimized.

@kieran-osgood

This comment has been minimized.

@mikehardy

This comment has been minimized.

@SandroMachado

This comment has been minimized.

@angadp

This comment has been minimized.

@angadp

This comment has been minimized.

@uloco

This comment has been minimized.

@barbieri
Copy link
Contributor

@barbieri is there a PR fpossible from your findings or does one already exist?

not yet, will submit and mark it here

@mikehardy
Copy link
Contributor

mikehardy commented Sep 28, 2021

@barbieri fabulous - I'm fairly happy with the current state of the workarounds put in place - as you mention they work (job #1!) but I'm excited to see it improved technically based on your findings. In particular the project.pbxproj file being updated between different architecture macs affects my projects and it seems like you've successfully found the root cause, something I didn't have the obj-c skills to figure out! Kudos

@barbieri
Copy link
Contributor

@mikehardy take a look at #32284 and see if that works for you, it did for me, but I don't have a huge test matrix.

While doing some testing I noticed that CocoaPods version plays a BIG role, using 1.11 will include CocoaPods/CocoaPods@6985cbf and with that we can remove the LIBRARY_SEARCH_PATHS, but older versions CANNOT. My fix works with CocoaPods-1.10.1 as per packages/rn-tester and also 1.11.2 tested in another project of mine.

I also recommend to use rbenv 2.7.4 installed WITHOUT ROSETTA2 and Gemfile.lock with PLATFORMS: ruby to avoid ping-pong with various architectures and macOS versions. Example:

Gemfile

source "https://rubygems.org"

ruby "2.7.4"

gem "cocoapods", "~> 1.11"

Gemfile.lock


GEM
  remote: https://rubygems.org/
  specs:

...

PLATFORMS
  ruby

DEPENDENCIES
  cocoapods (~> 1.11)

RUBY VERSION
   ruby 2.7.4p191

BUNDLED WITH
   2.2.28

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Oct 1, 2021
Done with Xcode Version 13.0 (13A233).

I got two errors while trying to build:

  Undefined symbol: __swift_FORCE_LOAD_$_swiftDataDetection
  Undefined symbol: __swift_FORCE_LOAD_$_swiftFileProvider

The root cause is reportedly [1] a bug in Xcode. The line with
`swift-5.0` in LIBRARY_SEARCH_PATHS, removed in this commit, leads
to a "Mach-O universal binary" that mistakenly omits the arm64
architecture, which reportedly causes this compilation failure.

facebook/react-native@a1c445a39, as yet unreleased, removes that
line from LIBRARY_SEARCH_PATHS in the template app. [2]

The other interesting line in LIBRARY_SEARCH_PATHS, the one with
just `swift`, doesn't have that bug.

But we go ahead and remove all of LIBRARY_SEARCH_PATHS, just because
that commit says it wants to.

They say they don't do that because it's supposedly not possible
without also upgrading to CocoaPods v1.11, which has
CocoaPods/CocoaPods@6985cbf7d. While RN figures out whether they can
or should require a minimum CocoaPods version, I notice that we seem
to have no trouble upgrading CocoaPods ourselves, so we might as
well.

[1] facebook/react-native#31480

[2] It also (with facebook/react-native@51bf55794) marks a
    `react-native` script named
    __apply_Xcode_12_5_M1_post_install_workaround, from
    facebook/react-native@ac4ddec54, as no longer needed. IOW, you
    don't have to call it from your Podfile anymore. But
    facebook/react-native@ac4ddec54 is also unreleased, so we've
    never had to worry about calling that script from our Podfile.
@philippenunes
Copy link

I'm having problems creating a new project. I'm using xcode 12.4 and RN 0.66.0

Anyone going through this that has a solution?

`** BUILD FAILED **

The following build commands failed:
CompileC /Users/nunes/Library/Developer/Xcode/DerivedData/myskills-adevwiplwjactsfyiotfadjdqjju/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/SysUio.o /Users/nunes/Desenvolvimento/ProjetosPessoais/Cursos/Ignite/react-native/1_fundamentos/myskills/ios/Pods/RCT-Folly/folly/portability/SysUio.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)`

@mikehardy
Copy link
Contributor

@philippenunes that's not the error, that's the notice that there was an error, up above somewhere is the actual error. I'm not sure Xcode 12.4 will work with RN0.66? It should but that's untested by me at least. I've definitely tested and seen success with Xcode 12.5.1 and Xcode 13. npx react-native init TestProject --version 0.66.0 && cd TestProject && yarn ios should work...

@philippenunes
Copy link

@philippenunes that's not the error, that's the notice that there was an error, up above somewhere is the actual error. I'm not sure Xcode 12.4 will work with RN0.66? It should but that's untested by me at least. I've definitely tested and seen success with Xcode 12.5.1 and Xcode 13. npx react-native init TestProject --version 0.66.0 && cd TestProject && yarn ios should work...

I had to downgrade RN to 0.63 and change Flipper to use_flipper!({'Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1'})
After many attempts it only worked like that.

@Eafy
Copy link

Eafy commented Dec 18, 2021

Arguments:
/usr/local/Cellar/node/14.8.0/bin/node /usr/local/bin/yarn install

PATH:
/Users/lzj/.rvm/gems/ruby-2.7.0/bin:/Users/lzj/.rvm/gems/ruby-2.7.0@global/bin:/Users/lzj/.rvm/rubies/ruby-2.7.0/bin:/Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk/Contents/Home/bin:/Users/lzj/Library/Android/sdk/tools:/Users/lzj/Library/Android/sdk/platform-tools:/Users/lzj/Library/Android/sdk/ndk-bundle:/Users/lzj/Library/Android/sdk:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/lzj/.rvm/bin:

Yarn version:
1.22.17

Node version:
14.8.0

Platform:
darwin x64

Trace:
Error: https://registry.npmmirror.com/node-notifier/download/node-notifier-5.4.5.tgz: incorrect data check
at Zlib.zlibOnError [as onerror] (zlib.js:180:17)

npm manifest:
{
"name": "react-native-baidu-map-zj",
"version": "1.4.3",
"description": "Baidu Map SDK modules and view for React Native(Android & IOS), support react native 0.57+. 百度地图 React Native 模块,支持 react native 0.57+,已更新到最新的百度地图SDK版本。",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eafy/react-native-baidu-map-zj.git"
},
"keywords": [
"Baidu Map",
"React Native"
],
"author": "Eafy",
"license": "MIT",
"bugs": {
"url": "https://github.com/eafy/react-native-baidu-map-zj/issues"
},
"homepage": "https://github.com/eafy/react-native-baidu-map-zj#readme",
"devDependencies": {
"react": "16.13.1",
"react-native": "^0.63.2"
}
}

yarn manifest:
No manifest

Lockfile:
No lockfile

Error:
error An unexpected error occurred: "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.4.5.tgz: incorrect data check".
info If you think this is a bug, please open a bug report with the information provided in "/Users/lzj/Desktop/Git/react-native-baidu-map-zj/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@mikehardy

This comment has been minimized.

@sccainsa
Copy link

sccainsa commented Feb 8, 2022

Here's my full set of hacks.

  post_install do |installer|
    react_native_post_install(installer)

    # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
        end
      end
      aggregate_target.user_project.save
    end

     # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
    # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end

    # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
    # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
    # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
  end

I'm not sure if this is the proper location, but this is where the workaround points to.

As a note for the implemented workaround included as part of react-native (__apply_Xcode_12_5_M1_post_install_workaround, which is based off of this answer and was updated in 0.67.2, 60cef850bd)

If your path has spaces the 'sed' command will fail with a 'directory not found' exception.

I was able to solve this by removing spaces in my path, reperforming 'pod install' and re-archiving.

@arzel
Copy link

arzel commented Feb 17, 2022

Here's my full set of hacks.

  post_install do |installer|
    react_native_post_install(installer)

    # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
        end
      end
      aggregate_target.user_project.save
    end

     # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
    # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end

    # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
    # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
    # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
  end

I'm not sure if this is the proper location, but this is where the workaround points to.

As a note for the implemented workaround included as part of react-native (__apply_Xcode_12_5_M1_post_install_workaround, which is based off of this answer and was updated in 0.67.2, 60cef850bd)

If your path has spaces the 'sed' command will fail with a 'directory not found' exception.

I was able to solve this by removing spaces in my path, reperforming 'pod install' and re-archiving.

The directory not found exception can be resolved with:

sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h

@arzel
Copy link

arzel commented Mar 10, 2022

Circling back and seeing if anyone has come across this error using Xcode 13

/ios/Pods/Headers/Public/RCT-Folly/folly/string.h:20:10: 'cstdarg' file not found

@amerllica
Copy link

Ridiculously, I cannot create a new project,

macOS: Monterey 12.4 (M1)
Xcode: 13.4 (13F17a)
RN: 0.68.2

I spend all of today and have read all SO and GH and tried every solution. still don't have any success. I cannot bring up Hello World of RN project.

@mikehardy
Copy link
Contributor

Hey @amerllica - here's a script that will not just bring up a hello world, but brings up the hello world and the entire firebase suite all at once: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

Alternatively, you might like the a hello world with react-native-web built in too: https://github.com/criszz77/luna/

Both of those work, I run them from scratch pretty frequently, also with xcode 13.4 / monterey 12.4, on x86-64 and M1

In particular if you look at the make-demo script and it's resulting rnfbdemo project result you'll see all of the little tweaks required. There really aren't that many, and they all have comments

@amerllica
Copy link

amerllica commented May 28, 2022

Really thanks dear @mikehardy, I used the Luna solution, but still I have these issues:

iOS

The following build commands failed:
	CompileC /Users/amerllica/Library/Developer/Xcode/DerivedData/LunaRN-gkpxtiipflbjcvfjxkdgmjcpushl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/arm64/SSLErrors.o /Users/amerllica/WebstormProjects/LunaRN/ios/Pods/Flipper-Folly/folly/io/async/ssl/SSLErrors.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Flipper-Folly' from project 'Pods')

Android

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.

About android, all of my environment is implemented awesomely, react-native doctor shows me everything is ok.

@mikehardy
Copy link
Contributor

@amerllica sorry, quite busy, took a while to see this.

doctor can still tell you everything is okay currently even though it is not. I just finished a PR for that here react-native-community/cli#1552 - you should reject the https://reactnative.dev/docs/environment-setup page for CLI android development on ios and make sure you have JDK11 installed properly so that "java --fulversion" tells you that you have version 11

Not sure why Xcode is failing for you. I just did:

git clone [email protected]:criszz77/luna
cd luna/template
yarn package:install
yarn ios

and it worked? On an M1, all same versions except I'm trialing Xcode 13.4.1 now on that machine.

you can also try this (assuming you cloned out the luna template and are in the template directory) to just run the build without spawning a simulator or whatever

xcodebuild -workspace ios/ProjectName.xcworkspace -scheme ProjectName -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build | xcbeautify

Note that your iOS "error" is not an actual error. It's a "hey, there was an error, go get the error. The actual error will be higher up in the build logs.

@facebook facebook locked as resolved and limited conversation to collaborators Sep 29, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contributor A React Native contributor. DX Issues concerning how the developer experience can be improved. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Tool: Xcode Type: Discussion Long running discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.