制作framework ,如何添加圖片,創(chuàng)建一個程工 選擇macOS下的Bundle摆碉,如圖:
建立完成之后塘匣,將target下面的build setting -architectures -base sdk 改成
然后在制作的framework工程里面巷帝,創(chuàng)建一個工具類忌卤,獲取bundle的資源文件,
具體代碼為:
點.h文件
import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface BundleManager : NSObject
- (NSBundle *)getBundlePath;
- (NSString *)getFilePathFromBundle:(NSString *)filePathInBundle;
@end
NS_ASSUME_NONNULL_END
.m 為:
@implementation BundleManager
(NSBundle *)getBundlePath {
return [NSBundle bundleWithPath: [[NSBundle mainBundle] pathForResource:@"KPTestBundle" ofType: @"bundle"]];
}(NSString *)getFilePathFromBundle: (NSString *) filePathInBundle{
NSBundle *myBundle = [CRRobotBundleManager getBundle];
if (myBundle && filePathInBundle) {
return [[myBundle resourcePath] stringByAppendingPathComponent: filePathInBundle];
}
return nil;
}
@end
然后把你的圖片拖進(jìn)工程楞泼,真機(jī)/模擬器 編譯項目驰徊,具體步驟和http://www.reibang.com/p/ac9c23fd2a5e一樣,然后把合并好的bundle 和framework 拖進(jìn)測試demo中堕阔,進(jìn)行測試如圖:
測試結(jié)果如下: