johnno1962 / injectionforxcode

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

Could not locate compile command for file.swift #152

Open orgmir opened 8 years ago

orgmir commented 8 years ago

I'm working on a swift project and I can't get it to inject. I have a main.swift and a dub main.m and the console prints out that the app is ready for inject when it starts. The actual compilation after i press the inject action gives this error:

Could not locate compile command for /Users/fakeUser/Dev/myproject/UserInterface/ViewController.swift
(...)
 at /Users/fakeUser/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/common.pm line 57.
   
  main::error('Could not locate compile command for /Users/luisramos/Dev/rus...') called at /Users/fakeUser/Library/Application Support/Developer/Shared/Xcode/Plug-ins/InjectionPlugin.xcplugin/Contents/Resources/injectSource.pl line 252

The folder where the file is located has a space in it: /User Interface. So I went ahead and changed the escape regex to add a backslash instead of removing the space, thinking this could be the issue. The change I made was in the InjectSource.pl file line 211.

But the same error still happens (now with the correctly escaped path printed in the plugin console).

Can you help me sort this out? I've been searching the other issues related to this, but can't seem to figure it out.

johnno1962 commented 8 years ago

Hi, I’m afraid this is a known problem. I’ve tried to get directories with spaces in them to work in the past and not succeeded.

orgmir commented 8 years ago

Thanks for the response! I've tried to figure it out, but my pearl skills are lacking. I'll update this if I find out the issue.

johnno1962 commented 7 years ago

This may have been because you were using “Whole module optimisation”?

orgmir commented 7 years ago

We were using "Whole module optimisation" in our debug builds, and had to turn it off because it was messing with our debugging. But I didn't test Injection after that. So I'm not 100% sure if that was the issue.