I try to understand the different architectures for iOS, and when I need which.
I have a Hello World example. Is my assumption correct that, if I run it in the Xcode Simulator, I need to compile everything including my dependencies for x64 (because it's running on my computer).
And for my attached iPhone it's getting compiled for only that architecture. And for Generic iPhones my example will be a multiarchitecture app (arm64 arm64 armv7 armv7e) so it can run on a variety of architectures. Is that correct?
Thanks for your insight.
P.S. So if my example links foo.a, but foo.a is just arm64 arm64 armv7 armv7e but not x64, I could compile my app for iPhones but not run it in my simulator
This is essentially correct although you have two arm64 listed above; it should be arm64 and arm64e.
As to what architectures get built, it depends on the setting "Build Active Architecture Only". The typical Debug config has this set to Yes, so it only builds for the architecture of the device that you're targeting.
A Release config has this set to No, so it compiles for all architectures specified in "Architectures", which usually $(ARCHS_STANDARD), i.e., the architectures you listed.
As to your PS, you are correct that a .a file with only ARM archs could not be linked to a Simulator target.
Both my Target and Project Build Settings are set to arm64 armv7 armv7s as the valid architectures.
Architectures: Standard architectures (armv7, arm64) - $
Valid Architectures: arm64 armv7 armv7s
When I archive and upload the build, iTunes Connect classifies it as only arm64. Under "Supported Architectures", iTunes Connect shows only arm64. This makes it so my app is not available to older devices (iPhone 5, iPad 2, iPad Mini 1, etc)
Has anybody ever come across this before? I'm supporting armv7 in Xcode settings, but that support is not being included in the build I am archiving.
Even though this topic already has it's accepted answer, this one is not true in any case.
There can be situations, in which your app has all the known architectures as valid architectures, has Build Active Architecture Only to NO for Release and still getting this issue.
The reason is: If your deployment target is iOS >= 11, then this will run on devices starting with iPhone 5s only. iPhone 5s is the first arm64 device. Hence XCode (at least in version 10) does NOT include anything else than arm64, even though you have all the settings made as suggested.
Usually this is not a problem, but it can lead to the "Too many symbols" issue, if you are using Pods, which come with binaries for architectures < arm64. Those will have symbols for armv7, even though your upload does not have a binary for armv7.
So it is suggested to fight this by altering the PodFile and include only symbols for arm64.
I suspect you are building the active architecture only.
To fix this set Build Active Architecture Only to NO for Release configuration.
I am getting an Undefined Symbols For Architecture i386 only when I try to run in the iPhone Retina (4-inch 64-bit) simulator. Project runs fine in the iPhone Retina (4-inch) simulator and iPhone Retina (3.5-inch) simulator.
I changed the Architectures in my Build Settings to armv7 and armv7s (both Architectures and Valid Architectures) but still will not work in 64-bit simulators.
I am using Xcode 5.1.1 and Cocos2D.
Okay so since I was using Cocos2D, there are two Targets ... one for my project, and a second Target that is called cocos2d libraries.
I had only changed the Architectures on my project Target, but not on the cocos2d libraries Target.
Once I changed the Architectures on this second Target as well to armv7 and armv7s then it worked properly and will now run in the 64-bit simulators as well.
I have a static library lipo'd for iOS and OS X with 5 architectures (x86_64, i386, armv7, armv7s, arm64).
The x86_64 architecture was built using the macosx SDK
The i386 architecture was built using the iphonesimulator SDK
The ARM architectures were built using the iphoneos SDK
When I try to link the resulting library in an example App it works when building for a device or for a 32-bit iOS simulator target. But when I try to build it for a 64-bit iOS simulator target I get a linker error:
ld: framework not found CoreServices for architecture x86_64
If I remove the x86_64 slice from the fat library it works for all devices and simulators.
I assume it's because the linker prefers the x86_64 architecture if it's there for the 64-bit simulator. But since it was compiled and linked for the macosx SDK it has the OS X dependencies somehow encoded.
I tried adding a second x68_64 slice for the iphonesimulator SDK but lipo won't let me. Also I tried to find a way to make the simulator use the i386 architecture even for 64-bit builds, but so far no luck.
If absolutely necessary I can create 2 binaries which would solve this but I would really prefer having them in one file. Is there a way to achieve this?
I solved it by only building it for the iOS device and simulator. The 64bit slice of the iOS Simulator SDK equally works for iOS and OS X targets, provided you don't need any other frameworks than what's shared between OS X and iOS (Foundation only in my case).
Project and Pods:
Build Settings ---> Link Frameworks Automatically change YES to NO, and rebuild static library ,it is work!
After updating to Xcode 5.1, I can no longer build my project for the 64-bit simulator, receiving this error:
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
These are my target build settings:
I tried changing "Build Active Architecture" to No, as well as adding "i386" to the "Valid Architectures", unfortunately neither worked.
Thanks for any suggestions!
What you need to do is just set the ONLY_ACTIVE_ARCH to NO (at least works for me). Below is a screenshot for it:
EDIT:
As far as I know (please point it out if there's something wrong, thanks), if you set ONLY_ACTIVE_ARCH to YES, it means the Xcode will only build for the active architecture (which refers to the device that's active in Xcode currently). Seems Xcode's default setting is set Debug to YES, so it won't build binaries for other architectures when you only want to build for a special device that connected to your Mac.
The reason failed to build might be that, the project does not support the architecture of the device you connected. So the best solution is to add the right architecture for your device. Below is a list for architectures & the devices that support:
ARMv8/ARM64: iPhone 6, iPhone 5s, iPad Air, Retina iPad Mini
ARMv7s: iPhone 5, iPhone 5c, iPad 4
ARMv7: iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini
ARMv6: iPhone, iPhone 3G, iPod 1G/2G
So why "set the ONLY_ACTIVE_ARCH to NO" works? Because the device can still run the binary that built for all architectures you added (pass the build), but will lose some performance. This's just a quick solution, but not best.
Note: The more architectures you added, the bigger the binary will be generated. So it's good to choose right architectures for your project. ;)
I had the same error message after upgrading to XCode 5.1. Are you using CocoaPods? If so, this should fix the problem:
Delete the "Pods" project from the workspace in the left pane of Xcode and close Xcode.
Run "pod install" from the command line to recreate the "Pods" project.
Re-open Xcode and make sure "Build Active Architecture Only" is set to "No" in the build settings of both the "Pods" project and your own project.
Clean and build.
Add arm64 to the target's valid architectures. Looks like it adds x86-64 architecture to simulator valid architectures as well.
If you are using CocoaPods, the most likely problem is because your Pods project Build Settings for Build Active Architecture Only is set to Yes for Debug.
The solution is simple. Change it to No.
Similarly, change to No for your application project.
I had similar issue. Got it solved by changing "Architecture" to "$(ARCHS_STANDARD_32_BIT)" in Build Settings for Project.
Now, you have to select Standard architectures (armv7, arm64) - $(ARCHS_STANDARD) since apple recommends apps to be build on 64-bit architecture. Click : Apple document
Add:
Architectures: $(ARCHS_STANDARD_INCLUDING_64_BIT)
Valid architectures: arm64 armv7 armv7s
Just in case, for anyone still encountering the issue despite following the above, check that the simulator you are running is also the supported one. I had mine specified to arm7 and arm7s but was trying to run the app on a 64 bit simulator.
To avoid having "pod install" reset only_active_arch for debug each time it's run, you can add the following to your pod file
# Append to your Podfile
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
Just add arm64 in valid architecture.i hope it will work for you.
My problem was that the Pods project was targeting OS X, despite my Podfile having platform :ios. I'm using cocoapods 0.35.0.rc2.
To fix it, select the Pods project in the project navigator, and check that the Pods PROJECT node (mind you, not the Pods target) is targeting iOS. That is, the architectures build settings should be:
Architectures: $(ARCHS_STANDARD)
Base SDK: iOS 8.1
Supported Platforms: iOS
Valid architectures: $(ARCHS_STANDARD)
I also wanted to build all architectures, so I added the following to the Podfile:
post_install do | installer |
installer.project.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
I had to add the following i386 and x86_64 to Valid Architectures. I'm running Xcode 7.2 and targeting iOS 8+. I already had armv7, armv7s and arm64 in there and that was working in Xcode 6.4.
I faced the same problem when running my app on iPad using xcode 5.1. It got resolved by removing armv7s from 'valid architectures' and setting the 'build active architectures only' value to No. Both these fields can be found in your app->targets->build settings->architectures.
I arrived at this question due to a problem with command line build for simulator in Xcode 7.2. In case anyone else gets here with the same issue, I will share the solution I found:
Apparently there is a bug in Xcode 7.2 that causes xcodebuild to fail when trying to build for simulator. The solution is to specify the option "-destination", e.g:
xcodebuild -project TestBuildCmd.xcodeproj -scheme TestBuildCmd -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' build
Update
The above example command will build a binary including the graphics for iPhone 6 only. If the binary is run on other simulators, the iPhone 6 graphics is scaled to the platform. A better workaround which contains all graphics for all platforms is to specify the parameter PLATFORM_NAME=iphonesimulator, for example:
xcodebuild -project TestBuildCmd.xcodeproj -scheme TestBuildCmd -sdk iphonesimulator -arch i386 PLATFORM_NAME=iphonesimulator build
Try removing all previous architectures (i.e. remove the ARCHS_STANDARD setting) at the same time as you add i386 to the Architectures. This should change the active architecture to i386. I encountered a similar issue when I tried to build for armv7 by default, but it kept trying to build for arm64. I changed ARCHS_STANDARD to ARCHS_STANDARD_32_BIT, and this changed the active architecture chosen.
In acrhiecture - sometimes to support 6.0 and 7.0 , we exlude arm64
In architectures - > acrchitecture - select standard architecture arm64 armv7 armv7s.
Just below in Valid acrchitecture make user arm64 armv7 armv7s is included.
This worked for me.
I solved this problem using #Kjuly's answer and the specific line:
"The reason failed to build might be that, the project does not support the architecture of the device you connected."
With Xcode loaded it automatically set my iPad app to iPad Air
This caused the dependancy analysis error.
Changing the device type immediately solved the issue:
I don't know why this works but this is a very quick answer which saved me a lot of fiddling around in the background and instantly got the app working to test. I would never have thought that this could be a thing and something so simple would fix it but in this case it did.
I found that it was necessary to enter the architecture names by hand:
I don't know why this was necessary, i.e. why these values were not inherited from Xcode itself. But as soon as I did this, the problem went away.
In Valid architectures: Select each entry (release, debug) and build and press backspace. It should work