iOS architectures vs Valid Architectures and repercussions of settings - ios

I have a library that is not 64 bit ready, so I removed arm64 from "architectures". I was then able to use the application on 64 bit platforms in the simulator. (It didn't work until I made that change. It would just crash)
When I was going to create an archive for my app to send to the store, I got the following error:
(null): File is universal (3 slices) but does not contain a(n) armv7s slice: /Users/cmuench/Desktop/PHP-Point-Of-Sale-Repos/PHP-Point-Of-Sale-iOS/PHP Point Of Sale/starSDK/StarIO.framework/StarIO file '/Users/cmuench/Desktop/PHP-Point-Of-Sale-Repos/PHP-Point-Of-Sale-iOS/PHP Point Of Sale/starSDK/StarIO.framework/StarIO' for architecture armv7s
I think this is because the another framework I use I am using for a receipt printer doesn't support armv7s.
3 questions:
Why was it able to work in debugging environment but then fail when creating an archive? The only way I could get the archive to work was by removing armv7s from "valid architectures"
Will my application work on newer hardware that uses the armv7s platform? (I don't have the newer hardware)
What is the difference between "architectures" and "Valid Architectures" in build settings?

In the simulator, the architecture is i386 not armv7 or armv7s. You would only get this error if you tried to run a debug session in a iOS device which had an armv7s chip.
Yes, arm64 and armv7s will run armv7 binaries.
Build Setting Reference describes all the build settings.
ARCHS (Architectures): Space-separated list of identifiers. Specifies the architectures (ABIs, processor models) to which the binary is targeted. When this build setting specifies more than one architecture, the generated binary may contain object code for each of the specified architectures.
VALID_ARCHS (Valid Architectures): Space-separated list of identifiers. Specifies the architectures for which the binary may be built. During the build, this list is intersected with the value of ARCHS build setting; the resulting list specifies the architectures the binary can run on. If the resulting architecture list is empty, the target generates no binary.

Related

Which architectures are used when I compile something for iOS?

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.

armv7 not included in build

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.

Xcode 6.3 missing required architecture arm64 [duplicate]

Just upgraded to Xcode 5.1, getting the following error:
ignoring file
...Dependencies/SalesforceNetworkSDK/libSalesforceNetworkSDK.a,
missing required architecture arm64 in file
...Dependencies/SalesforceNetworkSDK/libSalesforceNetworkSDK.a (3
slices)
If I turn off build active archs only and remove arm64 from valid archs I get:
Build/Products/Debug-iphoneos/libPods.a, file was built for archive
which is not the architecture being linked (armv7)
According to apple's release note, see the following note point.
Note:
Be aware of the following architectures issues when opening your
existing projects in Xcode 5.1:
When building for all architectures, remove any explicit
architectures setting and use the default Standard Architectures
setting. For projects that were previously opted-in using “Standard
Architectures Including 64-Bit”, switch back to the “Standard
architectures” setting.
When opening an existing project for the first time, Xcode 5.1 may
display a warning about the use of the Xcode 5.0 architectures
setting. Selecting the warning provides a workflow to revise the
setting.
Projects not able to support 64-bit need to specifically set the
architectures build setting to not include 64-bit.
So you've to set architecture as below to support libs architecture.
Reference from this post.
Update: From May 15, you've to take build from 5.1.1, see this post.
Don't know previous iOS but Setting Build Active Architecture Only to YES in iOS 8 did the trick.
I ended up getting my project to build by (1) turning off build active archs only (2) removing arm64 from valid archs and (3) making sure that the Pods project was building for only armv7 and armv7s.
Also worth noting here, that at the time of writing this edit, Salesforce mobile SDK was not available for arm64
I just changed the Debug from Yes to No,
Build Settings -> Architectures -> Build Active Architecture Only -> Debug -> NO.
This one fixed my error.

Dynamic library image doesn't contain x86_64, i386 architectures

I'm trying to build dynamic library for iOS, combined with architectures
armv7
armv7s
arm64
i386
x86_64
Here is my target's Build Settings
As you can see I've added x86_64 and i386 to Architectures and Valid Architectures, also Build Active Architecture Only is set to NO.
So after building my binary, I'm checking supported architectures by running file myDl.dylib in Terminal
myDl.dylib (for architecture armv7): Mach-O dynamically linked shared library arm
myDl.dylib (for architecture arm64): Mach-O 64-bit dynamically linked shared library
So it means it has been compiled for armv7 and arm64, and dlopen() fails on simulator with error "Unsupported architecture".
What am I doing wrong?
PS. When I use custom build script and use there "lipo" tool to create fat library, it works fine, but I don't like that way, and I want to get it normal working on Xcode.
Set armv7,armv7s and arm64 in valid architecture and make sure if you use any thirdparty framework that must be include 64 bit support.

Can you make Xcode 5.1 target dependencies build only valid architectures?

With Xcode 5.1 Apple has made $(ARCHS_STANDARD) include arm64. If your project does not support arm64 you can simply change the architecture build setting to $(ARCHS_STANDARD_32_BIT) and it will not build arm64.
However if you have a target dependency that uses $(ARCHS_STANDARD) it will build arm64 and you will get an error because your project is expecting symbols that are not arm64.
Is there a way to make your target dependency aware what you are building against so it will build the valid architecture?
Our quick fix was to leave the Architectures entry as $(ARCHS_STANDARD) but change Valid Architectures to armv7 and armv7s until the third party libraries we're using are updated.

Resources