johnno1962 / InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
MIT License
4.01k stars 318 forks source link

Could not locate compile command for ... #448

Closed skrew closed 1 year ago

skrew commented 1 year ago

Hi,

Using latest Xcode and simulators, on a M1 macbook pro.

When i run my app in xcode, the first time i want to inject, i always have this error:

Could not locate compile command for /.../.swift
This could be due to one of the following:
1. Injection does not work with Whole Module Optimization.
2. There are restrictions on characters allowed in paths.
3. File paths in the simulator are case sensitive.
4. The modified source file is not in the current project.
5. The source file is an XCTest that has not been run yet.
6. Xcode has removed the build logs. Edit a file and re-run.
Try a build clean then rebuild to make logs available or
consult: "/Users/xxx/Library/Developer/CoreSimulator/Devices/C9FBD644-3B3C-4223-A894-491E9205E223/data/Containers/Data/Application/9C926E27-345F-4906-87B5-824B76B90369/tmp/command.sh".

But, if i save the file again (even without touching anything), the injection works until i stop and build the app again.

Not a big problem but it's strange to me :)

I take this opportunity to thank you again for this very great app πŸ₯°

johnno1962 commented 1 year ago

Hi, It's been a while. This is very strange indeed. Do you think this is a regression? Have you tried the new 4.6.4 release candidate? Does this problem date back to 4.6.3 where I changed caching by any chance? I'd be very interested in tracking this down.

skrew commented 1 year ago

Hi,

You should add the current version in the app (maybe in the update check), it can help.

BTW i have tested with the 4.6.4 version, same problem.

I also noticed that after a "Clean build folder" and a complete build, the injection works from the first time, but after a relaunch, same problem.

I can share a remote screen with you if it can help, we had already done it several times

johnno1962 commented 1 year ago

TeamViewer? That would be very interesting. I don't think anybody else has reported this problem. What version of Xcode/InjectionIII is this (App, HotReloading Swift Package etc)? Surprised 4.6.4 is still doing it, it should be using a cache,

johnno1962 commented 1 year ago

Thanks for raising this issue, an interesting caching bug for large projects. I've updated the 4.6.4 pre-release of the app if you want to kick the tires (after removing the HotReloading project).

johnno1962 commented 1 year ago

I've push a few versions of the InjectionIII app since we talked and the final change was to make it silently retry without using the cache if these pesky file list files get deleted by housekeeping on the Mac after a couple of days. If you could give the current release candidate a try and get back to me if there is a problem I'd appreciate it otherwise I'll make it the main release tomorrow.

skrew commented 1 year ago

Hi, The version you patched with me still had the problem (less frequent) but the prerelease version looks ok, I have been testing for several hours and I don't have the problem anymore πŸ‘πŸ»

johnno1962 commented 1 year ago

Great, thanks for letting me know, raising this issue and your help resolving it. I introduced more use of caching a couple of months ago and hopefully this is the last of the problems it created. The last commit to 4.6.4 that invalidates the cache and retries on failure feels like the right solution.

skrew commented 1 year ago

Hi, I don't want to open a new issue just for that, i have tested your SwiftUI-Kit sample project and the injection doesn't works when i build it for tvOS

johnno1962 commented 1 year ago

Has the HotReloading Swift Package been added to the tvOS target? Probably not, try removing the package and reading it to the target you want to use.

skrew commented 1 year ago

Yep you are right :) i just have to add the framework the the tvOS target.

johnno1962 commented 1 year ago

Hi again, I have a new release candidate https://github.com/johnno1962/InjectionIII/releases/tag/4.7.3 where there were some minor changes related to these pesky -filelists which are used in large projects. Any chance you could download it and give it a try to make sure I haven't regressed something? Please remote /tmp/*_builds.plist and /tmp/filelists/* for a real test.

skrew commented 1 year ago

Hi,

Tested for 2 days now, i have see nothing special, i still have some crashs on some swiftUI views but nothing less or more compared with the latest version. So this RC is ok for me πŸ‘πŸ»

johnno1962 commented 1 year ago

Thanks for letting me know. Do tell me more about these crashes... You're calling .eraseToAnyView() religiously at the end of every view body? Otherwise it can crash when you insert interface elements or alter some modifiers. This is because this changes the concrete type for the opaque/some return value and it's memory. layout.

johnno1962 commented 1 year ago

Final 4.7.3 release is out if you want to upgrade. There were an assortment of minor fixes and enhancements as they say.