简体   繁体   English

ios应用程序在运行时在哪里找到与它链接的Apple提供的dylib?

[英]Where does an ios app find at runtime the Apple provided dylibs it links with?

I'm trying to make some light in my head about what happens with applications running on iOS. 我正在想一想关于iOS上运行的应用程序会发生什么情况。 I can see down under /Developer/Platforms/iPhoneOS.platform there are several dylibs that are probably linked against upon using certain Frameworks? 我可以在/Developer/Platforms/iPhoneOS.platform下看到在使用某些Framework时可能链接的几个dylib? In any case, my question is general: if for whatever reason an iOS app comes to be built with a dependency on an official (ie Apple provided) dylib, what will happen at runtime when running on an iDevice? 无论如何,我的问题很笼统:如果出于某种原因要构建依赖于官方(即Apple提供的)dylib的iOS应用,那么在iDevice上运行时会发生什么?

  1. The dylib is bundled together with the application dylib与应用程序捆绑在一起
  2. The dylib is already on the device and the runtime linker will resolve the dependencies using what it finds on the device. dylib已经在设备上,运行时链接程序将使用在设备上找到的内容来解决依赖关系。

I think 2) is what should happen, but I'm unsure and couldn't find any places that clearly states that. 我认为2)应该发生什么,但是我不确定,也找不到任何明确说明这一点的地方。

Yes your right it's 2) the libraries are dynamically linked. 是的,这是您的权利2)库是动态链接的。 You can investigate using otool , for example: 您可以使用otool进行调查,例如:

$ cd /path/to/App.app
$ lipo -info appbinary 
Non-fat file: appbinary is architecture: armv7
$ otool -L appbinary 
appbinary:
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 675.0.0)
    /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 881.0.0)
    /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 1600.0.0)
    /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 600.0.0)
    /System/Library/Frameworks/QuartzCore.framework/QuartzCore (compatibility version 1.2.0, current version 1.7.0)
    /System/Library/Frameworks/OpenGLES.framework/OpenGLES (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/OpenAL.framework/OpenAL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration (compatibility version 1.0.0, current version 432.0.0)
    /System/Library/Frameworks/CFNetwork.framework/CFNetwork (compatibility version 1.0.0, current version 548.0.3)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 53.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 161.1.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 6.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM