johnno1962 / injectionforxcode

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

*** Bundle has failed to load #175

Open dollar2048 opened 7 years ago

dollar2048 commented 7 years ago

Hello, John. Please, help. During injection I'm receiving such error: Xcode console log:

Compiling /Users/sergei.prikhodko/PR/Project/ProjectLive/Code/Managers/NetworkStatusManager.m 0.05 real 0.03 user 0.01 sys 2016-10-10 10:20:48.948 Project[9481:140869] Error loading /Users/sergei.prikhodko/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle5.bundle/InjectionBundle: dlopen(/Users/sergei.prikhodko/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle5.bundle/InjectionBundle, 265): Library not loaded: @rpath/AFNetworkActivityLogger.framework/AFNetworkActivityLogger Referenced from: /Users/sergei.prikhodko/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle5.bundle/InjectionBundle Reason: image not found 2016-10-10 10:20:48.949 Project[9481:140869] Bundle Load Error 2016-10-10 10:20:48.949 Project[9481:141010] *** Bundle has failed to load. If this is due to symbols not found, this may be due to symbols being hidden from dynamic libraries. *** 4 injections performed so far.

Where shall I have a look?

johnno1962 commented 7 years ago

You’ll likely have to adjust the “Runpath Search Paths” of your injection bundle.

timothycosta commented 7 years ago

John, could you give an example of how to modify those paths? I've installed Google/SignIn via cocoapods and can no longer inject with the error:

ld: framework not found GGLSignIn for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)



** BUILD FAILED **




The following build commands failed:
 Ld build/Debug-iphonesimulator/InjectionBundle.bundle/InjectionBundle normal x86_64
(1 failure)



*** Build Failed with status: 65. You may need to open and edit the bundle project to resolve issues with either header include paths or Frameworks the bundle links against. ***

dollar2048 commented 7 years ago

@johnno1962 I works inly when I "patch project for injection". otherwerwise xcode console says:

Error loading /Users/user/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/InjectionLoader.bundle/InjectionLoader:  dlopen(/Users/user/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/InjectionLoader.bundle/InjectionLoader, 265): no suitable image found.  
Did find:
    /Users/user/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/InjectionLoader.bundle/InjectionLoader: required code signature missing for '/Users/user/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/InjectionLoader.bundle/InjectionLoader'

How can I use plugin without modification in main.m and .pch files?

johnno1962 commented 7 years ago

Hi @dollar2048, you still have a problem where the InjectionLoader boostrap bundle isn’t signed correctly. Please build from the sources and alter the codesigning identity in the Build Phase until it is not giving an error. A build from Alcatraz will not report this error. Then you shouldn’t need to patch.

dollar2048 commented 7 years ago

Hi, @johnno1962 . Yes. you are right. I have deleted from alcatraz then build the injection project it manually (with evident signing instead of "iPhone Developer"). and it fixed the problem. I don't have to patch my project to apply injection :) Thank you again.

dollar2048 commented 7 years ago

@johnno1962 It came back again (it doesn't work even if I build the plugin using xcode):

2016-11-09 14:35:03.102 Project[1642:10843608] Error loading /Users/user/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle:  dlopen(/Users/user/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle, 265): Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /Users/user/PR/Project/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle2.bundle/InjectionBundle
  Reason: image not found
2016-11-09 14:35:03.102 Project[1642:10843608] Bundle Load Error
2016-11-09 14:35:03.102 Project[1642:10843757] *** Bundle has failed to load. If this is due to symbols not found, this may be due to symbols being hidden from dynamic libraries. ***
82 injections performed so far.

what could I do?

johnno1962 commented 7 years ago

Alcatraz may have rebuilt your rebuilt your plugin? Try building it manually again?

dollar2048 commented 7 years ago

@johnno1962 I have removed it from Alcatraz. Then build it manually. Still this problem.

what does this mean? Library not loaded: @rpath/XCTest.framework/XCTest

johnno1962 commented 7 years ago

I’m sorry, but I don’t know. Which Xcode is this??

dollar2048 commented 7 years ago

xcode 8.1 and I think it happens after upgrading to it.

I'll check on another machine if it works there.

yam-liu commented 7 years ago

same problem

Library not loaded: @rpath/XCTest.framework/XCTest

Details:

2016-11-27 00:53:36.034 xxy[51329:3837555] Error loading /Users/ooops/Documents/Xcode/Projects/xxx/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle8.bundle/InjectionBundle:  dlopen(/Users/ooops/Documents/Xcode/Projects/xxx/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle8.bundle/InjectionBundle, 265): Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /Users/ooops/Documents/Xcode/Projects/xxx/iOSInjectionProject/build/Debug-iphonesimulator/InjectionBundle8.bundle/InjectionBundle
  Reason: image not found
2016-11-27 00:53:36.034 xxy[51329:3837555] Bundle Load Error
2016-11-27 00:53:36.035 xxy[51329:3838456] *** Bundle has failed to load. If this is due to symbols not found, this may be due to symbols being hidden from dynamic libraries. ***
5 injections performed so far.
yam-liu commented 7 years ago

After several hours' investigation, I finally make it work for the Library not loaded: @rpath/XCTest.framework/XCTest issue inspired by another similar dyld question.

All you need to do is clear all the derived data (not just your current project). At least this works for me. Hope this helps.

dollar2048 commented 7 years ago

@ooopscc OMG. you are right! Derived data was causing the problem. Thank you so much!!!

p.s. but on Sierra since 8.1 unsigned xcode doesn't work good(( it freezes on saving.

zenangst commented 7 years ago

Hey @dollar2048

Try this and see if that doesn't solve the freezes - https://medium.com/@zenangst/is-unsigned-xcode-giving-you-a-hard-time-cdc30d2c54b3#.rbm382myh

dollar2048 commented 7 years ago

@zenangst Thank you so much! it helped me! Xcode is great again.

dollar2048 commented 7 years ago

@johnno1962 I don't know if I should close this issue or leave it as it is now.

johnno1962 commented 7 years ago

Let’s leave it open for now there is a lot of useful information here, particularly the contacts fix.