動態庫載入過程
1,將framework引入工程中比如Dylib.framework
2,設定target--->Build Phases--->Link Binary with Libraries,新增framework
3,設定target--->Build Phases---->Copy Bindle Resource,
4,新增Copy Files,
如圖:


5,設定Build Settings---->Linking----->Runpath Search Paths---->@executable_path
6,程式碼部分:
在使用的地方引入#import <Dylib/Dylib.h>
- (IBAction)bundleLoadAction:(id)sender {
NSLog(@"bundleLoadAction");
//NSString *documentsPath = [NSString stringWithFormat:@"%@/Documents/Dylib.framework",NSHomeDirectory()];
NSString*documentsPath = [NSStringstringWithFormat:@"%@/Dylib.framework",[[NSBundlemainBundle]bundlePath]];
[selfbundleLoadDylibWithPath:documentsPath];
}
- (void)bundleLoadDylibWithPath:(NSString*)path
{
_libPath= path;
NSError*err =nil;
NSBundle*bundle = [NSBundlebundleWithPath:path];
if([bundleloadAndReturnError:&err]) {
NSLog(@"bundle load framework success.");
}else{
NSLog(@"bundle load framework err:%@",err);
}
}
- (IBAction)trigerAction:(id)sender {
NSLog(@"trigerAction");
ClassrootClass =NSClassFromString(@"Person");
if(rootClass) {
idobject = [[rootClassalloc]init];
[(Person*)objectrun];
}
}
三個函式可看到效果。
相關文章
- DLL動態庫動態載入
- QLibrary 載入動態庫
- 使用dlopen載入動態庫
- html載入過程HTML
- runtime載入過程
- 類載入過程
- Android native層動態載入so庫Android
- springboot引導上下文載入過程和配置載入過程Spring Boot
- JVM類載入過程JVM
- 載入動態連結庫——dlopen dlsym dlclose
- 啟動優化之動態庫延遲載入優化
- Oracle資料庫啟動過程及狀態詳解Oracle資料庫
- java類的載入過程Java
- 頁面載入全過程
- 整理類載入的過程
- 類的載入過程概述
- 動態載入UserControl
- 為.Net專案新增動態庫載入路徑
- python動態載入(三)Python
- vue 動態載入元件Vue元件
- Java動態載入類Java
- goloader - golang動態載入Golang
- oracle11g啟動過程中載入配置檔案Oracle
- C# 動態載入元件類庫,支援熱插拔元件C#元件
- Android HAL模組的載入過程Android
- JS 頁面載入過程問題JS
- 瀏覽器頁面載入過程瀏覽器
- JVM(六):探究類載入過程-下JVM
- Android fragment 標籤載入過程分析AndroidFragment
- 三-類的載入過程詳解
- django 動態查詢實現過程Django
- 下拉表關聯非同步載入- 引數動態過濾非同步
- ListView動態載入資料View
- 指令碼的動態載入指令碼
- 從輸入 URL 到頁面載入全過程
- 虛擬機器類載入機制_類載入的過程虛擬機
- 【JVM進階之路】十三:類載入過程JVM
- JVM之類載入器、載入過程及雙親委派機制JVM
- PostgreSql擴充套件Sql-動態載入共享庫(C函式)SQL套件函式