BeeHive
BeeHive copied to clipboard
:honeybee: BeeHive is a solution for iOS Application module programs, it absorbed the Spring Framework API service concept to avoid coupling between modules.
我新建了一个项目 在plist文件中注册了四个模块 其中我在首页模块中motInit方法里的断点以及输出语句都不执行,另外3个模块则注册成功,找了许久找不出问题,然后我又新建了多个模块,发现除了之前的3个模块其他都未注册成功,我打开官方demo,发现官方demo里的HomeMoudle里的语句也未执行,断点也断不进,同样的模块类有些能注册成功有些则注册失败,除了类名不同其他都一模一样,实在找不出原因,望解答
fix some BHRouter bugs
@BeeHiveService(UserTrackServiceProtocol,BHUserTrackViewController) #define BeeHiveService(servicename,impl) \ class BeeHive; char * k##servicename##_service BeeHiveDATA(BeehiveServices) = "{ \""#servicename"\" : \""#impl"\"}";
Annotation方式注册方式中使用了 `void initProphet() { _dyld_register_func_for_add_image(dyld_callback); }` dyld_callback被回调次数非常多,如果注册的比较多的话会不会引起性能问题?
 上图展示的是通过对编译链接完成生成的可执行文件分别查看Mach-O文件结构和反编译代码的结果 BeeHive的原理简单来说分为三步: 1、为了避免无用数据在编译阶段被优化删掉,就通过 `used` 来修饰 并告诉编译器把数据存到Mach-O文件的Segment Data 中,就是宏定义那段 2、hook动态链接库加载,在main函数执行之前把数据从Segment Data读取出来,做好class和protocol的字典对应准备,就是注册main函数执行之前__attribute__((constructor))那段 3、当程序启动完成后,就可以从字典的中根据protocol取出对应的类,达到解耦合的目的 再附上有关文章: https://lowlevelbits.org/parsing-mach-o-files/ http://liumh.com/2018/08/18/ios-attribute-section/#section
建议在`BHServiceManager.h` 中把获取类名的方法`- (Class)serviceImplClass:(Protocol *)service;`也给暴露出来,因为有的protocol可能有类方法,在调用类方法时候时可能还没必要创建实体对象。 
There are lots of "message brokers" out there; but none quite as simple to use and deploy as [msgbus](https://github.com/prologic/msgbus). To that end (*time permitting*) I will contribute such a bee...