8

I'm trying to build my react native project on a Mac Intel, but keep getting the next error:

Showing All Messages
Undefined symbol: _swift_stdlib_isStackAllocationSafe

Undefined symbols for architecture arm64: "_swift_stdlib_isStackAllocationSafe", referenced from: function signature specialization <Arg1 = Owned To Guaranteed> of function signature specialization <Arg[0] = [Closure Propagated : closure #1 (__C.SKProduct) -> Swift.Bool in closure #2 (Swift.Set<__C.SKProduct>) -> () in PurchasesCoreSwift.IntroEligibilityCalculator.checkTrialOrIntroductoryPriceEligibility(with: Foundation.Data, productIdentifiers: Swift.Set<Swift.String>, completion: (Swift.Dictionary<Swift.String, __C.NSNumber>, Swift.Optional<Swift.Error>) -> ()) -> (), Argument Types : [Swift.Set<Swift.String>]> of generic specialization <__C.SKProduct> of Swift._NativeSet.filter((A) throws -> Swift.Bool) throws -> Swift._NativeSet in libPurchasesCoreSwift.a(IntroEligibilityCalculator.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried almost all the answers on: link.

Also

pod deintegrate 
pod install
pod repo update

My react-native version:

"react-native": "0.64.2"

The Architecture of my project: Architectures

The link binary With Libraries link binary

UPDATE I also updated the react native version to 0.67.4 but still not working.

1

5 Answers 5

8

For react-native 0.67+: After a lot of research, I found the next solution from Vegaro:

SOLUTION LINK

First step is to upgrade the react-native-purchases by Revenuecat package to the latest version.

Clean your pods: REFERENCE LINK TO PROPERLY CLEAN PODS

Declare a pods post install process: Add the next to your Podfile:

 post_install do |installer|
    react_native_post_install(installer)
    fix_library_search_paths(installer)
  end
end

def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end 

And finally, change the Library Search Paths in the project manually (XCode). Remove:

$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)

Add:

$(SDKROOT)/usr/lib/swift

Clean your project and run the: "Archive" build again.

1
  • The 'SOLUTION_LINK' worked for me with Expo -> RN 0.64. Only changing the pods post install script solved for me. Thank you, was struggling for some days on that.
    – Alexandre
    Apr 14, 2022 at 13:11
4

I had a similar issue on my M1 Mac and here is what I did to fix this:

  1. brew install watchman
    if you don't have node => brew install node
  2. sudo arch -x86_64 gem install ffi
  3. add this code at the end of the pod file which is inside ios folder:
post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
      end
    end
  end
  1. cd ios/ && arch -x86_64 pod install.

  2. run Xcode with Rosetta.
    enter image description here.
    You can install Rosetta by running: softwareupdate --install-rosetta

  3. exclude architecture arm64. enter image description here

  4. clean build - open xcode then press Command + Shift + K


  1. If you're using nvm try to replace NODE_BINARY=node with the actual result of the which node command, which in my case looks something like this:enter image description here
    enter image description here

Shoutout to these answers: one two three

1
  • Using Rosetta is not a recommended long term solution if you're actually interested in resolving this problem permanently. Dec 13, 2022 at 22:27
2

As a workaround downgrade to Xcode 13.2.1 works for me. On this version everything is ok.

But at the version 13.3 - I have this issue

1
  • Yes, this works for me too. I don't why this issue is in 13.3 version of Xcode. May 14, 2022 at 10:28
2

If it is feasible for you to do so, update your React Native version. Version 0.67 fixes this issue.

If updating is not an option, the easiest solution is to update your Library Search Paths.

Select your project in Xcode, and go to "Build Settings". Scroll down until you see "Search Paths", and finally, "Library Search Paths". Replace "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" with "$(SDKROOT)/usr/lib/swift".

Library Search Paths

Credit for this solution goes to Vegaro, who posted it HERE, along with what I'd consider to be a more invasive option if this doesn't work for you.

0

It works for me when I upgraded xcode to 14.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.