Closed karolbielski closed 10 months ago
Hey, I think the main problem is that the Generator is unable to write to the generated file. Does the directory at /Users/kb/Documents/Software-Developer/Experiment-Learn/WeatherApp/WeatherApp/WeatherAppTests/GeneratedMocks.swift
exist? Perhaps try creating the GeneratedMocks.swift
file and see if that fixes it.
Yes, folder at path /Users/kb/Documents/Software-Developer/Experiment-Learn/WeatherApp/WeatherApp/WeatherAppTests
exists. I created GeneratedMocks.swift
file manually but the result is the same as before.
Hm, I see. The No Cuckoo Generator found.
is not an error, it's simply an info for you that a generator will need to be either built from sources or downloaded, the latter of which the run script promptly does.
Regarding the FileKit error, it seems the generator has issues both reading the input file and writing the output file, so if the paths are absolutely correct, this hints at a permission issue. I know that recent Mac versions started requiring Documents access permission to read or write, so that might be it.
I managed to solve the issue.
All paths and files are correct. But the errors "Could not read contents of ..." and "Could not write to file at ..." gave me a hint that it is a problem with reading and writing to files that are input and output of the script.
It turns out that from Xcode 15 value of ENABLE_USER_SCRIPT_SANDBOXING
(reference) in Build Settings is Yes
by default. As far as I understood, it means that if there is no input or output arguments to run script (declared in Xcode), the system sandboxes the script and as a result input/output files cannot be read/write from inside the script.
After I change ENABLE_USER_SCRIPT_SANDBOXING
to No
the script started to work as expected and GeneratedMocks.swift
file was generated.
@MatyasKriz Thanks for your time and effort. I'd be happy to create a PR that adds information about this problem to installation instructions in README.
Oh yeah, I remember something about this and I thought it was already in README, but it may have been in an issue or somewhere else entirely then.
If you'd be so kind, I'd happily merge this addition so others don't have to battle with this. 🙂
README is updated. I am closing the issue.
I am facing two problems:
Run script output
When I try to build test target I have:
My configuration
I added Cuckoo using SPM to my test target and created run script also in test target and put it above "Compile Sources":
"Generate Fakes" run script:
File manager of the project with file to be generated:
I added
--clean --download
to Cuckoo/run script as suggested in other Issues but with no luck.I am using Xcode 15.1, Cuckoo 1.10.4.
Should I do something additional to help generator to be found?
About "Could not read contents of ..." error: the file at path "/Users/kb/Documents/Software-Developer/Experiment-Learn/WeatherApp/WeatherApp/WeatherApp/Service/Forecast/ForecastService.swift" exists and the path is correct.
I would be happy if someone help me solve this. Thanks in advance.