johnno1962 / injectionforxcode

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

Injection seems to fail almost silently with Google Analytics #142

Closed joedaniels29 closed 8 years ago

joedaniels29 commented 8 years ago

When I inject, heres what I do get

objc[18574]: Class BundleInjection is implemented in both /Users/Joe/Library/Developer/CoreSimulator/Devices/BADC197C-6E2E-4BDA-92ED-4CEBFE4325DC/data/Containers/Bundle/Application/90EBBC5C-9909-46D7-A0D7-6FB3C91A8A73/EpiWatch.app/EpiWatch and /Users/Joe/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/InjectionLoader.bundle/InjectionLoader. One of the two will be used. Which one is undefined.

None of the classes seem to reload, and the injected method isn't getting called. How can I go about debugging this? Idk where injectionforxcode logs if anywhere.

joedaniels29 commented 8 years ago

As soon as I post I solved it. its the Appcode injection patch in main.m that seems to be prohibiting the reload from functioning properly in Xcode.

joedaniels29 commented 8 years ago

Both xc and app code injection are failing because of this issue though, which I don't understand. Any idea how I can debug this one?

2016-06-09 14:30:23.264 EpiWatch[23121:1097572] Error loading /Users/Joe/Projects/Mine/epiwatch/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle:  dlopen(/Users/Joe/Projects/Mine/epiwatch/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle, 265): Symbol not found: _OBJC_CLASS_$_GAI
  Referenced from: /Users/Joe/Projects/Mine/epiwatch/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle
  Expected in: flat namespace
 in /Users/Joe/Projects/Mine/epiwatch/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle
2016-06-09 14:30:23.264 EpiWatch[23121:1097572] Bundle Load Error
2016-06-09 14:30:23.264 EpiWatch[23121:1098241] *** Bundle has failed to load. If this is due to symbols not found, this may be due to symbols being hidden from dynamic libraries. ***
2 injections performed so far.
johnno1962 commented 8 years ago

Hi, this is gnerally to do with Google analytics if you are using it in the class being injected as they make their symbols non-public visibiliy so they can not be linked against. I’m afraid there is no solution to this. Other classes that do not refer to the GAI class should inject ok.

joedaniels29 commented 8 years ago

Thank you so much for the feedback!

—Looks like you're right. This project has GA all throughout it, but only sparsely in this file. By commenting out the references (who cares about analytics anyways?) and setting the VC class to UIViewCOntroller, it all worked. Thanks again!