seanhenry / SwiftMockGeneratorForXcode

An Xcode extension (plugin) to generate Swift test doubles automatically.
MIT License
748 stars 47 forks source link

not detecting project even when set to manual #11

Closed abbeyjackson closed 6 years ago

abbeyjackson commented 6 years ago

I'm experiencing an issue where my first mock works fine but after that there is a long period of time and then I get a message that the project could not be auto detected and to set the path manually. The only problem is it is already set manually. The first time it was on automatic so I changed it to manual earlier this morning. In order to fix this I have to click automatic and then back to manual and then it will generate successfully. I have closed the project and reopened but that did not resolve the issue.

seanhenry commented 6 years ago

Hi. Thanks for raising this issue. The auto-detect feature uses Apple Script to ask Xcode which project directory is open. It sounds like this isn't working for you. Could you try a few things to help me understand what is happening?

  1. Next time you see the error: "Could not detect your project. Enter one in the companion app." open Terminal and execute this command: osascript -e 'tell application "Xcode" to path of active workspace document'. Can you send the response that you get?

  2. Also when you see the error above, open the companion app. Does it show you the path to your project or does it say "Cannot find a project. Make sure a project is open in Xcode."?

  3. Next time the extension takes a long time to generate a mock. Could you cancel it before it finishes and try again? It shouldn't take longer than a couple of seconds to generate a mock unless the protocol is particularly large. Xcode should say something like: 'The command "Generate Mock" is still busy' and there should be a cancel button on the right side.

  4. Do you have more than one version of Xcode open or more than one project open at the same time?

abbeyjackson commented 6 years ago

Next time I see the issue I will reply with all of this info but in the meantime some of this I can answer:

  1. It shows the correct path
  2. It actually always takes more than a few seconds to generate. We have a large repo and it is faster if I point the plugin to the directory that contains the protocol but it is still usually more than a couple seconds. We have a large internal framework included statically and also ReactiveSwift added via carthage. Not sure if this is relevant but I have noticed that if I get bored/distracted while waiting and I navigate off of the file while it is being generated it will often timeout or stall and I have to go back and generate it again.
  3. No only my project, no playgrounds. But as indicated above our project contains a lot.
seanhenry commented 6 years ago

Thanks for the response. I think I’ve found the issue and will put out a fix soon.

Sorry to hear about the slow generation times. I intend to do some benchmarking to get better performance when I finish adding the next few features.

abbeyjackson commented 6 years ago

No worries, our project is pretty big, I'm used to things taking a while :)

seanhenry commented 6 years ago

I've uploaded the fix. The problem (I think) was that you can't run an AppleScript reliably in an XPC instance so it's now running from the extension itself. Hopefully this fixes your problem.

seanhenry commented 6 years ago

I'm going to assume that fix has solved your problem. If not, feel free to open this issue again.

abbeyjackson commented 6 years ago

Hi Sean, sorry for the delay. I will confirm for you on Monday!

abbeyjackson commented 6 years ago

Everything is working great, thanks again Sean!

seanhenry commented 6 years ago

Great!