前因:

  因为公司上架前后的原因,外围的平台层部分提前上线,而我做的功能部分需要晚一些上线,是单独的一个工程在其他仓库开发。

我的资源文件放在Bundle中。合到主工程中,资源文件不用改,直接拖进去。倒是代码部分因为重名较多,花了大半天时间来改名字。

  过一段时间,需要将我们的代码以Framework的形式,放入另一个项目的平台层中。我的做法是,将代码打包进入Framework,然后资源文件在Bundle中,两部分拖进平台层,资源文件调用等等也都不用改。

因为Android就只有一个aar文件导入平台层。所以对方提出希望我也只提供一个Framework 包。

所以现在就需要改资源文件调用方式了。

以前的做法很简单:

NS_INLINE UIImage * UIResourceBundleSubMove(NSString *strPath){
return [UIImage imageNamed:[NSString stringWithFormat:@"XXXX.bundle/images/move/%@.png",strPath]];
}

现在就是

#define FrameworkPath  [[NSBundle mainBundle] pathForResource:@"VivenSDK" ofType:@"framework"]
#define FrameworkBundle [NSBundle bundleWithPath:FrameworkPath]
#define VivienBundle [NSBundle bundleWithPath:[FrameworkBundle pathForResource:@"Vivien" ofType:@"bundle"]]
#define UIResourceBundleSubMove(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"images/move/%@",imageName] inBundle:VivienBundle compatibleWithTraitCollection:nil] NS_INLINE UIImage * UIResourceBundleMore(NSString *imageName){
return [UIImage imageNamed:[NSString stringWithFormat:@"images/main/%@",imageName] inBundle:VivienBundle compatibleWithTraitCollection:nil];
}

然后再把Framework再拖一份到主工程的Copy Bundle Resources

如果报错,可以通过代码的方式查看报错:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"VivienSDK" ofType:@"framework"];
NSLog(@"path = %@", path); NSBundle *myBundle = [NSBundle bundleWithPath:path];
NSLog(@"myBunlde = %@", myBundle); NSBundle *vivienResBundle= [NSBundle bundleWithPath:[myBundle pathForResource:@"Vivien" ofType:@"bundle"]]; NSLog(@"vivienResBundle = %@", vivienResBundle); UIImage *iconImage = [UIImage imageNamed:[NSString stringWithFormat:@"Images/%@",@"icon_friend"] inBundle:vivienResBundle compatibleWithTraitCollection:nil];
NSLog(@"iconImage = %@", iconImage);

现在发现这样有问题,Archive的时候会报错:

 Failed to generate distribution items with error: Error Domain=DVTMachOErrorDomain Code= "Found an unexpected Mach-O header code: 0x72613c21"
UserInfo={NSLocalizedDescription=Found an unexpected Mach-O header code: 0x72613c21, NSLocalizedRecoverySuggestion=}

因为,静态的framework不能打包进bundle。静态库会编译进二进制文件的。静态framework里面的资源需要重新打包一个bundle。工程里面链接下framework,加入资源bundle就ok了

如果改为动态库可以成功;

1,Sandbox会验证动态库的签名,所以如果是动态从服务器更新的动态库,是签名不了的,因此应用插件化、软件版本实时模块升级等功能在iOS上无法实现;

http://www.jianshu.com/p/f2ffe8325519

最新文章

  1. KBMMW 4.92.00 发布
  2. UVa 1626 Brackets sequence (动态规划)
  3. apache 配置反向代理服务器
  4. object-单例设计模式
  5. Python学习教程(learning Python)--3.3.4 Python的if-elif-else语句
  6. noip2002提高组题解
  7. (转)实战Memcached缓存系统(6)Memcached CAS的多线程程序实例
  8. Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
  9. php 微信 统一下单 接口实例
  10. 微信js-sdk接口的使用及ios深坑
  11. 单纯形求解线性规划(BZOJ1061)
  12. netcorec程序部署配置
  13. Confluence 6 配置时间和日期格式
  14. UOJ#310 【UNR #2】黎明前的巧克力 FWT 多项式
  15. 002.Ceph安装部署
  16. javascript Location对象属性和方法
  17. Docker网络解决方案 - Calico部署记录
  18. 解决IDEA授权报错
  19. 【转】车和家CEO李想回顾创业20年:站在更高层才能看到低层问题
  20. Unity入门&物理引擎

热门文章

  1. ideal使用eclipse快捷键
  2. Javascript-数据类型转换 、 运算符和表达式
  3. 常见web错误码
  4. lua学习之循环打印九九乘法表
  5. zookeeper开发
  6. 启动与关闭WebService
  7. python操作Mysql数据库示例
  8. 移动端点击返回时强制页面刷新解决办法(pageshow)
  9. c# 共享事件处理程序
  10. ElasticSearch相关文章推荐