facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.26k stars 24.35k forks source link

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

Closed kelset closed 3 years ago

kelset commented 3 years ago

Hey folks.

This issue wants to be a follow up to https://github.com/facebook/react-native/issues/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 https://github.com/facebook/react-native/issues/28405#issuecomment-840914650 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'})
  2. change your package.json react-native dependency to
    "react-native": "0.62.3"
  3. 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'})
  2. change your package.json react-native dependency to:
    "react-native": "0.64.1" // or higher
  3. 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.

xclidongbo commented 3 years ago

one of Flipper-Folly `s dependencies is "OpenSSL-Universal" . version: '1.1.180' is incompatible with 'libssl.a' old version. when I run app, it always crashes with EXC_BAD_ACCESS in Flipper.

How can I fix it?

kelset commented 3 years ago

@xclidongbo I think that error is caused by cocoapods, make sure you are on latest

xclidongbo commented 3 years ago

@xclidongbo I think that error is caused by cocoapods, make sure you are on latest

cocoapods version is 1.10.1

nphivu414 commented 3 years ago

Tried everything for 0.64.1 on XCode 12.5, still no luck. The build keeps failing consistently due to something with FBSDK:

** BUILD FAILED **

The following build commands failed:
  CompileSwift normal x86_64 /ios/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/Swift/Enums+Extensions.swift
  CompileSwift normal x86_64 /ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Swift/FBLoginButton.swift
  CompileSwift normal x86_64 /ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Swift/LoginConfiguration.swift
  CompileSwift normal x86_64 /ios/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Swift/LoginManager.swift
  PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/cass/Library/Developer/Xcode/DerivedData/Speedoc-cpnprerptsolqnbbkqaumsxfhnud/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-AD85DDCBE42B0F530880C262082B23C0.sh
(5 failures)

What's strange is the x86_64 part of the error seems to refer to a problem with M1 MacBooks, but I'm on a MacBook Air 2020 (the Intel version, not the M1). Does anyone else know how to resolve this by any chance?

I got the same problem with my iMac 2017 and this solution works for me: https://github.com/facebookarchive/react-native-fbsdk/issues/794#issuecomment-695217977

ithustle commented 3 years ago

RN 0.64.2, after activated hermes on iOS and no luck.

Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable
yoojeen126 commented 3 years ago

Still build faild on RN 0.63.2, even clean react native project done.

gmonte commented 3 years ago

I created a new project from react-native cli today (react native 0.64.2) and the command react-native run-ios is not working.

error Failed to build iOS project. We ran "xcodebuild" command but it ex
ited with error code 65. To debug build logs further, consider building 
your app with Xcode.app, by opening appTest.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -works
pace appTest.xcworkspace -configuration Debug -scheme appTest -destinati
on id=4B4D293F-C0EB-44FC-B356-4C4E2D794B9A

Well, I tried run the project directly on xcode and it works! But running with react-native cli it fails again. All solutions above does not fix this problem to me.

My environment: MacBook Pro Intel - macOS 11.4 cocoapods 1.10.1 xcode 12.5 - iOS 14.5 react-native 0.64.2

radiosilence commented 3 years ago

Whenever I try to pod install it fails to install glog:


Installing glog (0.3.5)
[!] /opt/homebrew/bin/bash -c 
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif

/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk accepts -g... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk option to accept ISO C89... none needed
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk... gcc3
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk -E
checking whether we are using the GNU C++ compiler... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk accepts -g... yes
checking dependency style of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk... gcc3
checking build system type... 
/Users/jc/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-73c24/missing: Unknown `--is-lightweight' option
Try `/Users/jc/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-73c24/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
Invalid configuration `arm64-apple-darwin20.5.0': machine `arm64-apple' not recognized
configure: error: /bin/sh ./config.sub arm64-apple-darwin20.5.0 failed

Enviroment: Macbook Pro M1 Cocoapods 1.10.1 Xcode 12.5 react-native 0.64.2

I've tried both in a Rosetta Terminal and a Native terminal and they both fail the exact same way.

FIXED! brew uninstall coreutils

oarsoy commented 3 years ago

Although XCode 12.5 and M1 processors available since December 2020, what a shameful for React Native community to not be able to solve this problem!

If someone is looking for a solution with current stable version 0.64.2, all you need to do in Podfile;

  1. delete react_native_post_install line (I don't know why but this command breaks Xcode building as well)
  2. add/update following lines like
...
use_flipper!()
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
...

Facebook literally hates Apple ecosystem. They don't even test with Xcode anymore before releasing new versions. Each versions have different bugs. If someone is starting to React Native recently, I definitely suggest Flutter instead of React Native!

adrianbartyczak commented 3 years ago

Tried to build a new project on Xcode 13 beta. I get this error message:

Screenshot from 2021-06-15 15-15-54

oarsoy commented 3 years ago

Tried a new project on Xcode 13 beta. I get this error message:

Screenshot from 2021-06-15 15-15-54

There are some bugs https://github.com/facebook/react-native/issues/31480#issuecomment-858079368

I didn't try yet with Xcode 13 but the solution in Xcode 12.5 with current stable version 0.64.2, all you need to do in Podfile;

1) delete react_native_post_install line (this command breaks Xcode building) 2) add/update following lines like

...
use_flipper!()
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
...

And after this don't forget to run "pod install".

adrianbartyczak commented 3 years ago

I tried making those changes, but now I get a syntax error:

Screenshot from 2021-06-15 16-40-09

Kaihuang724 commented 3 years ago

@adrianbartyczak It looks like you're missing an end statement for your installer.pods... block. It should look something like this:

use_flipper!({'Flipper' => '0.85.0'})
   post_install do |installer|
     installer.pods_project.build_configurations.each do |config|
         config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
     end
     flipper_post_install(installer)
   end
end
kelset commented 3 years ago

@adrianbartyczak @Kaihuang724 @oarsoy could I kindly ask you to create a new issue to talk about Xcode 13 related issues? I'm slightly concerned issues not strictly related to the workaround described in this post will surface and it'd be better to track them properly.

Kaihuang724 commented 3 years ago

@adrianbartyczak @Kaihuang724 @oarsoy could I kindly ask you to create a new issue to talk about Xcode 13 related issues? I'm slightly concerned issues not strictly related to the workaround described in this post will surface and it'd be better to track them properly.

Sure, no problem. Just FYI, though, I didn't try on Xcode 13 but could never get the workaround to work in 12.5. I ended up downgrading to 12.4

adrianbartyczak commented 3 years ago

Hey @kelset, sure. I didn't realize the issue was different enough for a new thread, so I'll create one.

@Kaihuang724 I tried your fix for the syntax error, and it fixed it, however when I build the app, I still get the same error.

Base29 commented 3 years ago

3. add_flipper_pods

@rbackhouse ... I have RN version 0.62.0 and tried your solution but I had no luck. Below is the error message that I get.

[!] Invalid `Podfile` file: undefined method `add_flipper_pods!' for #<Pod::Podfile:0x00007f8a92ab6548>.

 #  from /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/ios/Podfile:24
 #  -------------------------------------------
 #  # end
 >  add_flipper_pods!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
 #  
 #  -------------------------------------------

Here is my Podfile

source 'https://cdn.cocoapods.org/'
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
# require_relative '../node_modules/react-native/scripts/autolink-ios'
# def add_flipper_pods!
#   version = '~> 0.75.1'
#   pod 'FlipperKit', version, :configuration => 'Debug'
#   pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
#   pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
#   pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
#   pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
# end

# Post Install processing for Flipper
# def flipper_post_install(installer)
#   installer.pods_project.targets.each do |target|
#     if target.name == 'YogaKit'
#       target.build_configurations.each do |config|
#         config.build_settings['SWIFT_VERSION'] = '4.1'
#       end
#     end
#   end
# end
add_flipper_pods!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')

target 'sunset_24' do
  # Pods for sunset_24
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  target 'sunset_24Tests' do
    inherit! :complete
    # Pods for testing
  end

  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'sunset_24-tvOS' do
  # Pods for sunset_24-tvOS

  target 'sunset_24-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Any suggestions on this?

rbackhouse commented 3 years ago

@Base29 My podfile changed to this which yours has commented out

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

Not sure if that's the cause

suprith-s-reddy commented 3 years ago

I have the same issue, and I use xcode 12.5, and react-native 0.63.4 and even after trying all the fixes still does not work.

Jexim commented 3 years ago

As for me for react-native 0.64.1 helped these steps: 1) Add to the end of Podfile function find_and_replace :

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

2) Change block post_install do |installer| to this:

post_install do |installer|
    flipper_post_install(installer)

    # Fix atomic_notify_one bug for XCode 12.5
    find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") 
    find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
end

3) Find and remove strings $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) from project.pbxproj file. 4) Add empty swift file to ios project by xCode. 5) Remove folder ios/Pods clear caches, clean build folder in xCode. 6) Install pods and run the project.

Base29 commented 3 years ago

@Base29 My podfile changed to this which yours has commented out

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

Not sure if that's the cause

@rbackhouse ... Uncommenting the line require_relative '../node_modules/react-native/scripts/autolink-ios' throw this error when I do pod install


[!] Invalid `Podfile` file: cannot load such file -- /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/node_modules/react-native/scripts/autolink-ios.

 #  from /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/ios/Podfile:4
 #  -------------------------------------------
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 >  require_relative '../node_modules/react-native/scripts/autolink-ios'
 #  def add_flipper_pods!
 #  -------------------------------------------
rbackhouse commented 3 years ago

@Base29 My podfile changed to this which yours has commented out require_relative '../node_modules/react-native/scripts/autolink-ios' Not sure if that's the cause

@rbackhouse ... Uncommenting the line require_relative '../node_modules/react-native/scripts/autolink-ios' throw this error when I do pod install


[!] Invalid `Podfile` file: cannot load such file -- /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/node_modules/react-native/scripts/autolink-ios.

 #  from /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/ios/Podfile:4
 #  -------------------------------------------
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 >  require_relative '../node_modules/react-native/scripts/autolink-ios'
 #  def add_flipper_pods!
 #  -------------------------------------------

@Base29 Did you do this from the first comment ?

change your package.json react-native dependency to "react-native": "0.62.3"

Base29 commented 3 years ago

@Base29 My podfile changed to this which yours has commented out require_relative '../node_modules/react-native/scripts/autolink-ios' Not sure if that's the cause

@rbackhouse ... Uncommenting the line require_relative '../node_modules/react-native/scripts/autolink-ios' throw this error when I do pod install


[!] Invalid `Podfile` file: cannot load such file -- /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/node_modules/react-native/scripts/autolink-ios.

 #  from /Users/FaisalHussain/Crowdbotics/blaque-fitness-24874/ios/Podfile:4
 #  -------------------------------------------
 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 >  require_relative '../node_modules/react-native/scripts/autolink-ios'
 #  def add_flipper_pods!
 #  -------------------------------------------

@Base29 Did you do this from the first comment ?

change your package.json react-native dependency to "react-native": "0.62.3"

@rbackhouse ... does changing the RN version to 0.62.3 require significant updates to various files of the project? Or did facebook made it easy to update the version of react native ? I remember I use this tool to help me upgrade the RN version https://react-native-community.github.io/upgrade-helper/

I will give it a try and get back to you with the results.

Base29 commented 3 years ago

@rbackhouse ... issue resolved by following your guidance ... Thanks for the help

M-HARIS-97 commented 3 years ago

@smadan Im using RN 62.2. Ur solution not working for me.

angadp commented 3 years ago

I have been following this thread since almost the start. The best solution that I have found is to use XCode 12.4 and add the support files in your XCode.app for the version you want to use. It will even build for 14.6. There are a bunch of open source projects for this. Just search 'device support files xcode' and then the version number of your iPhone. Putting this out there until a permanent solution is found. This is just a workaround for the people facing issues even after doing the above steps.

oferRounds commented 3 years ago

Has anyone was able to build 0.64 + use_frameworks! + Hermes on iOS? getting multiple build failures note: I disabled Flipper, but it still does not build

ahartzog commented 3 years ago

I am suddenly seeing this "atomic_notify_one" build error in xcode again. image

I have tried with my more-updated flipper that has been working...

image

As well as reverting back to the original fixes for 0.64.1

image

Edit: after five years of react native development, I can still be a giant idiot. I was opening the wrong workspace (which did not have the appropriate fixes) in xcode. Glad I spent hours doing that this weekend.

aiba commented 3 years ago

For those on Apple Silicon (M1) chips, I think there are extra steps necessary for react-native 0.64.2.

Eventually I got this to work (react-native 0.64.2, xcode 12.5, apple m1, no rosetta). I documented my steps here in case it is helpful to others:

https://github.com/aiba/react-native-m1/blob/main/README.md

oferRounds commented 3 years ago

@aiba thanks! Would you be to try if your way works also with use_frameworks! + removing Flipper (as they do not work together)?

AGurindapalli commented 3 years ago

carbon-6 : 0.64.2, Xcode 12.5

### This worked out for me. Please give it a try.

platform :ios, '12.1'

`use_flipper!({'Flipper-Folly' => '2.6.7','Flipper' => '0.95.1','Flipper-RSocket' => '1.4.3','Flipper-DoubleConversion' => '3.1.7'}) post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1' end flipper_post_install(installer)

Fix atomic_notify_one bug for XCode 12.5

find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") 
find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")

end end`

songzhw commented 3 years ago

carbon-6 : 0.64.2, Xcode 12.5

### This worked out for me. Please give it a try.

platform :ios, '12.1'

use_flipper!({'Flipper-Folly' => '2.6.7','Flipper' => '0.95.1','Flipper-RSocket' => '1.4.3','Flipper-DoubleConversion' => '3.1.7'}) post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1' end flipper_post_install(installer) # Fix atomic_notify_one bug for XCode 12.5 find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_notify_one(state)", "folly::atomic_notify_one(state)") find_and_replace("Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h", "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)") end end

I got error when running this: [!] Invalid Podfile file: syntax error, unexpected end, expecting end-of-input.

ryderdonahue commented 3 years ago

@songzhw https://github.com/facebook/react-native/issues/31179#issuecomment-831932941 Here is where I have seen this snippet and successfully got it to work from

evanjmg commented 3 years ago

@oferRounds Any luck with hermes 0.64 + use_frameworks? This I think is blocking? https://github.com/facebook/react-native/issues/31302 @tapz any update?

chriskrogh commented 3 years ago

I'm actually getting a different error on a fresh install (npx react-native init MyApp) with a M1 Mac and "react-native": "0.64.2", when running yarn ios.

objc[32403]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1efc73ad8) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x117f6c2b8). One of the two will be used. Which one is undefined.
objc[32403]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1efc73b28) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x117f6c308). One of the two will be used. Which one is undefined.
** BUILD FAILED **

gist of output

None of the methods mentioned above resolve this. I'm able to reproduce consistently with both a fresh install and also by following the steps outlined here

It seems like people have gotten this issue for a bunch of reasons in the past like with Flutter and python

Has anyone encountered this before and knows if this is related?

Yandamuri commented 3 years ago

I ma still facing this error after doing as mentioned in the issue description. I ma using RN 0.63.

Can some one help me to get rid of this error?. Thank you.

heapwalker commented 3 years ago

Suggestion at https://github.com/facebook/react-native/issues/31249#issuecomment-811715288 helps solved my issue. I uninstalled nvm and used n instead.

More info: I faced this issue with RN 0.64.2, Xcode 12.5, node 14.15.5 (and with nvm too).

My RN project failed to build ios app, via npx react-native run-ios. But it succeeded in building android app, via npx react-native run-android. Such strange behavior has occurred for some weeks, probably since after I upgraded Xcode.

I have followed all steps under section "If you are on 0.64" on first post of this issue (except I am using RN 0.64.2 rather than 0.64.1). But no luck, it still failed to build ios app.

Lastly I see https://github.com/facebook/react-native/issues/31249#issuecomment-811715288 . Remembering I did see error messages coming out from npx react-native run-ios:

...
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/usr/local"
Run `unset npm_config_prefix` to unset it.
...

(I tried many times running such unset npm_config_prefix but still no success).

Then I tried uninstalling the nvm on my machine (falling back to default node). And then npx react-native run-ios works perfectly! 😃😃

p.s.

xiongemi commented 3 years ago

how about RN 0.65?

kelset commented 3 years ago

@xiongemi 65 should work out of the box, it did during our testing

tiennguyen1293 commented 3 years ago

same issue, when i run npx react-native run-ios on command line. with XCode the build is successfully

xiongemi commented 3 years ago

@xiongemi 65 should work out of the box, it did during our testing

I use 0.65-rc.3 and I run the xcode command code: xcodebuild -workspace App2.xcworkspace -scheme App2 -configuration Debug -sdk iphonesimulator -derivedDataPath ./build -quiet

I got this error:

** BUILD FAILED **

emilyxiong@tm0705919 ios % xcodebuild -workspace App2.xcworkspace -scheme App2 -configuration Debug -sdk iphonesimulator -derivedDataPath ./build -quiet
/Users/emilyxiong/nx-react-native-rc4/apps/app2/ios/Pods/RCT-Folly/folly/container/detail/F14Table.cpp:41:10: error: thread-local storage is not supported for the current target
  static thread_local std::atomic<size_t> value_tl{0};
         ^
/Users/emilyxiong/nx-react-native-rc4/apps/app2/ios/Pods/RCT-Folly/folly/container/detail/F14Table.cpp:56:10: error: thread-local storage is not supported for the current target
  static thread_local std::atomic<uint32_t> state_tl{0};
         ^
2 errors generated.

it also failed with configuration Release: xcodebuild -workspace App2.xcworkspace -scheme App2 -configuration Release -sdk iphonesimulator -derivedDataPath ./build -quiet

tido64 commented 3 years ago

@xiongemi: What's your target iOS version? It doesn't look like thread_local was added until iOS 9.

xiongemi commented 3 years ago

@xiongemi: What's your target iOS version? It doesn't look like thread_local was added until iOS 9.

in my podfile, I have platform :ios, '11.0'

this iso target is from RN 0.65, right? https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.65.0-rc.3/RnDiffApp/ios/Podfile

tido64 commented 3 years ago

It would be great if you could upload a minimal repro for us. As kelset mentioned earlier, we did not see this issue during testing.

flora8984461 commented 3 years ago

Wondering if anyone using stripe? I am on M1 device, Xcode 12.5, RN 0.64.1 and keep getting

fatal error: module map file '/<path>/DerivedData/<AppName>-bruuceewkpsieogndskuohenymiu/Build/Products/Debug-iphonesimulator/Stripe/Stripe.modulemap' not found

And I think it's kinda related with Xcode and RN. Any help is really appreciated, thanks!

xiongemi commented 3 years ago

It would be great if you could upload a minimal repro for us. As kelset mentioned earlier, we did not see this issue during testing.

this is repo i used. it is just a out-of-box project I generated using react native cli. I run the command under ios folder: xcodebuild -workspace reactNativeApp.xcworkspace -scheme reactNativeApp -configuration Debug -sdk iphonesimulator -derivedDataPath ./build -quiet and I got this error:

/Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/RCT-Folly/folly/container/detail/F14Table.cpp:41:10: error: thread-local storage is not supported for the current target
  static thread_local std::atomic<size_t> value_tl{0};
         ^
/Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/RCT-Folly/folly/container/detail/F14Table.cpp:56:10: error: thread-local storage is not supported for the current target
  static thread_local std::atomic<uint32_t> state_tl{0};
         ^
Screen Shot 2021-08-12 at 11 17 50 AM

react native version: 0.65.0-rc.3 xcode version: Version 12.5 (12E262)

NullPainter2 commented 3 years ago

@xiongemi I HAVE NOT NESTED IT: I would start by fixing warnings. Look like You have IPHONEOS_DEPLOYMENT_TARGET set to 8 and not to 9. Since thread_local is supported since IOS 9, so it seems like that should lead to fixing this problem https://github.com/measurement-kit/measurement-kit/commit/9362ad10eac9d6a988dfe429aea5eea28064d67a

xiongemi commented 3 years ago

@xiongemi I HAVE NOT NESTED IT: I would start by fixing warnings. Look like You have IPHONEOS_DEPLOYMENT_TARGET set to 8 and not to 9. Since thread_local is supported since IOS 9, so it seems like that should lead to fixing this problem measurement-kit/measurement-kit@9362ad1

i do have it set ios target in xcode:

Screen Shot 2021-08-12 at 1 26 33 PM

I run xcodebuild -showBuildSettings | grep IPHONEOS_DEPLOYMENT_TARGET:

DEPLOYMENT_TARGET_CLANG_ENV_NAME = IPHONEOS_DEPLOYMENT_TARGET
    DEPLOYMENT_TARGET_LD_ENV_NAME = IPHONEOS_DEPLOYMENT_TARGET
    DEPLOYMENT_TARGET_SETTING_NAME = IPHONEOS_DEPLOYMENT_TARGET
    IPHONEOS_DEPLOYMENT_TARGET = 11.0

do you mean I have to add delete 'IPHONEOS_DEPLOYMENT_TARGET' to Podfile? I have also tried config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'

  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end
  end

i got a different error when I run xcodebuild -workspace reactNativeApp.xcworkspace -scheme reactNativeApp -configuration Debug -sdk iphonesimulator -derivedDataPath ./build -quiet:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/time.h:171:9: note: previous definition is here
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
        ^
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/RCT-Folly/folly/net/NetOps.cpp:17:
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/net/NetOps.h:25:
/Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17: error: typedef redefinition with different types
      ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
typedef uint8_t clockid_t;
                ^
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/RCT-Folly/folly/net/NetOps.cpp:17:
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/net/NetOps.h:22:
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/net/NetworkSocket.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/ostream:138:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/ios:214:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/wchar.h:119:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/wchar.h:91:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/time.h:172:3: note: previous definition is here
} clockid_t;
  ^
4 warnings and 1 error generated.
Screen Shot 2021-08-12 at 1 55 31 PM
NullPainter2 commented 3 years ago

@xiongemi no, my mistake, I apologize. You seem want Your target to be 11, so set 11. Not 9. :)

xiongemi commented 3 years ago

@xiongemi no, my mistake, I apologize. You seem want Your target to be 11, so set 11. Not 9. :)

do you mean add config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'? I have tried:

installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
    end

i still got the same error with command xcodebuild -workspace reactNativeApp.xcworkspace -scheme reactNativeApp -configuration Debug -sdk iphonesimulator -derivedDataPath ./build -quiet:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/time.h:171:9: note: previous definition is here
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
        ^
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/RCT-Folly/folly/net/NetOps.cpp:17:
In file included from /Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/net/NetOps.h:25:
/Users/emilyxiong/Code/tmp/reactNativeApp/ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17: error: typedef redefinition with different types
      ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
typedef uint8_t clockid_t;