iOS库编程入门

1,Introduction to Framework Programming Guide
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html#//apple_ref/doc/uid/10000183i
2,Dynamic Library Programming Topics
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/000-Introduction/Introduction.html#//apple_ref/doc/uid/TP40001908-SW1

1,库包的解剖
1.1,一个包含额外资源类型的库

MyFramework.framework/
    Headers      -> Versions/Current/Headers
    MyFramework  -> Versions/Current/MyFramework
    Resources    -> Versions/Current/Resources
    Versions/
        A/
            Headers/
                MyHeader.h
            MyFramework
            Resources/
                English.lproj/
                    Documentation
                    InfoPlist.strings
                Info.plist
        B/
            Headers/
                MyHeader.h
            MyFramework
            Resources/
                English.lproj/
                    Documentation
                    InfoPlist.strings
                Info.plist
        Current  -> B

1.2,伞型库

CoreServices.framework/
    CoreServices           -> Versions/Current/CoreServices
    CoreServices_debug     -> Versions/Current/CoreServices_debug
    CoreServices_profile   -> Versions/Current/CoreServices_profile
    Frameworks             -> Versions/Current/Frameworks
    Headers                -> Versions/Current/Headers
    Resources              -> Versions/Current/Resources
    Versions/
        A/
            CoreServices
            CoreServices_debug
            CoreServices_profile
            Frameworks/
                CarbonCore.framework
                CFNetwork.framework
                OSServices.framework
                SearchKit.framework
                WebServicesCore.framework
            Headers/
                Components.k.h
                CoreServices-gcc3.p
                CoreServices-gcc3.pp
                CoreServices.h
                CoreServices.p
                CoreServices.pp
                CoreServices.r
            Resources/
                Info-macos.plist
                version.plist
        Current             -> A

1.3,库的版本
大版本及小版本的区别
修改库

1.4,库和绑定
1.4.1,动态共享库
不像程序在内存中维护一块内存,所有的应用共享同一个拷贝。因为库时动态链接的,辛苦可以在不重新编译程序的情况下动态安装。
1.4.2,符号绑定
能够在运行时绑定符号的能力,是通过Mach-O动态共享库的内部结构实现的。
在运行时,如果需要,动态链接编辑器会动态加载并链接那些模块

1.5,库和弱链接
支持老版本是开发者面临的大问题。如果应用调用老版本的接口会失败甚至崩溃。苹果用若链接符号解决了这个问题。
当库中的符号被定义为弱链接时,符号在进程运行时不需要表示出来。
在定义库时可以同weak_import表示

extern int MyFunction() __attribute__((weak_import));
extern int MyVariable __attribute__((weak_import));

2,动态库概要
使用静态库的App

使用动态库的App

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值