Why does Xcode build for arm64 even when excluded? - ios

I am trying to solve a problem related to Xcode 12, building for iOS Simulator, but linking in an object file built for iOS, for architecture 'arm64'
As an experiment, I wanted to see if I could configure one of my frameworks to only build x86_64 for all cases.
Here is my config:
You can see I have overridden the architectures to be x86_64 and I am excluding arm64. I am also only building active architectures only. There is no way that arm64 should ever be considered during a build.
And yet...
Here is the output of a build the very next moment. It's tons of source files that indicate they are still being compiled for arm64.
Can anyone explain this discrepancy? I am running the latest Xcode, 13.2.1, on a new M1 Max laptop.

Related

object file built for free standing (BlackBerry Dynamics iOS SDK)

I'm having trouble to build an external pre built dependency. It throws the following error:
In /Users/me/Projects/app/ThirdParty/GoodFiles/GD.framework/GD(nondga_helper.o), building for iOS, but linking in object file built for free standing, file '/Users/me/Projects/app/ThirdParty/GoodFiles/GD.framework/GD' for architecture arm64
One of the questions that really bothers me is that I don't have a real idea what "free standing" really means. I thought it had to do with being a fat binary, but after running lipo -thin arm64 GD -o GD (and verifying with -info that it really worked) in one of my build scripts I'm still seeing the same problem.
I also tried to exclude arm64 from the simulator and x86_64 from iOS builds in Excluded Architectures as mentioned elsewhere, but that didn't work either.
Removed the Xcode 12 reason. This already doesn't compile anymore in Xcode 11.
Hi there are new BB certification files you have to add along with the usual GD.Framework files. These are documented on Blackberry website
New Xcode build system
GD.framework
BlackBerryCerticom.xcframework
BlackBerryCerticomSBGSE.xcframework
Legacy Xcode build system
GD.framework
BlackBerryCerticom.framework
BlackBerryCerticomSBGSE.framework
https://docs.blackberry.com/en/development-tools/blackberry-dynamics-sdk-ios/8_1/blackberry-dynamics-sdk-ios-devguide/Steps-to-get-started-And-iOS/rqx1490022241984/Prepare-an-app-to-use-the-static-framework
Check:
Xcode > Preferences > Locations > Command Line Tools
In my case it was set to Xcode 12 after installing Xcode 12. There is NO Xcode 12 proof solution until mid December.

Build iOS framework towards My Mac with Xcode 11.2 report errors

I upgrade my xcode recently.
When I build my iOS frameworks towards My Mac, most of them works fine. However one framework build failed. The error as follow:
My Mac doesn’t support any of XXX.framework’s architectures. You can add My Mac’s x86_64h architecture to XXX.framework’s Architectures build setting.
I have tried add x86_64h, x86_64, and arm64e to valid architecture, but it doesn't work.
I also tried to compare build settings between these frameworks, but failed to find out an solution.
Any suggestion to solve this problem?
I had the same issue, then I changed Valid Architectures to arm64 x86_64.
After this, I was able to build the framework and use it.

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.

iOS 10.1 Simulator shows "Application May Slow Down Your iPhone"

When running an app for the first time from Xamarin Studio on an iOS 10.1 Simulator, I got the following message:
app name May Slow Down Your iPhone
The developer of this app needs to update it to improve its compatibility.
The app runs normally, and the message does not appear when I run it for the second time. How can I get rid of this message?
It turned out that the app was only built for the i386 architecture and not for the newer x86_64 one. After changing this in the build settings (to "i386 & x86_64", though I suppose "x86_64" would help as well) it didn't occur anymore.
Ref: https://releases.xamarin.com/stable-release-cycle-8-service-release-0-w-xcode8-1-support/
Remaining higher visibility known issues related to Xcode 8.1
[Xamarin Studio] – 45861 – “May Slow Down Your iPhone … The developer of this app needs to update it to improve its compatibility.” because of default “i386” supported architecture setting in the iPhoneSimulator configuration on new projects
Fix: Change Project options > iOS Build > Supported architectures to x86_64 (instead of the default i386) for the iPhoneSimulator configuration.
Why This Warning Appears
Apple added this warning in iOS 10.1. This article succinctly defines the warning:
"In a bid to push developers to update their apps to 64-bit frameworks, Apple has introduced a new warning message with iOS 10.1. The message reads: “[App Name] may slow down your iPhone”, with a slug, “The developer of this app needs to update it to improve its compatibility.” This message only appears if you're running a 32-bit app.
This won’t affect a vast majority of iOS users as Apple stopped accepting updates to 32-bit apps in June 2015."
Update: Before Cycle 8 Service Release 2, the default Build Architecture for the iOS Simulator Build Configuration did not include the 64-bit architecture.
How To Resolve/Prevent This Warning
For Xamarin apps that were created before C8SR2, you can prevent this error message by manually changing the iOS Build Architecture.
Build Architecture Causing Warning
This iOS Build Architecture does not include the 64-bit Architecture
Build Architecture Resolving/Preventing Warning
This iOS Build Architecture does include the 64-bit Architecture
Update: New Xamarin.iOS Apps
In the latest Stable version of Xamarin, Cycle 8 Service Release 2, the default Build Architecture for new Xamarin.iOS apps is x86_64 for iOS Simulator builds.
i.e. When you create a new app (File -> New), the default Build Architecture is x86_64 for iOS Simulator builds.
Compiling for x86_64
You need to build your app for the x86_64 architecture, whether you're using Xcode or Xamarin. In particular when building from the command line with xcodebuild, set ONLY_ACTIVE_ARCH=NO and be sure not to constrain the target architectures with -arch i386 because you need to allow the compiler to build for x86_64 too.
Verifying your app
To verify that your app is built for x86_64, unzip your IPA file and find the binary. <filename> and <app> are the names of your IPA and app respectively:
unzip <filename>.ipa -d $TMPDIR/app
file $TMPDIR/app/Payload/<app>.app/<app>
If you see Mach-O 64-bit executable x86_64, your app is built for x86_64. You might also see that your app is a universal binary, which is OK too as long as it contains an x86_64 slice:
Mach-O universal binary with 2 architectures
(for architecture x86_64): Mach-O 64-bit executable x86_64
(for architecture i386): Mach-O executable i386

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.

Resources