BloodMagic icon indicating copy to clipboard operation
BloodMagic copied to clipboard

CocoaPods 'use_frameworks!' option breaks dependency injection

Open s-k opened this issue 8 years ago • 3 comments

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.

s-k avatar Apr 11 '16 17:04 s-k

+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.

tkach avatar Jun 15 '16 15:06 tkach

Actually, I have created a pull request some time ago to fix this issue:

https://github.com/railsware/BloodMagic/pull/34

s-k avatar Jun 18 '16 10:06 s-k

@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

DanSkeel avatar Feb 16 '20 21:02 DanSkeel