Symbol(s) not found for architecture arm64 - XCode - ios

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.

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.

I had a similar issue on my M1 Mac and here is what I did to fix this:
brew install watchman
if you don't have node => brew install node
sudo arch -x86_64 gem install ffi
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
cd ios/ && arch -x86_64 pod install.
run Xcode with Rosetta.
.
You can install Rosetta by running: softwareupdate --install-rosetta
exclude architecture arm64.
clean build - open xcode then press Command + Shift + K
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:
Shoutout to these answers:
one two three

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

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.

It works for me when I upgraded xcode to 14.1.

Related

Undefined symbol: _MDMMotionCurveMakeBezier

Can't build my project on new Xcode 14.1
I'm using MaterialComponents/ActivityIndicator
"_MDMMotionCurveMakeBezier", referenced from:
+[MDCActivityIndicatorMotionSpec loopIndeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeToDeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeToIndeterminate] in MDCActivityIndicatorMotionSpec.o
+[MDCActivityIndicatorMotionSpec willChangeProgress] in MDCActivityIndicatorMotionSpec.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Perhaps you have this line in your Podfile
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
Until they fix it, you can remove it
The podspec of MaterialComponents is missing a dependency. Because the build order can vary a bit with parallel builds in Xcode it will not always occur.
The fix is adding MotionInterchange as dependency of ActivityIndicator:
diff --git a/MaterialComponents.podspec b/MaterialComponents.podspec
index d37749ea9..931c25fed 100644
--- a/MaterialComponents.podspec
+++ b/MaterialComponents.podspec
## -107,6 +107,7 ## Pod::Spec.new do |mdc|
component.dependency "MaterialComponents/Palettes"
component.dependency "MaterialComponents/private/Application"
component.dependency "MotionAnimator", "~> 4.0"
+ component.dependency "MotionInterchange"
component.test_spec 'UnitTests' do |unit_tests|
unit_tests.source_files = [
https://github.com/material-components/material-components-ios/issues/10260#issuecomment-1327611872
This is just a quick solution to avoid to modify the library .podspec
Maybe not the most recommendend option but it could save some time while considering moving from Material Component to a better solution.
In the podfile of your project, include:
pod 'MotionInterchange'

IOS build errors - Xcode 13

Below are errors while building in latest xcode 13 & Mac Apple Pro M1 chip
<unknown>:0: error: module map file '/Users/xxxx/Library/Developer/Xcode/DerivedData/xx-cwbykxafbbbrfjbaeyuaxhdrivdp/Build/Products/Debug-iphonesimulator/Stripe/Stripe.modulemap' not found
<unknown>:0: error: module map file '/Users/xxxx/Library/Developer/Xcode/DerivedData/xx-cwbykxafbbbrfjbaeyuaxhdrivdp/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found
Command PrecompileSwiftBridgingHeader emitted errors but did not return a nonzero exit code to indicate failure
Most of the answers mentioned to edit pod file & write exclude configuration hence the tried below fix -
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)'] # or it won't build on apple silicon
# without explicitly clearing this out, it flaps between excluding arm64 or not
# Fix some library / linker errors
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' # only one at a time
config.build_settings['VALID_ARCHS'] = 'arm64 x86_64' # you need both to work on both CPU archs / release etc
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
aggregate_target.user_project.save
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# We support a smaller range of deployment than some libraries, eliminate related noise
# This also avoids a nasty Folly bug about an API not available until ios10+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
Also couple of answers mentioned to open workspace file which also tried but these errors are not resolving. Requesting if someone can provide right pointers.
I faced a similar issue with Xcode 14 in M1 Mac running macOS Ventura. The following workaround fixed the issue for me.
Right click on Applications -> Xcode
Choose Get Info
Select Open with Rosetta option if it's not selected

iOS: How to build a static framework based on CocoaPods dependencies?

I am trying to build a framework that makes use of the geopackage-ios CocoaPods dependency. I would then like to statically embed this framework into one or more apps.
Similar questions have been asked before, but I couldn't find a solution to my problem. Here's what I've been trying so far:
First Approach: Building Manually
In this approach, I would create a static library using Xcode, add the CocoaPods dependencies to it and build it. The problem with this approach, however, is that the resulting framework will not have the CocoaPods dependencies embedded into it.
Create a new static library from Xcode (File > New > Project… > iOS: Static Library) named "MyLibrary" with language Swift.
Create a Podfile in the project root directory with the following content:
target 'MyLibrary' do
pod 'geopackage-ios', '~> 7.2.1'
end
Run pod install. (This will install the geopackage-ios pod and 10 depending pods.)
Open the newly created MyLibrary.xcworkspace and add a BridgingHeader.h to the "MyLibrary" group having the following content:
#ifndef BridgingHeader_h
#define BridgingHeader_h
#import "geopackage-ios-Bridging-Header.h"
#endif
Reference the bridging header by clicking on the "MyLibrary" project in the project navigator, selecting the "MyLibrary" target and, in the Build Settings, specifying MyLibrary/BridgingHeader.h as the "Objective-C Bridging Header".
Modify MyLibrary.swift to use the GeoPackage dependency:
public class MyLibrary {
public init() {}
public func test() {
let manager = GPKGGeoPackageFactory.manager()!
print("Manager:", manager)
}
}
Build the library for the iOS simulator by pressing Cmd + B.
Optionally, create a static framework using a shell script like the one in this article (which will compile the library once for the simulator and once for physical devices and then combine the two results to a universal framework using the lipo command).
When I embed either the static library (along with the MyLibrary.swiftmodule) or the universal framework into an app, linking will fail for this app:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GPKGGeoPackageManager", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
"_OBJC_CLASS_$_GPKGGeoPackageFactory", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I could also add the geopackage_ios.framework (found in the build folder of "MyLibrary") to the app (making sure to choose the Embed & Sign embedding option), which will allow the app to be built successfully. Then, however, the app will crash upon launch:
dyld[79209]: Library not loaded: #rpath/ogc_api_features_json_ios.framework/ogc_api_features_json_ios
Referenced from: /Users/admin1/Library/Developer/CoreSimulator/Devices/C3D61224-CFE8-45CC-951B-7B6AB54BC8B3/data/Containers/Bundle/Application/D41A82D6-4E69-4BB6-AC59-6BC28AE58795/TestApp.app/Frameworks/geopackage_ios.framework/geopackage_ios
One might be able to fix this by adding all eleven pod frameworks to the app, which, however, is what I'm trying to avoid.
Second Approach: Using PodBuilder
A second approach would be to use PodBuilder, which aims at automating this particular kind of build task. This approach, however, fails with a build error, the cause of which I can't quite make out.
Again, I would start out with a new Xcode project. This time, I'd create an iOS Swift app named "MyApp".
I would create a Podfile with almost the same content as above:
use_frameworks!
target 'MyApp' do
pod 'geopackage-ios', '~> 7.2.1'
end
Then, I'd run pod install.
Next, I would install PodBuilder, create an empty Git repository (which PodBuilder requires for some reason), initialize PodBuilder, and start the build task:
sudo gem install pod-builder
git init
pod_builder init
pod_builder build geopackage-ios
The build will fail, however, with errors like these written to /tmp/pod_builder/pod_builder.err:
Undefined symbols for architecture arm64:
"_PROJ_WEB_MERCATOR_MAX_LAT_RANGE", referenced from:
+[GPKGTileBoundingBoxUtils toWebMercatorWithBoundingBox:] in GPKGTileBoundingBoxUtils.o
+[GPKGTileBoundingBoxUtils boundDegreesBoundingBoxWithWebMercatorLimits:] in GPKGTileBoundingBoxUtils.o
-[GPKGTileDao isXYZTiles] in GPKGTileDao.o
-[GPKGTileGenerator adjustXYZBounds] in GPKGTileGenerator.o
"_PROJ_UNDEFINED_CARTESIAN", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
"_PROJ_AUTHORITY_NONE", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
[…]
This seems to be a problem with the geopackage-ios pod itself, which can be fixed by cloning our own version of the repo …
cd ..
git clone --branch 7.2.1 https://github.com/ngageoint/geopackage-ios.git
…, installing the pods …
cd geopackage-ios
pod install
… manually copying the proj-ios source files …
cp -r Pods/proj-ios/proj-ios geopackage-ios
…, and opening the geopackage-ios.xcodeproj to reference the proj-ios files in the geopackage-ios group inside that project.
Then telling CocoaPods to use our local version of the pod …
use_frameworks!
target 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
end
…, reinitializing PodBuilder …
cd ../MyApp
pod_builder deintegrate
pod deintegrate
pod install
pod_builder init
… and allowing PodBuilder to use local pods by editing the ./PodBuilder/PodBuilder.json file:
{
…,
"allow_building_development_pods": true,
…
}
Then, one can try to rebuild:
pod_builder build geopackage-ios
This time, the build will fail with a different error:
The following build commands failed:
CompileC /tmp/pod_builder/build/Pods.build/Release-iphoneos/sf-proj-ios.build/Objects-normal/arm64/SFPGeometryTransform.o /tmp/pod_builder/Pods/sf-proj-ios/sf-proj-ios/SFPGeometryTransform.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'sf-proj-ios' from project 'Pods')
(1 failure)
The SFPGeometryTransform.m file, however, looks fine.
The full build log is available here.
Third Approach: Using Rome
The third approach would be to use cocoapods-rome.
To use it, one would install Rome …
sudo gem install cocoapods-rome
…, get rid of the PodBuilder stuff …
pod_builder deintegrate
pod deintegrate
…, quickly adjust the Podfile:
use_frameworks!
platform :ios, '13.0'
plugin 'cocoapods-rome', { :pre_compile => Proc.new { |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
installer.pods_project.save
},
dsym: false,
configuration: 'Release'
}
target 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
end
… and install the pods:
pod install
This, however, will fail with the exact same error as PodBuilder.
Can anyone give me some advice on any of these approaches? Or does anyone perhaps have a whole different idea on how to build such a framework?
(EDIT: It seems like the PROJProjectionTransform.h file imported to SFPGeometryTransform.m cannot be found. Anyway, I don't think these approaches are expedient. So any help is highly appreciated.)
Solved the problem by simply feeding all the aggregated source files from the pod installation into a new static library, then using either the lipo command to make a fat binary out of it or creating an Xcode framework from it (as described here). The compiled framework could then be used to create another framework built on top of it.

react-native can't build ios: (error xcode Flipper) Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

My goal is to run a react native build (ios version).
Situation 1
Actions: start metro (ok)
build ios.
Problem: build failed with exit code 1.
(CompileC /Users/macbook/Library/Developer/Xcode/DerivedData/NAME_OF_PROJECT-gxlagomyefvmjkdemiakcfycxnhx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper.build/Objects-normal/x86_64/FlipperRSocketResponder.o /Users/macbook/Documents/work/omg/mobile/ios/Pods/Flipper/xplat/Flipper/FlipperRSocketResponder.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler)
Situation 2
Actions: build ios.
Problem: Flipper:: Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t'
Versions
xcode version 12.5
ios 9+
iphone 12
Some actions I tried that didn't work:
solution 1
solution 2
reisntall all pods
update all pods
reclon project
rm -Rf Pods/*
pod cache clean --all
pod install
and a few other little fixes. Any help would be appreciated.
Change Podfile like below:
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
end
Run pod install and it works!
I also faced the same issue on my very first react-native project when I tried to run it on an ios simulator.
clockid_t
clockid_t is part of one of your systems. The error is actually for redefining clockid_t twice.
Renaming clockid_t to something else solved my problem.
I renamed it from clockid_t to clockid_tt and then my project ran smoothly.
Because I'm a beginner react-native dev, I am not sure about whether this solution will create any future problems on my react-native project. Not yet faced any problem with this solution.
If you have use_frameworks! enabled, Flipper will not work and you should disable these next few lines in your Podfile.
# use_flipper!()
# post_install do |installer|
# react_native_post_install(installer)
# __apply_Xcode_12_5_M1_post_install_workaround(installer)
# end
**OR**
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end

Double-quoted include [all Facebook SDK imports], expected angle-bracketed instead

I am getting the following warning in iOS Xcode builds:
Double-quoted include "FBSDKDeviceLoginCodeInfo.h" in framework header, expected angle-bracketed instead.
This is apparently a new default warning in Xcode 12 which will throw a warning anywhere you #import or #include with "quotes.h" instead of <brackets.h>.
I am getting this for all of the Facebook SDK imports. There are a few StackOverflow proposed solutions out there, but none of them works.
These solutions do not work:
go in the project's Build Settings a just set the option Quoted Include In Framework Header to No :
you can use Cocoapods version 1.10.0.rc.1 temporarily until 1.10.1 is officially available -> gem install cocoapods -v '1.10.0.rc.1'
Another option is to update your Podfile (add below code) to disable the warning flag CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER setting for all pods in your project
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = 'NO'
end
end
end
end
You can disable these warnings for your entire project by navigating to your project's "build settings", finding the field "other linker flags" and adding the following flag: -Wno-quoted-include-in-framework-header
Worked for me:
rm -rf ~/Library/Developer/Xcode/DerivedData/
rm -rf ~/Library/Caches/CocoaPods/
pod deintegrate
pod update
These solutions were written 7 or 8 months ago and DO NOT WORK FOR ME.
Are there any new solutions beyond manually editing hundreds of occurrences of this?

Resources