美文网首页
iOS 包含 Bundle 的 FrameWork

iOS 包含 Bundle 的 FrameWork

作者: Yuency | 来源:发表于2019-03-29 12:49 被阅读0次

    前言:

    1、上面的需求,说要做一个FrameWork给对面用。
    2、写这篇文章是为了记录我的实践过程。
    3、这篇文章是抄的。

    第一节,制作 Bundle

    新建工程 Bundle


    1 新建bundle.png

    Base SDK 改成 iOS

    2 basesdk.png

    COMBINE_HIDPI_IMAGES 改成 NO

    3 combine.png

    Installation Directory 这个貌似不用管

    4 dir.png

    Skip Install 改成YES

    5 install.png 6 添加资源.png 7 添加资源2.png 8 取包.png

    第二节,制作 动态 FrameWork

    1 创建动态fr.png

    Build Active Architecture Only 改成NO

    2 build.png

    Mach-O Type 改为 Dynamic Library

    3 Dynamic.png 4 导入.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 导入2.png 11 添加1.png 12 验证.png

    第三节,制作 静态 FrameWork

    Build Active Architecture Only 改成NO

    1 build.png

    Mach-O Type 改为 Static Library

    2 macho.png 3 导入bundle.png 4 写代码访问.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 导包.png 8 选择导入.png 9 导包2.png 10 导包3.png 11 导包4.png 12 完成.png

    感谢大佬:
    包含 Bundle 资源的 framework 的正确打包方式

    下一篇

    iOS Framework 包含 图片 Plist XIB

    相关文章

      网友评论

          本文标题:iOS 包含 Bundle 的 FrameWork

          本文链接:https://www.haomeiwen.com/subject/quklbqtx.html