一. Embedded Binaries 方式
1. 把 xx.framework 添加到 Embedded Binaries 中;
2. 保證Build Setting - Runpath Search Paths 中設置路徑,例如:@executable_path/Frameworks(xcode 一般會自動設置好);
3. 代碼中直接使用 xx.framework 頭文件中提供的類即可;
二. NSBundle 加載方式
NSBoundle *frameworkBundle = [NSBundle bundleWithPath:libPath];
if (frameworkBundle && [frameworkBundel load]) {
Class myclass = NSClassFromString(@"testClass");
NSObject *obj = [[myclass alloc] init];
[obj performSelector:@selector(test) withObject:self withObject:frameworkBundle];
}
三. dlopen 加載方式
void* lib_handle = dlopen([libPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_LOCAL);
if (!lib_handle) {
NSLog(@"Unable to open library: %s\n", dlerror());
return;
}
if (dlclose(lib_handle) != 0) {
NSLog(@"Unable to close library: %s\n",dlerror());
}
動態庫的調用方式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
NSArray ,NSSet, NSDictionary
Running_allTheTime
2020-07-02 05:17:35
【轉】ios字符串編碼轉換(utf-8 & gbk)問題
Running_allTheTime
2020-07-02 05:17:34
iOS 基礎 (一)
昨天和今天
2020-02-25 06:53:01
Swift 中的數組 (Array)
骑着蜗牛赛跑
2020-02-25 01:09:27
Swift 中的元組 (Tuples)
骑着蜗牛赛跑
2020-02-25 01:09:27
實現performSelector 傳遞多個參數
sharpyl
2020-02-23 08:26:59
UISegmentedControl的基本用法
TommyYaphetS
2020-02-20 20:46:24
NSArray 之 SEL 的保存
LikeeCat
2019-03-08 13:41:18
離屏渲染的基礎知識整理
LikeeCat
2019-03-08 13:41:18
Xcode10 【libray not found for -lstdc++.6.0.9 】
LikeeCat
2019-03-08 13:41:18
Block 的一些簡單認識
LikeeCat
2019-03-08 13:41:18
NSArray ,NSSet, NSDictionary
Running_allTheTime
2020-07-02 05:17:35
【轉】ios字符串編碼轉換(utf-8 & gbk)問題
Running_allTheTime
2020-07-02 05:17:34