johnno1962 / injectionforxcode

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

my injection doesn't work #93

Open ghost opened 8 years ago

ghost commented 8 years ago

I just change the text of uilabel for test.

2016-03-14 7 40 45 2016-03-14 7 43 01

I don't understand. Can you help me fix that issue

TangTangWan commented 8 years ago

The same problem came up to me. And the outputs in the console are similar to yours. I downloaded my injection plugin from http://injectionforxcode.com/, and my Xcode version is 7.2.1.

johnno1962 commented 8 years ago

Normally this is becuase the ViewController has not been reloaded.

ghost commented 8 years ago

ctrl + = didn't make ViewController reload.I must try command + R.

johnno1962 commented 8 years ago

Injection changes the code but it needs to be re-executed i.e. -viewDidLoad needs to be called again. You could add a -injected method to the view controller and have it call -viewDidLoad for testing.

ghost commented 8 years ago

Thank you very much.You save my life:)

huanghe810229530 commented 8 years ago

why close? I can't solve this problem, help...

ghost commented 8 years ago
func injected(){
     viewdidload()
}

just do that,then it works.

jonsnowwinterfell commented 8 years ago

i still have no idea to make the plugin works ,when i Use the shortcut “control =" nothing happen in xocde 127af1e8-4a44-4aec-b872-934b9e7131b4

ghost commented 8 years ago

Maybe u can install injection once again,then use command + q to close Xcode and reopen Xcode. U will see injection work.Hope to be useful to u.

superleexpert commented 8 years ago

I have met the similar issue about that do not work in a UIView class when adjust some properties on xcode7.2.

And I solved through changed method in -(void)injection. But it is not flexible. I really expect that code change everywhere and all will worked by "control+=".

huanghe810229530 commented 8 years ago

@lingang009 It is not flexible, but thank you! It improves the efficiency!

orta commented 8 years ago

People on this thread, maybe it might be a good idea to ask someone with good english and chinese skills to work on a translation of the README/docs?

ghostSamu commented 8 years ago

i have the same problem, my Xcode version is 7.2. i had added the method -(void)injected{ [self viewDidLoad]; }

it can refresh UI but it still print the message :

Class HomeViewController is implemented in both Developer/CoreSimulator/Devices/0C35732D-086B-4BDA-9C0E-DF10E731D82F/data/Containers/Bundle/Application/302CFF8A-9645-4721-88FC-F7C12D92A2C7/GaoKaoHelper.app/GaoKaoHelper and Desktop/GaoKaoHelper/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle. One of the two will be used. Which one is undefined. 2016-07-11 00:19:26.350 GaoKaoHelper[61611:9789048] Ignore any warning, Swizzled HomeViewController 0x111760598 -> 0x104fa7b48 8 injections performed so far.

johnno1962 commented 8 years ago

The message is a warning. Add an NSLog to see if -injected gets called.

ghostSamu commented 8 years ago

@johnno1962

yes ,it is called.

i just don't understand this message: One of the two will be used. Which one is undefined. one is in .app one is in bundle can i choose just one? how?

johnno1962 commented 8 years ago

The warning comes from the runtime. You can ignore it. Injection does the right thing.

tolord commented 8 years ago

i change the self.title's name,and then i press shift + control + = ,then,the window became empty why??

log is here //-------------------------------------------- objc[40764]: Class InjectionBundle3 is implemented in both /Users/liaozhongru/Desktop/3.application/AKServer/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle and /Users/liaozhongru/Desktop/3.application/AKServer/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle5.bundle/InjectionBundle. One of the two will be used. Which one is undefined. objc[40764]: Class AKServiceManageViewController is implemented in both /Users/liaozhongru/Library/Developer/CoreSimulator/Devices/7C1D8286-1B79-43BF-934B-61CAC7F70326/data/Containers/Bundle/Application/62F43460-59E2-45CD-9066-D4F677705BD0/alijkManager.app/alijkManager and /Users/liaozhongru/Desktop/3.application/AKServer/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle5.bundle/InjectionBundle. One of the two will be used. Which one is undefined. 2016-07-18 17:40:26.268 alijkManager[40764:4320988] BundleInjection.h [Line: 1005] __41+[BundleInjection autoLoadedNotify:hook:]_block_invoke Ignore any warning, Swizzled AKServiceManageViewController 0x122535c00 -> 0x107448bb8 30 injections performed so far.

johnno1962 commented 8 years ago

You are using “inject and reset” by mistake whicih doesn’t always work. Use "control - =" not "control - shift - ="

Huang-Libo commented 7 years ago

@lingang009 Thanks, you save my life!