johnno1962 / injectionforxcode

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

renaming bundle so it reloads.. #85

Open bigParis opened 8 years ago

bigParis commented 8 years ago

When I run a simple demo project, It can be injected successfully, but when I test it on a big project it not works. I got messages from injection console as below

* RECORDED BUILD SUCCEEDED 

Renaming bundle so it reloads..
rm -rf "/Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle" && cp -r "/Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle.bundle" "/Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle"
Loading Bundle...
Modified iOSInjectionProject/injectionCount.txt ...

\ Bundle load failed ***
Consult the Xcode console.

But I open InjectionBundle.xcodeproj and it can be build successfully, how to fix this problem?

johnno1962 commented 8 years ago

The problem is in the loading of the bundle. Look at the debug console in Xcode to look for dynamic loading errors.

bigParis commented 8 years ago

@johnno1962 Error loading /Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle: dlopen(/Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle, 265): Symbol not found: _OBJCCLASS$_MFAlertView Referenced from: /Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle Expected in: flat namespace in /Users/yy/Desktop/makefriends/makefriends-ios_requirement_feature/proj.ios_mac/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle

This is the message shown in debug console, MFAlertView is a self-defined component, Injection will not work with self-defined component, or how can I load injectionBundle in a right way?

johnno1962 commented 8 years ago

That should work. Look for something affecting the visibility of that class in the source i.e. https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

ph661 commented 8 years ago

@johnno1962

Bundle load failed

* RECORDED BUILD SUCCEEDED 

Renaming bundle so it reloads..
rm -rf "/Users/mtt0123/penghao/TechGitLab/MTCamera/MTCameraMoudleDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle6.bundle" && cp -r "/Users/mtt0123/penghao/TechGitLab/MTCamera/MTCameraMoudleDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle.bundle" "/Users/mtt0123/penghao/TechGitLab/MTCamera/MTCameraMoudleDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle6.bundle"
Loading Bundle...
Modified iOSInjectionProject/injectionCount.txt ...

\ Bundle load failed ***
Consult the Xcode console.


johnno1962 commented 8 years ago

Look at your Xcode console for the error this time.

zhangqingyv commented 7 years ago

RECORDED BUILD SUCCEEDED 

Renaming bundle so it reloads..
rm -rf "/Users/Terry/WorkSpace/QYGithub/QYDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle12.bundle" && cp -r "/Users/Terry/WorkSpace/QYGithub/QYDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle.bundle" "/Users/Terry/WorkSpace/QYGithub/QYDemo/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle12.bundle"
Codesigning with identity '-' for iOS device
Loading Bundle...
Modified iOSInjectionProject/injectionCount.txt ...

 Bundle load failed 
Consult the Xcode console.

And Nothing in Console

johnno1962 commented 7 years ago

Are you trying to use on a device? That no longer works I’m afraid.