前言:
1实胸、上面的需求他嫡,說(shuō)要做一個(gè)FrameWork給對(duì)面用。
2庐完、寫(xiě)這篇文章是為了記錄我的實(shí)踐過(guò)程钢属。
3、這篇文章是抄的门躯。
第一節(jié)淆党,制作 Bundle
新建工程 Bundle
1 新建bundle.png
Base SDK 改成 iOS
2 basesdk.png
COMBINE_HIDPI_IMAGES 改成 NO
3 combine.png
Installation Directory 這個(gè)貌似不用管
4 dir.png
Skip Install 改成YES
5 install.png
6 添加資源.png
7 添加資源2.png
8 取包.png
第二節(jié),制作 動(dòng)態(tài) FrameWork
1 創(chuàng)建動(dòng)態(tài)fr.png
Build Active Architecture Only 改成NO
2 build.png
Mach-O Type 改為 Dynamic Library
3 Dynamic.png
4 導(dǎo)入.png
5 選擇.png
6 代碼.png
NSBundle *dynamicBundle = [NSBundle bundleForClass:[DynamicView class]];
NSURL *bundelURL = [dynamicBundle URLForResource:@"ResourcePackage" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:bundelURL];
NSString *path = [imageBundle pathForResource:@"y" ofType:@"jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.image = [UIImage imageWithContentsOfFile:path];
7 暴露文件.png
8 暴露文件2.png
9 打包.png
10 導(dǎo)入2.png
11 添加1.png
12 驗(yàn)證.png
第三節(jié)讶凉,制作 靜態(tài) FrameWork
Build Active Architecture Only 改成NO
1 build.png
Mach-O Type 改為 Static Library
2 macho.png
3 導(dǎo)入bundle.png
4 寫(xiě)代碼訪問(wèn).png
NSString *bundlePaht = [[NSBundle mainBundle] pathForResource:@"Static.framework/ResourcePackage" ofType:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithPath:bundlePaht];
NSString *path = [imageBundle pathForResource:@"y" ofType:@"jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.image = [UIImage imageWithContentsOfFile:path];
5 暴露頭文件.png
6 暴露頭文件2.png
7 導(dǎo)包.png
8 選擇導(dǎo)入.png
9 導(dǎo)包2.png
10 導(dǎo)包3.png
11 導(dǎo)包4.png
12 完成.png
感謝大佬:
包含 Bundle 資源的 framework 的正確打包方式