Home > OS >  Symbol(s) not found for architecture arm64 - XCode
Symbol(s) not found for architecture arm64 - XCode

Time:03-30

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

The link binary With Libraries link binary

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

CodePudding user response:

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.

  • Related