How to check if a static library is built for 64-bit?
Asked Answered
N

3

80

I just built a static library for iOS with the build setting for Architectures set to $(ARCHS_STANDARD_INCLUDING_64_BIT).

I want to make sure that the .a library is properly including that architecture, but when i run lipo -info on it, I see:

Architectures in the fat file: library.a are: armv7 armv7s (cputype (16777228) cpusubtype (0))

Does this mean that arm64 isn't included? If the lipo command can't tell me, is there another way to tell?

I'm running Xcode 5 with the latest Command Line Tools installed.

Nanny answered 24/9, 2013 at 22:1 Comment(0)
W
124

Yes, an arm64 slice is there. To see it, you need to use lipo from the iOS toolchain, not from the host system (which doesn’t know about arm64):

xcrun -sdk iphoneos lipo -info $(FILENAME)
Wrist answered 24/9, 2013 at 22:45 Comment(5)
I'm curious about the difference between /usr/bin/lipo and xcrun's lipo. It seems like they are not one and the same.Eyla
@Eyla It would appear, based on Stephen's answer, that the /usr/bin/lipo is the Mac's version of Lipo, while xcrun's lipo is XCode's lipo. So updating to XCode 5 meant getting a new lipo through xcrun.Nanny
Presumably because the one came out after the other, the lipo that ships with v10.9 appears to recognise arm64 natively. No need to invoke anything from Xcode. Running simply lipo -info $(FILENAME) reported arm64 amongst others for a relevant library for me when tested.Morales
On my machine, running macOS High Sierra, the lipos are both one and the same.Shulock
@Shulock Yes, the default toolchain lipo now knows about all the supported architectures; this was not the case when arm64 was new.Wrist
B
69

good old file can do the trick, too:

$ file libTestFlight.a

libTestFlight.a: Mach-O universal binary with 5 architectures
libTestFlight.a (for architecture armv7):   current ar archive random library
libTestFlight.a (for architecture armv7s):  current ar archive random library
libTestFlight.a (for architecture i386):    current ar archive random library
libTestFlight.a (for architecture x86_64):  current ar archive random library
libTestFlight.a (for architecture cputype (16777228) cpusubtype (0)):   current ar archive random library

It seems that nobody at Apple cared to add the arm64 cputype to file, yet.

Interestingly, in the iOS 7 Tech Talk Videos ("Architecting Modern Apps, Part 2", PDF page 35) they show a working file tool's output:

enter image description here

Belfry answered 21/1, 2014 at 15:2 Comment(4)
which OS version are you on? I'm on 10.9.1, and 'file' only lists the cputype instead of arm64.Conservatism
I don't see an arm64 in your example output, which was what I was having trouble seeingNanny
really cool and quick tool to check for supported file architecturesOnassis
file did not work in my case, it just said current ar archive random library. Using lipo -info did work.Puttyroot
A
19

For a .framework

lipo -info myFramework.framework/MyFramework

Acciaccatura answered 28/12, 2015 at 2:28 Comment(1)
How does it show is lib static or dynamic? My output: Architectures in the fat file: MyFramework are: arm64 x86_64 for both types.Eliaseliason

© 2022 - 2024 — McMap. All rights reserved.