Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check a lib (static or dynamic) is built for iOS simulator or Mac OSX

Tags:

xcode

macos

ios

My work is blocked by 'ld: warning: URGENT: building for iOS simulator, but linking in object file built for OSX' or vice versa, so I want to find out which platform a lib was built for.

I tried:

file tmp/openssl/lib/libcrypto.dylib
lipo -info tmp/openssl/lib/libcrypto.dylib
otool -hv -arch all tmp/openssl/lib/libcrypto.a
otool -hv -arch all /usr/local/opt/openssl/lib/libcrypto.a

and only thing I got is CPU type x86_64 or i386.

like image 982
haolun Avatar asked Oct 28 '25 08:10

haolun


1 Answers

Use vtool with -show-build it will tell you the platform the binary is targeting.

% vtool -show-build foobar.dylib 
build/layers/foobar.dylib:
Load command 8
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform IOS
    minos 13.0
      sdk 17.0
   ntools 1
     tool LD
  version 1015.7

Currently vtool only operates on final linked binaries, such as executable files, dynamic libraries, and bundles.

like image 160
jpr42 Avatar answered Oct 31 '25 00:10

jpr42