zoukankan      html  css  js  c++  java
  • 热更新--动态加载framework

    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];
  • 相关阅读:
    2-5
    2-4 及 1、2两章 学习心得 和问题
    2-3
    4-8
    4-6
    4-5
    4-4
    4-3
    4-2
    4-1
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/5781900.html
Copyright © 2011-2022 走看看