BloodMagic
BloodMagic copied to clipboard
CocoaPods 'use_frameworks!' option breaks dependency injection
I have created a simple iOS project with CocoaPods and dependency injection using BloodMagic. It works perfectly. However, if I add the 'use_frameworks!' option in the Podfile, the app breaks. An error is thrown, which complains that the getter method of the dynamic property does not exist.
+1. Seems that BMClassCollector can't collect classes when built in a Dynamic Framework.
const char *imageName = class_getImageName(object_getClass(self));
const char **classNames = objc_copyClassNamesForImage(imageName, &classesCount);
This code searches classes in the Dynamic Lib that contains BMClassCollector. In the case of using dynamic frameworks (use_frameworks!), we have own separate framework for BloodMagic, and it just doesn't see any classes outside.
Actually, I have created a pull request some time ago to fix this issue:
https://github.com/railsware/BloodMagic/pull/34
@s-k your solution works only with classes that are direct subclasses of NSObject.
Here is more general solution that was used before optimisation: #38