Do you need help on a specific subject? Use the contact form (Request a blog entry) on the right hand side.

2016-04-19

Xcode Server and multiple repositories

Last week we upgraded our mac mini server such that it can now run the most recent OS.
And of course we installed OS-Server on it. A big step up from the old days of OS-X 10.7...

And of course we wanted to setup continuous integration (CI) for XCode.

But we hit a snag that cost me a good day to figure out: our first bot could not find all the necessary source files. It just so happens that we use Xcode's workspaces and in a workspace we have multiple projects:



In the project Swiftfire we use the files ASCII.swift and VJson.swift from SwifterJSON. And of course these are referenced files, i.e. Swiftfire does not have copies of those files, but refers to SwifterJSON whenever it needs the files for compilation.

That is a problem when creating bots for CI.

One of the first things a bot does is to check out the repository of its associated project. And since I created the first bot inside a project instead of the workspace it failed to check out all of the necessary files.

Inside the workspace however it is not possible to create a bot since the bot must reside in a repository for the server to check it out.

I have not found a way to create a git repository from inside Xcode when creating or working in a workspace. So I did this manually.

Note: Before doing so, it is worth noticing that git works recursive. Hence it is probably not a good idea to have a workspace repository sitting in a directory in which the projects also reside. Unless you want to tweak the '.gitignore' file. I have not tried this, but opted for the safer approach: I created a special "workspace" directory alongside the project directories:


In the workspace directory, using Xcode, I created the Q5 workspace.
Then I exited Xcode (seems safer to me) and started the Terminal. I navigated to the Workspace directory and initialised a git repository: > git init
For good measure I also added a ".gitignore" file with ".DS_Store" and "xcuserdata" in it:



At this point we may well also add and commit the files:
> git add .
> git commit -m "Initial commit"

Next I fired Xcode up again, and look, it found the workspace repository:



Using "Source Control" -> "Workspace - Master" -> "Configure Workspace" I created a new repository on the server. If you did not add & commit at the Terminal line, you need to "commit & push" the workspace file now.

One more thing to do: we now must tell Xcode which repositories are necessary when a bot is activated. This is done in the "Source Control" -> "...." -> "Configure ...." dialogue:



For each project that is needed, make sure the "include as" is checked and the popup box has selected "required".

I forgot if it is necessary at this step to perform a commit & push again. It probably is.

Anyway, you can now create bots and when executed each bot will checkout all projects and find all files necessary for its integration.


Happy coding...

Did this help?, then please help out a small independent.
If you decide that you want to make a small donation, you can do so by clicking this
link: a cup of coffee ($2) or use the popup on the right hand side for different amounts.
Payments will be processed by PayPal, receiver will be sales at balancingrock dot nl
Bitcoins will be gladly accepted at: 1GacSREBxPy1yskLMc9de2nofNv2SNdwqH

We don't get the world we wish for... we get the world we pay for.

No comments:

Post a Comment