I've been thinking a bit about the workflow of branch switching when you use XcodeGen. Currently many people are regenerating the project after a checkout (sometimes in a git checkout hook) to make sure the project is up to date, in case the project spec has changed or files have been added or removed. In a very large project, this can potentially take a couple of seconds.
I propose adding a project lock file that is used to track whether generation is necessary.
project.lock file (name TBD).xcodegen, something like --check-lock (name?). When this is provided it checks for a project.lock file and compares the current spec with the one included in the lock file.For those using Cocoapods, a pod install has to be run after project generation. Another argument --pod-install could run pod install after generation. This would mean it only runs if get past the lock file.
This command could then be added as a git checkout hook (perhaps with a command in XcodeGen itself)
Thoughts?
Sounds good! I also want to use --pod-install.
However, since I think that it is also necessary to obtain a list of source files when generating projects and comparing project.lock, either way, it will take more time for more files.
I didn't measure precisely, as far as seen the log, are seen in our project it takes about 3 seconds for generating project and about 1 second for writing project. I am thinking that much time of project generation is used for scanning source files, so I am uncertain about how much we can improvements with lock file.
I've personally solved this with a Makefile that have the Xcode project dependent on the project.yml file. Thus, every time that project.yml is edited, the Xcode project will be rebuilt before continuing with anything else.
Not saying that this shouldn't be a good addition ☺️ just sharing my current setup.
edit: I'm using something similar to: https://github.com/LinusU/Soon/blob/master/Makefile
For us we have lots fo changes that aren't listed in the project.yml, such as moving/adding/removing of source files. This feature would be really nice for us.
We currently solve this problem by:
git ls-files to see if any files have been added or deletedFor those interested this is our script for this:
#!/bin/bash
set -o pipefail
set -u
touch ./tmp/project_generated.json.sha256
shasum --check ./tmp/project_generated.json.sha256 > /dev/null 2>&1
project_changed=$?
shasum -a 256 ./project_generated.json > ./tmp/project_generated.json.sha256
git ls-files --others --exclude-standard --cached \
| shasum -a 256 > ./tmp/newfiles.txt
cmp --silent ./tmp/files.txt ./tmp/newfiles.txt
files_changed=$?
mv ./tmp/newfiles.txt ./tmp/files.txt
test -f ./Lyft.xcodeproj/project.pbxproj
project_exists=$?
if [[ "$project_changed" -ne 0 ]] || [[ "$files_changed" -ne 0 ]] \
|| [[ "$project_exists" -ne 0 ]]
then
exit 1
fi
The only known case this doesn't handle is if the dev changes the project in Xcode. I'm planning on solving that with the timestamp of the project.pbxproj in the meantime.
This proposal sounds great though!
@keith that's an ok solution. The advantages here are:
include feature to pull in multiple specs this will check all for changesI've put up a working implementation here #412. Let's continue the conversation there
If you guys could give it a test that would be great! 😄
I'll try this out on ours shortly!
--
Keith Smiley
On Sat, Sep 29, 2018 at 12:15 AM Yonas Kolb notifications@github.com
wrote:
If you guys could give it a test that would be great! 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yonaskolb/XcodeGen/issues/409#issuecomment-425623063,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARU7tVlgaXynrX3IejBBuCrygSCezz6ks5ufx4jgaJpZM4W6fAp
.
Released in 2.1.0 under a --use-cache flag