johnno1962 / injectionforxcode

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

Some swift files not injected in AppCode if they are not currently opened in Xcode #242

Open eduardbosch opened 6 years ago

eduardbosch commented 6 years ago

Hi,

I'm working in Xcode and with most of the files, it works really well.

With some swift files, it happens that they are not injected when I save them from AppCode if I haven't them opened in Xcode. So I have to save the file from AppCode and then go to Xcode, find the file, open it and automatically it gets injected as Xcode sees the changes I've made in AppCode.

Is there any process to say injection to look for all the files for changes? I have "File Watcher" enabled and works well with most of the files.

My project is currently configured as a framework library scheme and an app scheme that uses the framework library. I'm having trouble when I update files from both schemes, so I don't think is a problem with updating some code to a framework and som to the app code.

Thanks for this great tool. I hope that this has an easy fix that I'm missing ✌🏻

johnno1962 commented 6 years ago

If some classes are injecting and others not it’s more of a Swifty problem like not being able to inject final methods, structs etc as they are direct dispatched i.e don’t go through the vtable which is what injection patches.

eduardbosch commented 6 years ago

Well, the files are successfully injected if I have those files opened in Xcode.

For example, imagine I have two swift files A.swift and B.swift. If I have the file A.swift opened in Xcode and I save it from AppCode, it's correctly injected. But if I save the file B.swift in AppCode, the file is not injected until I open it in Xcode.

johnno1962 commented 6 years ago

Sorry, led you astray there. This version of injection will inject the file currently open in Xcode using the AppleScript api. In theory AppCode will also work provided the injection app is in /Applications but I haven’t tested this in a while.

eduardbosch commented 6 years ago

Will be great if it works in AppCode.

Is there anything I can do to test or check what may be happening?

johnno1962 commented 6 years ago

You could try the new version “InjectionIII” which uses a file watcher from the injection home page while this will inject tests the TDD side isn’t implemented.

eduardbosch commented 6 years ago

Thanks! This version injects any saved file from AppCode 🎉

I don't care about the TDD injection right now as it's not, but will be great also to support TDD injection with Quick.

Thanks again for this tool @johnno1962 👏🏻