本文介绍了ios中的框架包含内部的静态或动态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到过多个站点,这些站点描述了框架可以包含静态库和动态库.但是我如何确定框架实际包含的是动态库还是静态库.我想首先求助于扩展名(.a 用于静态库,.dylib 用于动态库),但我在我正在试验的框架内看到的只是没有为打包在其中的二进制文件提供扩展名.有什么办法可以找到它是静态库还是动态库.

I have come across multiple sites describing that frameworks can contain both static as well as dynamic library. But how do I identify if what the framework actually contains is a dynamic library or a static library. I thought of first taking help of extension (.a for static library, .dylib for dynamic library) but all I could see inside the framework that I was experimenting was that no extensions were provided for the binary file that was packaged inside. Is there any way I can find whether it's a static library or a dynamic library.

我还阅读了 Landon Fuller 关于静态库的帖子 http://landonf.bikemonkey.org/code/ios/Radar_15800975_iOS_Frameworks.20140112.html他在其中提到框架为库提供了两级命名空间,但它是否涵盖了正常的调试符号而不仅仅是依赖关系,甚至对于封装在框架内的静态库也有效.

Also I have read Landon Fuller's post on static libraries http://landonf.bikemonkey.org/code/ios/Radar_15800975_iOS_Frameworks.20140112.htmlin which he mentions that frameworks provide two level namespace for libraries but does it cover normal debug symbols and not just dependencies and does it work even for static libraries packaged inside frameworks.

例如如果我在框架内以及它所链接的项目代码库中有相同的调试符号会发生什么.两级命名空间在这种情况下是否有效.

E.x. what happens if I have the same debug symbol inside a framework as well as in the project codebase to which it is linked. Will two level namespace work in that scenario.

也据此作者 http://ddeville.me/2014/04/dynamic-链接/框架是包含动态库、头文件和资源的包或包.

Also according to this author http://ddeville.me/2014/04/dynamic-linking/framework is a bundle or package containing a dynamic library, header files and resources.

根据以下帖子 库?静止的?动态的?还是框架?另一个项目中的项目它说框架可以包含静态库和动态库.

As per the following post Library? Static? Dynamic? Or Framework? Project inside another projectit says frameworks can contain both static as well as dynamic libraries.

我对此感到非常困惑.有人可以解释 iOS 中的框架,它们包含什么以及它们如何在两级命名空间方面工作.

I am so confused by this. Can somebody explain framework in iOS as to what they contain and how they work in terms of two level namespace.

推荐答案

检查静态还是动态

确定文件扩展名何时显式很简单

It is simple to determine when a file extension is explicit

  • .a - 静态库
  • .dylib - 动态库
  • .a - static library
  • .dylib - dynamic library

变体 1:

你可以使用file命令

you can use file command

file /some_path/<framework_name>.framework/<framework_name>

//possible results
current ar archive random library //static library
dynamically linked shared library //dynamic library

*可以在构建设置中将其更改为 Mach-O 类型Static Library targetDynamic library 结果会生成 .a 文件,file 命令显示动态链接的共享库,但它将是静态库

*It is possible to change it in Build Settings a Mach-O type from Static Library target to Dynamic library as a result .a file will be generated, file command show you dynamically linked shared library but it will be static library

变体 2:[otool 静态或动态]

*有同样的副作用

[词汇]
[静态与动态框架]

这篇关于ios中的框架包含内部的静态或动态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-11 04:21