Ross Carter
Ross Carter

Reputation: 562

Xcode, git, and intermediate build folders

I would like two things:

  1. to be able to change branches in git, and then Run or Build in Xcode without recompiling the entire project.

  2. have git ignore intermediate build files during merge, so it won't ask me to resolve any conflicts.

Putting the intermediate builds folder outside the project, or using .gitignore to ignore that folder, accomplishes #2 but not #1; I have to rebuild the entire project when I change branches, even if I did not modify any files.

Upvotes: 5

Views: 1860

Answers (3)

moala
moala

Reputation: 5334

You could define two variables:

  • MY_BRANCH_NAME = branch_foo (adapted in each branch)
  • TARGET_TEMP_DIR = $(CONFIGURATION_TEMP_DIR)/$(TARGET_NAME)$(MY_BRANCH_NAME).build (the same for all branches)

This way, the builds for your different branches will be made and keeped in separate folders, not needing to recompile everything because of a branch-to-branch config change.

You can do it in xcconfig files, or automatically define MY_BRANCH_NAME as an xcodebuild argument in a build script, among other means.

Upvotes: 1

AlBlue
AlBlue

Reputation: 24060

Xcode is going to do all of its data based on the timestamps of the files in question. If you replace the file with a newer file, then Xcode should notice that the timestamp of the file is newer than the timestamp of the build product and recompile it.

However, if you change it with an even older version of the source file, then it can't know that the build file isn't correct. It will just see that the build output is still newer than the source file, and so not recompile it.

In short, you can't know which files have definitely changed, and which have definitely not. You're better off doing a full clean+rebuild to make sure; otherwise you're going to lose time debugging when it doesn't work.

Upvotes: 0

Jakob Borg
Jakob Borg

Reputation: 24515

Well, you've answered #2 correctly yourself, so really your question only related to #1. I don't really see why Xcode would need to recompile things either - git won't change timestamp on unchanged files when switching branches.

Have you actually implemented the #2 solution, so that the entire problem isn't caused by git stomping on your build directory, which should be .gitignore'd?

Upvotes: 1

Related Questions