`

ios:beehive

    博客分类:
  • ios
阅读更多
添加PrefixHeader.pch:参见:(http://www.jianshu.com/p/a19bb67d705e)

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#import "BeeHive.h"
#import "BHTimeProfiler.h"

#endif
=====================
Podfile:
platform :ios, '7.0'
target "TestBeehive" do
pod "BeeHive", '1.0.0'
end
=====================
在项目根目录下添加
--------------------
BeeHive.plist:
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>moduleClasses</key>
<array>
<dict>
<key>moduleClass</key>
<string>TestService</string>
<key>moduleLevel</key>
<integer>1</integer>
</dict>
</array>
</dict>
</plist>
--------------------
BHService.plist:
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>service</key>
<string>HomeServiceProtocol</string>
<key>impl</key>
<string>ViewController</string>
</dict>
</array>
</plist>
=====================
--------------------
AppDelegate.h
--------------------
#import <UIKit/UIKit.h>
@interface AppDelegate : BHAppDelegate <UIApplicationDelegate>
@end

--------------------
AppDelegate.m
--------------------
#import "AppDelegate.h"
#import "HomeServiceProtocol.h"

@interface AppDelegate ()
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    //[BHContext shareInstance].env = BHEnvironmentDev;
    [BHContext shareInstance].application = application;
    [BHContext shareInstance].launchOptions = launchOptions;
    [BHContext shareInstance].moduleConfigName = @"BeeHive";//可选,默认为BeeHive.bundle/BeeHive.plist
    [BHContext shareInstance].serviceConfigName = @"BHService";
   
    [BeeHive shareInstance].enableExpection = YES;
    [[BeeHive shareInstance] setContext:[BHContext shareInstance]];
    [[BHTimeProfiler sharedTimeProfiler] recordEventTime:@"BeeHive::super start launch"];
   
    [super application:application didFinishLaunchingWithOptions:launchOptions];
   
    id<HomeServiceProtocol> homeVc = [[BeeHive shareInstance] createService:@protocol(HomeServiceProtocol)];
   
    if ([homeVc isKindOfClass:[UIViewController class]]) {
        UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:(UIViewController*)homeVc];
        [navCtrl setNavigationBarHidden:YES];
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        self.window.rootViewController = navCtrl;
        [self.window makeKeyAndVisible];
    }
   
    return YES;
   
}

=====================
--------------------
ViewController.h
--------------------
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end

--------------------
ViewController.m
--------------------

#import "ViewController.h"
#import "HomeServiceProtocol.h"

//BeeHiveService(HomeServiceProtocol,ViewController)
@interface ViewController()<HomeServiceProtocol>

@end

@implementation ViewController

-(instancetype)init
{
    self = [super init];
    if (self) {
       
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

-(void)registerViewController:(UIViewController *)vc title:(NSString *)title iconName:(NSString *)iconName
{
//    vc.tabBarItem.image = [UIImage imageNamed:[NSString stringWithFormat:@"Home.bundle/%@", iconName]];
//    vc.tabBarItem.title = title;
//   
//    [self.registerViewControllers addObject:vc];
//   
//    self.viewControllers = self.registerViewControllers;
    NSLog(@"test-======");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
=====================
--------------------
HomeServiceProtocol.h
--------------------

#import <Foundation/Foundation.h>

@protocol HomeServiceProtocol <NSObject, BHServiceProtocol>

-(void)registerViewController:(UIViewController *)vc title:(NSString *)title iconName:(NSString *)iconName;

@end
=====================
--------------------
TestService.h
--------------------
#import <Foundation/Foundation.h>

@interface TestService : NSObject

@end

--------------------
TestService.m
--------------------

#import "TestService.h"
#import "HomeServiceProtocol.h"
#import "ViewController.h"

@interface TestService()<BHModuleProtocol>

@end

@implementation TestService

//BH_EXPORT_MODULE(YES)

-(void)modInit:(BHContext *)context
{
    switch (context.env) {
        case BHEnvironmentDev:
            //....初始化开发环境
            break;
        case BHEnvironmentProd:
            //....初始化生产环境
        default:
            break;
    }
}

- (void)modSetUp:(BHContext *)context
{
    //[[BeeHive shareInstance]registerService:@protocol(HomeServiceProtocol) service:[ViewController class]];
   
    NSLog(@"TradeModule setup");
}

=====================


=====================
分享到:
评论

相关推荐

    swift-BeeHive是一个iOS程序模块化开发框架

    **Swift-BeeHive:iOS应用模块化开发框架详解** Swift-BeeHive 是一个专为iOS应用程序设计的模块化开发框架,它旨在提高代码的可维护性、可扩展性和可复用性。通过将应用划分为独立的模块,开发者可以更有效地管理...

    BeeHive基于iOS大型项目解耦方案.pptx

    【BeeHive基于iOS大型项目解耦方案】 在iOS应用开发中,随着项目的规模不断扩大,业务线的增多,代码的耦合度逐渐升高,这不仅导致了性能问题,也使得开发、测试和维护变得困难。针对这些问题,BeeHive提出了一种...

    iOS 模块化编程框架 BeeHive.zip

    iOS 模块化编程框架 BeeHive ,BeeHive是用于ios的app模块化编程的框架实现方案,吸收了Spring框架service的理...

    iOS应用程序模块程序的解决方案

    这里提到的BeeHive是由阿里巴巴开发的一个开源框架,专门用于实现iOS应用的模块化。 BeeHive借鉴了Java中的Spring Framework API服务概念,这个概念强调的是依赖注入(Dependency Injection),即通过外部容器来...

    DecouplingKit:在iOS项目中的模块之间解耦。 iOS初始过程中模块间解初始方案

    去耦套件播客文件platform :ios , '7.0'pod 'DecouplingKit' , '~&gt; 0.0.2' DecouplingKit,在iOS项目中的模块之间解耦。 DDKServiceManager,用于加载服务列表DKService.plist,该服务是企业的协议。 DKService....

    架构师201003.pdf

    1. **Apache Beehive**:这是一个已退役的项目,曾经提供了一组用于构建企业Java应用程序的服务框架。它的目标是简化Java EE开发模型,减少样板代码的编写。 2. **Apache Attic**:这是Apache基金会的一个存储库,...

    阿里巴巴移动中台技术与应用.pdf

    同时,针对移动设备的复杂性,如Android的多版本和机型、iOS的审核周期,阿里巴巴建立了自动化适配测试系统,包括MQC(Mobile Quality Center)和MQC for iOS,涵盖了兼容性测试、功能测试、稳定性测试等多个方面,...

    App稳定性与性能优化实践.pptx

    同时,通过模块解耦工具如Beehive来管理依赖,利用容器化技术,如UICoreLogicSDKs和SDKsBundle,以及中间件Bus,实现了工程的解耦和单工程容器化,从而支持多团队并行开发,减少了开发冲突和发布阻塞。 在稳定性...

    阿里巴巴移动中台技术与应用25页.pdf

    Andfix、Tlog、Atlas、BeeHive等技术或服务,是用于热修复、日志记录、应用框架构建和消息推送的工具或框架,它们可以快速响应并修复已上线应用中的问题,提高应用质量和用户体验。 最后,文档提到了网络安全方面的...

Global site tag (gtag.js) - Google Analytics