johnno1962 / injectionforxcode

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

Fix wrong device path for AppCode #207

Closed Saik0s closed 6 years ago

johnno1962 commented 7 years ago

Can you supply more information about this patch please? Are you using a device with AppCode? I have no way of testing this.

Saik0s commented 7 years ago

Problem is that correct deviceRoot in case of AppCode sets only after isDevice, isSimulator and isAndroid variables. That's why you will get incorrect value for isIOS variable, next - incorrect value for template , InjectionBundle and finaly error because of undefined logDir - "Please inject with Xcode before using AppCode".

In my case AppCode plugin was expecting OSXInjectionProject instead of iOSInjectionProject.

johnno1962 commented 7 years ago

Are you using the plugin or the app version?

Saik0s commented 7 years ago

Appcode plugin. Here is a piece of code from AppCode plugin, you can see mainFilePath

processScriptOutput(script, new String[]{resourcesPath + script, resourcesPath, project.getProjectFilePath(), mainFilePath, executablePath, arch, "" + ++patchNumber, "" + flags, unlockCommand, serverAddresses(), selectedFile}, event);

And here is a piece of code from common.pm where these arguments are assigned to variables.

($resources, $workspace, $deviceRoot, $executable, $arch, $patchNumber, $flags,
    $unlockCommand, $addresses, $selectedFile, $xcodeApp, $buildRoot, $logDir, $learnt) = @ARGV;

As you can see mainFilePath is assigned to $deviceRoot

johnno1962 commented 7 years ago

That looks like it’s the old plugin version you are using. Have you tried the new app version and AppCode plugin? https://github.com/johnno1962/InjectionApp. I’d rather support that than making changes to code that I thought was working this late in the day.

Saik0s commented 7 years ago

Yeah, App works, but it requires an additional application to be running. Anyway, just wanted to inform you about a little issue in the old code.

Thank you for your great injector!

johnno1962 commented 7 years ago

Thanks for reporting the problem & I’m sure you’re right. Sorry I can’t revisit that code just now.