johnno1962 / injectionforxcode

Runtime Code Injection for Objective-C & Swift
MIT License
6.55k stars 565 forks source link

Tunable parameters Xcode 7.2 #73

Closed PabloLerma closed 8 years ago

PabloLerma commented 8 years ago

I don't know if it is actually a issue but I am not able to use tunable parameters in XCode 7.2.

In a init of a UIView (objc) I set self.backgroundColor = INColors[0]; and it is not working. XCode's console prints "Color #0 -> 0.079900,0.662133,0.997869,1.000000" but it seems that the parameters are not been injected. If I inject the code manually (ctrl+=) and reload the view it seems to work. I also tried to add the code in - (void)inject but it doesn't work (I suppose that the tunable parameters doesn't call it). @johnno1962 what am I doing wrong? Thanks!

johnno1962 commented 8 years ago

Probably to do with the order of initialisation of your app. Perhaps INColors has not been set by the time UIView.init is called. You would need to use + (void)inSetTarget:(id)target action:(SEL)action forColor:(int)tag; or the #define INJECTION_BACKGROUND( _who, _which ) \ INColorTargets[_which] = _who; INColorActions[_which] = @selector(setBackgroundColor:) in BundleInterface.h to have the color come through continuously.

PabloLerma commented 8 years ago

:+1: You're right! Thank you!

codwam commented 8 years ago

use of undeclared identifier 'INColors' xcode 7.2

johnno1962 commented 8 years ago

You’ll need a .pch file in your project for injectino to patch, or, for Swift a bridging header (or just put extern UIColor *INColors somewhere provided you are using "patched” injection)