Reputation: 768
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:
The link binary With Libraries
UPDATE I also updated the react native version to 0.67.4 but still not working.
Upvotes: 11
Views: 45089
Reputation: 1145
I face this error because my React Native project version is "0.62.2" and my Xcode version is 14.3
so, I simply update:-
1. Updating Library Search Paths in Xcode
You need to change Library Search Paths in Xcode:
2. Adding new fix_library_search_paths feature in your Podfile
In your podfile find post_install
section and add one line of fix_library_search_paths(installer)
there and function itself. Should work after that.
post_install do |installer|
flipper_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
Also, it is said, that updating RN to >= 0.67
helps.
Upvotes: 5
Reputation: 119
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"
.
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.
Upvotes: 10
Reputation: 2624
I had a similar issue on my M1 Mac and here is what I did to fix this:
brew install watchman
brew install node
sudo arch -x86_64 gem install ffi
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
cd ios/ && arch -x86_64 pod install
.
run Xcode with Rosetta.
.
You can install Rosetta by running: softwareupdate --install-rosetta
clean build - open xcode then press Command + Shift + K
nvm
try to replace NODE_BINARY=node
with the actual result of the which node
command, which in my case looks something like this:Shoutout to these answers: one two three
Upvotes: 5
Reputation: 484
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
Upvotes: 2
Reputation: 768
For react-native 0.67+: After a lot of research, I found the next solution from Vegaro:
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.
Upvotes: 14