skip to Main Content

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.

5

Answers


  1. Chosen as BEST ANSWER

    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.


  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

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  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

    Login or Signup to reply.
  5. It works for me when I upgraded xcode to 14.1.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search