码迷,mamicode.com
首页 > 其他好文 > 详细

热更新--动态加载framework

时间:2016-08-17 22:46:15      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

1.准备工作:先自己封装一个framework:http://www.cnblogs.com/sunjianfei/p/5781863.html

2.把封装好的framework压缩成zip,放到本地服务器端

3.下载压缩包,并且解压,参照:http://www.cnblogs.com/sunjianfei/p/5781799.html

4.添加并设置Application requires iPhone env。。。。。为yes

技术分享

5.动态加载下载下来的framework库文件:

  NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *bundlePath = [NSString stringWithFormat:@"%@/%@",documentDirectory,@"JFTestFramework.framework"];
        NSLog(@"2-------%@",bundlePath);
        if (![[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
            NSLog(@"file not exist");
            return;
        }
        NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
        
        if (!bundle || ![bundle load]) {
            NSLog(@"bundle load error");
        }
        Class loadClass= [bundle classNamed:@"JFDylib"];
        
        if (!loadClass) {
            NSLog(@"get bundle class fail");
            return;
        }
        
        NSObject *bundleObj = [loadClass new];
        
        [bundleObj performSelector:@selector(showViewAfterVC: inBundle:) withObject:self withObject:bundle];

 

热更新--动态加载framework

标签:

原文地址:http://www.cnblogs.com/sunjianfei/p/5781900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!