Im trying to build a project after adding 3rd party framework, however I can't compile the project after adding the framework, I get Undefined symbols for architecture arm64: error when I try to compile on a device, but I can compile on a simulator. I have tried all other solutions I found on stackoverflow. any help is appreciated!
Here is what I have tried:
Added Any iOS Simulator SDK with value arm64 inside Excluded Architecture.
I do have $(inherited) inside Other Linker Flags
Set Bitcode Enabled to No
None of the solutions I tried worked for me.
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_*", referenced from:
objc-class-ref in frameworkName.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"Product" -> "Scheme" -> "Edit Scheme"
select "Build"
Uncheck "Parallelize Build"
Try adding this to your pod file
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
end
end
end
I found the issue.
My project supports lower minimum deployment target than the framework, and that caused the issue. I had to include the framework starting from a specific iOS version.
Here is the scenario and the issue: my project supports iOS 9 and the framework supports starting from 9.1. For that reason I was not getting the latest framework, instead Cocoapods was downloading the older version of the framework which doesn't support arm64.
So for the time being I just included the framework only for iOS 9.1 and above:
platform :ios, '9.1'
pod 'PodName', '~> 3.2'
Then the project compiled properly, thanks for those who tried to help. I spent half day because of this and Im putting this here for anyone who might face the same problem.
Forget about complicated answers that can affect other developed apps because you change XCODE inners.
In my experience, this happens because you update versions duplicating projects, that it is the simplest way to do it.
The problem is worked out when you set to YES the "Enable Modules (C and Objetive -C)" parameter in BUILD SETTINGS tab.
I also recommend to compare the BUILD SETTINGS parameters (there are a lot but is faster than rebuild the project ... I do not understand why Apple makes it so complicated) beetween projects than work ok.
There are many possible reasons, last armv7 version stays in iOS 10.
So for me:
I tried to use "Valid Architectures" without 'armv7', which doesn't exist in Xcode 12 anymore.
Next I tried ONLY_ACTIVE_ARCH, which I know this will result in I cannot Archive my app in the end
Finally, I searched my local podspec, found
s.ios.deployment_target = "10.0"
Since my main app's minimum deploy target is set to iOS 11. So I set
s.ios.deployment_target = "11.0"
Xcode doesn't complain this armv7 anymore.
Hope this will help someone, check your framework or any dependencies, make sure they are set correctly.
I found it help to set the target membership of file that has this error to target. click on a file that produced this error, on the right of Xcode there is the inspector. in inspector It shows target membership. if file is currently not of any target membership select what you want.
Related
I am currently working on a Swift 5.0 project (Xcode 12). I currently use an M! computer. For my project, I have a couple of pod dependencies that I need (AWS, Google, etc) to make my project work. When I run my code on a IOS device, I encounter no issues. But when I try to run the project on a simulator, I run into different errors involving the pod linking.
The Google places autocomplete FAQ says that if I have troubles building on an iOS simulator using Xcode 12, I should exclude the arm64 architecture for iOS simulators by altering the project build settings. But upon doing that, I get a warning of "No such module found: AWSAppSync".
In attempting to fix this, I've added 'x86_64' and 'x86' to architectures, set "Build Active Architecture Only" to "yes", and made sure my pod's build settings have the same "Build Active Architecture Only" value, which results in no change. I have also tried pod update, install, install --repo-update, cleaning the build folder, deleting derived data, and restarting Xcode.
When I set "Build Active Architecture Only" to "No" for both sets of build settings (pod and project), I get another error from a different non-AWS pod:
"Could not find module 'MultiSlider' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator"
Removing any code references to the multi slider then lets the app fully build, but the app crashes before launching on the simulator with an error of "unrecognized selector sent to instance 0x60000067fd90".
Note that with any of these attempted fixes, the app continues to run on an actual iOS device as expected. I'm very new to pods and would really appreciate any help or insight anyone could offer! Thank you in advance.
I had to exclude the arm64 architecture for each of the pods when building for the simulator. See https://narlei.com/development/apple-m1-xcode-error-when-build-in-simulator/ for more details, but it seems that excluding arm64 from the project AND excluding it in the Podfile for each pod's target is necessary.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
I have my custom framework and it works properly in XCode 10. I rebuild it in XCode 11 beta 3, then integrated into the app, and get the following error:
Could not find module 'MyCustomFramework' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios
Are there some changes I have to make in "valid architectures" in the framework project?
Updated: I can't pick any answer as a correct one as the framework in my case was really tiny (one class, a few methods) and almost not in use, so I decided to get rid of it and move these a few methods into main project.
To solve this issue I had to create a fat library of my custom framework again using xcode 11 tools.
To do that I did the following:
1) Build YourCustomFramework target for iOS simulator and extract framework from products folder on your desktop.
Xcode ▸ DerivedData ▸ Your Project ▸ Build ▸ Products ▸ Release-iphonesimulator
2) Build YourCustomFramework target for Generic iOS Device and extract framework from products folder on your desktop.
Xcode ▸ DerivedData ▸ Your Project ▸ Build ▸ Products ▸ Release-iphoneos
3) Rename the simulator generated framework to YourCustomFramework-sim.framework so that it is distinguishable later.
4) Use the lipo command to combine both binaries into a single fat binary file. (cd to your desktop or wherever your custom framework file is located)
$lipo -create ./YourCustomFramework-sim.framework/YourCustomFramework ./YourCustomFramework.framework/YourCustomFramework -output ./YourCustomFramework
5) Copy YourCustomFramework binary file created in above step and replace it with the binary in YourCustomFramework.framework folder.
6) From folder
YourCustomFramework-sim.framework/Modules/YourCustomFramework.swiftmodule/
copy all of the modules and paste them to
YourCustomFramework.framework/Modules/YourCustomFramework.swiftmodule/
This should solve your issue.
Swift 5.0-5.1, Xcode 11 Open Xcode, <your project>, Build Settings, Build Active Architecture Only and change to <NO> for Debug and Release. Architectures set/leave in Standard Architecture -$(ARCHS_STANDARD), important is next step:Valid Architecture: armv7, armv7s, arm64, arm64e, ADD here x86_64 and if you need add i386 for Debug and Release. (String: armv7, armv7s, arm64, arm64e, x86_64)
Choose any simulator in your simulator list and BUILT IT. DONE.
I hope it is works for you.
Description of Architecture:
armv64: iPhoneX, iPhone 5s-8, iPad Air — iPad Pro
armv7 : iPhone3Gs-5c, iPad WIFI(4th gen)
armv6 : iPhone — iPhone3G
-the above if for real devices
i386 : 32-bit simulator
x86_64 : 64-bit simulator
This is because all your library are not flexible with m1 chip. so right click on xcode, get info and tick open as rosetta. open your project, clean and build. Finally, run your project as before :D
I encountered this issue on my M1 MacBook.
To solve this I've added to following lines to my host app Podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Edit: Adding this line as well helped with runtime issues:
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
I have added two architectures i386 and x86_64.
And set Yes to "Build Active Architecture Only".
It works for me to build on every simulator devices.
For the XCode-12 Valid Architectures has been moved under User-Defined option at the very bottom as VALID_ARCHS
This is all I needed in my Podfile:
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
Please check your Scheme be sure to run correct scheme.
And then you should open XCode > -Your Main Target- > Build Active Architecture Only and set 'NO' to build on the all architectures.
Options:
YES - If set to yes, then Xcode will detect the device that is connected, and determine the architecture, and build on just that architecture alone.
NO - If set to no, then it will build on all the architectures.
For all pods on mac M1 chip you need to add 'x86_64-apple-ios-simulator' support in architectures in build setting. So process will be like,
go to pods, select that the error target add x86_64-apple-ios-simulator in it.
Set "build active architecture". to No in pods specific target.
It will solve this problem. More in project setting. you can set "build active architecture" according to your requirement.
At this time i am using xcode 12.5
For this i have edited User-Defined option at the very bottom with VALID_ARCHS
Select the target and go to Build Setting
Click the plus icon and you will see
Add VALID_ARCHS and $(ARCHS_STANDARD) value
or you can use -> armv7, armv7s, arm64, arm64e, x86_64, i386
For the new M1 Mac with Xcode 12 I encountered the same issue. I was able to solve it by setting Build Active Architecture Only = 'Yes' and adding VALID_ARCHS = arm64 armv7 arm64-ios-simulator (essentially excluding x86_64 and x86_64-ios-simulator architecture) in the Build Settings.
I had to set 'Build Active Architecture Only' from Debug:Yes/Release:No to Debug:No/Release:No for any Pod target showing the error
'Could not find module 'PODNAME' for target
'x86_64-apple-ios-simulator';'
where PODNAME is the pod throwing the error when you compile.
I was facing this issue for RxSwift while running unit tests. Changing the build settings of Pods project and setting the Build Active Architecture to No, fixed the issue for me
Delete your pods and
install pods with this command
"arch -x86_64" pod install
That error means your custom framework has been built for any ios device (an actual device) and you are trying to use this custom framework on a simulator where your app is being tested.
The solution is very simple. Just rebuild your custom framwork for simulator you want to test it out(e.g. Iphone 13 simulator) not for 'Any iOS Device'. And replace the old framework with the newly compiled framework.
Set the 'Build Active Architecture Only' to 'No'.
Please look at the image below.
Alternative Solution
This question is actually about Creating Custom Framework. Even years after posting, people still visiting the page fixing similar issues. I think we need to head up for other solutions as well.
After Xcode 11 now Xcode fully supports using and creating binary frameworks in Swift. Simultaneously support devices and Simulator with the new XCFramework bundle type. XCFrameworks support the binary distribution of Swift and C-based code (C, C++, Objective-C). A single XCFramework can contain a variant for the simulator, and for the device. This means you can ship slices for any of the architectures, including the simulator, any Apple OS, and even separate slices for UIKit and AppKit apps.
You can check the repo if you're interesting the using a library for creating Custom Framework.
if you think #willhess answer is hard you can use this script
open Build Phases -> click plus button -> New Run Script Phase and add below code
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
cp -a "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework"
"${UNIVERSAL_OUTPUTFOLDER}/"
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
lipo -create -output
"${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
"${BUILD_DIR}/${CONFIGURATION}-
iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}"
"${BUILD_DIR}/${CONFIGURATION}-
iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
"${PROJECT_DIR}"
open "${PROJECT_DIR}"
Then build simulator and any ios device, your project folder will be open and your fat framework will be there
in my case show this alert because Pod 'MessageKit', '~> 3.3.0' have this problem but just change Deployment info To iOS 13 For MessageKit All Done
Since Valid Archs isn't available for Xcode 12, you will create a user defined setting by hitting + and typing VALID_ARCHS with the x86_64 and additional architectures.
In my case, I have added test target after the pod init, install etc..
And I saw, adding test target block in podfile solved my problem.
Example;
target 'SampleProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for SampleProject
target 'SampleProjectTests' do
inherit! :search_paths
# Pods for testing
end
end
You need to change the Architecture settings for both Project and Pods project files.
Select project settings then write Architecture in the search bar. After that change the `Build Active Architecture Only" to false NO for all targets.
Then add x86_64-apple-ios-simulator to the Architectures propriety.
You need to do the same for the Pods project setting.
For me it was a setting missing.
In Xcode go to: File->Workspace Settings . In Build System change it to "Legacy Build system".
Run it again and copy the new Framework
I just starting using CocoaPods and I am getting the following errors when I pod install from the terminal (My project is called babyMilestones and I'm trying to use CocoaPods for the ShipLib Framework). :
The babyMilestones [Release] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the$(inherited)` flag, or
- Remove the build settings from the target.
I'm getting this error for Header Search Paths and Framework Search Paths.
When I try to build my project I get an error on the #import line saying the ShipLib/ShipLib.h file cannot be found. In my project navigator my Pods project is showing properly, and the ShipLib framework is visible.
I never set any of these search paths explicitly, I just let XCode 6 do it's thing. I found this answer : The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig
I have tried the following :
Deleted all the Framework Search Paths in Build Settings. This did not fix the issue
I then added $(inherited) to the Framework Search Path. I did Clean then Build. This gave new errors of the following type:
ld: warning: directory not found for option '-L/Users/billpaystation/Documents/iOS/babyMilestones/babyMilestones/Pods/build/Debug-iphoneos'
ld: warning: directory not found for option '-F'
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ActionSheetDatePicker", referenced from:
objc-class-ref in EditItemViewController.o
"_OBJC_CLASS_$_SYSincerelyController", referenced from:
objc-class-ref in EditItemViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Action Sheet Picker and Sincerely Controller are the libraries I'm trying to add with Pods.
I noticed that libPods.a is red under Frameworks in my file inspector. So I went to Scheme ->Edit Scheme-> and added Pods to the Build.
I don't really understand the whole target/build settings and I may have made it worse trying so many different things. Any help would be appreciated!
You should add $(inherited) to the Framework Search Path. For the new errors you should go:
TargetSettings->Build Phases->Compile Sources->(+) ActionSheetDatePicker.m, and SYSincerelyController.m classes and then Build and Run.
Here's my problem and solution from yesterday.
target overrides the FRAMEWORK_SEARCH_PATHS build settings
Hope this helps.
In my case it was not an Xcode issue, plus I think that fixing it by hand is a bad idea. I tried to use a different (earlier version) of Cocoapods and it worked fine!
gem install cocoapods -v 0.33.1
I've installed cocoa pods library and some frameworks through it. Now when I compile project the build fails.
Error:
ld: library not found for -lPods-Project
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here part of text:
Ld /Users/polzovatel/Library/Developer/Xcode/DerivedData/Project-bybevfqrgvqqldbzsgewqafpmylj/Build/Products/Debug-iphonesimulator/Project app/Project normal i386
cd /Users/polzovatel/Projects/iOS-master/Project_iPhone
export IPHONEOS_DEPLOYMENT_TARGET=6.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
What I need to do to fix this problem?
Fixed it by deleting the -lPods-Projectname.a in Link Binary (for newer versions, delete the -lPods-Projectname.a under the Frameworks group).
Whenever I execute "pod install" it leads me to spend several hours fixing build errors. So, I deleted CocoaPods stuff and do not have problems any more! Now I am lucky and happy man.
Start using Swift Package Manager (SPM). If your 3rd party lib still do not support SPM I encourage you to take action on adding SPM support on your own. Here is instructions.
Or create an issue for the 3rd party lib about adding support for SPM.
The exact location that you should remove your libs is at:
Remove -lyourlibname.a in "Link Binary With Libraries" on "Build Phases" of your target.
You can try "Build Active Architecture Only" = YES . it may be solving problem.
Ensure that Build Active Architectures Only settings for both of your project and the Pods project were equal for debug and release configuration! That's was a problem in my case.
Make sure Build Active Architectures Only in your Project/Target and in your Pod/Target and Pod are the same.
We often set the debug yes and set the release no.
I realized the xcproject file was opened instead of the updated workspace. This fixed my error. Hope this information will help others too.
If none of the other answers help you, try this:
Deintegrate cocoa pods using pod deintegrate. Check this link https://github.com/kylef/cocoapods-deintegrate.
Search on the build settings for target and project file for "pod". Anything that looks like it belonged to cocoa pods, remove.
Finally, run pod install once again.
Go to Product > Scheme > Edit Scheme... > Build > + > Add the Pods-Projectname.a and drag it to the top > Clean & Build your project.
I had a very different experience. I tried removed the library from build settings to no avail. And honestly, I couldn't see the logic behind it.
What I did was try a new pod install. And so it gave me this error
[!] The ProjectName [Debug] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
[!] The ProjectName [Release] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
So I did what it told me to, I added the $(inherited) flag to build settings. And all worked well
In my case I found that a mis-match of deployment target of the Project (iOS 11.4) versus the Target (iOS 10.3). Updating the target to iOS 11.4 fixed the issue.
Project > Info > Deployment Target > iOS Deployment Target
Project > Target > General > Deployment Target > Target
Podfile:
platform :ios, '11.4'
I had this problem when I accidentally opened project instead of workspace so Cocoapods where missing....
Check your Project -> Targets -> Build Phases -> Link Binary With Libraries
Point to your Pods project, set the BaseSDK to iOS SDK since 'pod install' process clear it.
Also set Build Valid Architecture Only to NO
That should work.
I experienced a similar error which affected one of my computers but not the other when compiling the same project.
I reinstalled cocoapods, all gems, rebuilt the project and none of it worked. I finally got it to compile but required me to completely remove Xcode and related data (iPhone simulator, DerivedData) then reinstall Xcode.
I've had this error after adding a new build configuration.
pod install helped, because it adds separate settings for each build configuration.
i also had the same sort of issue. So Check your pod file's platform :ios . and check Deployment info target versions. and please make sure version of both files are same. if both are not same the issue will be executed. i also had the issue after library updating my react native project
(Target info = select your project, then select target, In general section Deployment info is available.)
I'm getting a error from cocoa pods that I've never seen before. I've had it working with several dependencies just fine. I recently added the TestFlightSDK as a dependency through pods and I'm unable to Archive the project. It builds just fine to devices but refuses to Archive. Has anyone else experienced this issue?
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My Library Search Paths looks like this (for both debug and release):
$(SRCROOT) recursive
$(PODS_ROOT) recursive
$(inherited) recursive
Ok so I found the answer (that worked for me) using some suggestions from this post
I was actually getting a different Warning that I hadn't noticed.
Pods was rejected as an implicit dependency for 'libPods.a' because its
architectures 'armv7 armv7s' didn't contain all required architectures
'armv7 armv7s arm64'
It was actually related to the Pods target not having the correct architectures. It turned out to be a xCode bug after all. In my Pods Target I had all the correct acrhitectures selected, armv7, armv7s, and arm64.
THE SOLUTION:
Update cocoapods to the newest version that supports 64 arch.
sudo gem update cocoapods
Delete all Valid Architectures and do a project clean (which fails alot..)
Re-Add the architectures that you just removed and voilà!
my fault was an old cocoa pods integration. had to delete the pod-.a files in "/Frameworks" folder and pod-.xcconfig in "/Pods".
-> run 'pod install'
everything fine
Other solution is if you update your pods with new target, you will check libpods.a, maybe was deleted and system not found it. Make sure that libpods is in your Linked Framework and libraries in General information (where you change version, bundle identifier and build).
In my case problem was with Scheme.
go to Product -> Scheme -> Edit Scheme
click on Build
add the Pods static library, and make sure it's at the top of the list
clean and build again
You can fix this issue if this belongs to libraries by selecting your Target, then going to "Build Phases" in "Link Binary With Libraries", and removing ".a" file of that library. After this Clean and Build.
Hope this helps.