GitLab CI and iOS Testing

I’m in the process of developing a d20 Treasure Tracking app and wanted to take advantage of the GitLab CI testing. Yea I know, I can just test right in Xcode and don’t need it. But I also have other projects with other developers and having a CI Runner do the work lets us ALL know what is going on.

Portions of this article were taken from this post and modified/updated with changes I had to make to get it working with Xcode 7.1 and my setup. YMMV.

What I’m running

  1. El Capitan (10.11.2b3 as of this post)
  2. Xcode 7.1.1
  3. iOS 9.1 Simulators
  4. GitLab 8.1.4 with CI Turned on.

Runner Setup

First and foremost, you must install the gitlab-ci-runner. To run iOS/OS X tests, you need a mac to run it on (obviously). It can either be your local dev machine (how I have it setup), a home server, or a co-located server. What ever you choose, it needs OS X and Xcode installed.

Just follow the instructions here to install the runner with 1 change. When asked which executioner to use, choose `shell` so it’ll run the local toolset. We’re going to make a change in the GitLab UI to limit this running to just running iOS tests so any other projects you have, it won’t pick up the extra work.

After the runner is installed, install XCPretty on the runner machine. This will help cleanup the output so you can see what is failing where.

gem install xcpretty

Once the runner (and XCPretty) is installed, and registered with your GitLab instance, we need to make a quick change to make sure it’ll run just jobs for iOS/OS X. Log into your instance and do the following:

  1. Go to the Admin Area -> Continues Integration -> Runners
  2. Find the runner you just created and hit Edit
  3. Under tags, add `iOS` and hit save.
  4. You can also restrict the runner from the Edit screen to only certain projects if security is a bigger issue.

Project Setup on GitLab

Once you have pushed some code to GitLab, it’s time to get it plugged into the CI system. Navigate to your project and go to Settings -> Services. Under this, you should have a service calls `GitLab CI` and under that you’ll have 3 checkboxes.

  1. Active
  2. Push Events
  3. Tag Push Events

I have all 3 enabled so that any time I do a push or anytime I create a tag it’ll test the code. Although it’s possible to test to much (say it ain’t so!!!), this helps ensure nothing gets changed somehow along the way.

To ensure this is setup correctly, go under the admin area under Continues Integration and make sure your project is listed under the Projects tab.

Note: Some where during this process it may ask to use a shared runner. I hit enable as it gets restricted via the Tag field above for the runner. Sorry it wasn’t inline but I just don’t remember where I saw it.

Project Setup

In your project settings, under schemes, need to make sure the project is `Shared`. This is what it looks like here.

Shared Project
Shared Project settings.

A folder calls `xcscheme` (or something similar) will be created/modified. Add this to your repository as it’ll be needed later.

GitLab CI YAML File

This is the last part before seeing if everything works or the world is coming to a grinding halt. Probably somewhere in the middle. The GitLab CI system uses a YAML file ( .gitlab-ci.yml) at the root of the repository to handle all the commands and settings for building. Yes it’s a dot-file. I’ve pasted mine below (modify as you need to).

  - test

  stage: test
    - ios
    - xcodebuild clean test -project ProjectName.xcodeproj -scheme ProjectScheme -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6S,OS=9.1' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c && exit ${PIPESTATUS[0]}

Push everything to the GitLab instance and under Builds for the project, it should appear in the list of running. Under it you can watch it as it runs. If all goes well, it should come up as success. Or if you want to test failure, you can do like I did and get this:

Sample Error
Sample deliberate error

A few notes:

  1. The Code Signing commands are to allow building/testing without needing the certificates. Important if you don’t want to pass your developer certs around.
  2. The script command can be duplicated as many times as you want for each iOS/device configuration you want to test with. It’ll test each one and give output of each.
  3. Clean is done before each build to ensure an empty starting point as the runner will re-download/update the existing code without cleaning out the old code.

How To Get The Sample Code

To my programming students, below are the instructions for getting the code we’ve been going over as well as how to create and publish a branch as well as how to sync it to the server. You’re objective for the next week is to remove the code related to square and create a spinning cube with each side a different color. I wish you luck!

Log in to the GitLab server and from the main screen go to the projects tab on the left hand side.

1 - Projects Tab

You’ll see a project name similar to below.

2 - Project Name


On the next screen, click on HTTP and leave this window open!


Now… Open up Visual Studio. Make sure you have a Microsoft Account setup so that the 30 day trial doesn’t complain. If your parents have an account, ask them to use theirs, if not, make a “fake” account for the purposes of using Visual Studio.

Now inside Visual Studio, you’ll need to open up the Team Viewer if it’s not already open (look to the right of the screen, tabs at the bottom of the screen). If not open, you can find it here.

4 - Team Explorer


Inside of the Team Explorer, we’ll start under the Connect Tab.

5 - Connect Tab

From here, it’ll be the same for every repository of code you’ll be downloading or starting fresh. We’ll need to clone a copy of the code so that you can work with it locally on your machine.

You’ll need the HTTP address from above here. You’ll paste that into the box (probably yellow when empty) and it’ll pick a place to save the copy. Hit clone and it’ll ask for your username and password from the GitLab server. If asked to save, do so so that you won’t have to type it in every time you need to work with the server.

6 - Clone Repo

Once cloned, it’ll appear underneath as shown above. You’ll need to double click on the repo name to open it up. It’ll lead to the following screen.

7 - Open Repo

This is the “Home” screen (Home icon up top). We’ll be doing a few things here. Anytime I mention “working from Home,” this is where I’m talking about.

Next we need to create a branch for you to work on. Click on branches, click on “new branch”, give it the name as shown replacing the rh at the beginning with your first and last initials. Make sure the drop down shows “master” and the “Checkout branch” checkmark is checked. Then click “Create Branch”.

9 - New Branch off of master


This branch is what you’ll be working with for the changes. But before you make any changes, we need to make sure a copy can be sent to the server. Next we’re going to “Publish” this branch. Right click on the new branch and click on “Publish Branch.”

10 - Publish Branch


It shouldn’t ask you for your username/password again, but if it does, just enter the same info as you would for the GitLab server.

The only code you’ll need to modify is in 1 section of the code. Under the Solution Explorer (look at the bottom tabs where it says “Team Explorer” or under the view menu), under the Source Files, the DisplayManager.cpp file. Scroll down tot he DisplayManager::drawScene() method.

Screen Shot 2015-04-22 at 21.33.07


You won’t need the code related to GL_QUARDS so go ahead and remove it and everything associated with the square.

Once you’ve made changes, you’ll need to “commit” and “sync” them. From the Home screen, go under “Changes”.

12 - Name commit with changes and commit

You’ll need to give it a message to say what you did, for example, “Removed Quads” are all the changes I made when I removed all code associated with…. removing the code related to the GL_QUADS. Once you press “Commit,” the changes will be staged and ready to be synced to the server, but they won’t be yet.

When committing changes, it may ask to confirm that you really want to commit them. Go ahead and say yes.

The nice thing about how this works is you can do a lot of small changes, say one commit for each side of the cube for example, and then sync them all at once later when you’re ready.

When you’re ready to sync to the server, go back to the Home screen in the Team Explorer and click on the “Unsynced Commits” button. From here you’ll see a list of commits that haven’t been sent to the server. Just click the “Sync” button and let it go. It’ll send all the changes up.

15 - Sync to server

Every project we work on from here on out, this is how we’ll keep up on what changes are being done.

As always, if you need help with this, send me an email. I’ll respond as fast as I’m able.

Happy coding!

* UPDATE: On first commit, it may ask to setup Username and Email address. Please set this up as it is needed for accountability of changes and is recorded in the code repository. It’s sort of change tracking while working with teams. It lets us confirm who did what.

I’m Still Alive!!!

I know it’s been quite here to all 3 of you, but I’m still here. Life’s been piling it on and I’ve been running through it all. That’s a good thing though. From all this running, I’ve lost 18lbs in the last 2 months. Still not back below 300, but WILL be there within a month. Target is still 180ish by end of year. I WILL have my bootcamp body back!

On another note, I’ve been doing some mentoring at my daughter’s school, as well as the Jr. High I expect she will be attending, on programming and development. Been interesting thus far. Looking forward to see where it leads.

I’ve also started several personal projects that I’ll post updates on as they progress. One being a twitter client (another one?) that keeps track of who’s following you are verified as well as other tidbits. The other is a syncing app to go along with DreamObjects that ties into OS X 10.10. Should be interesting.

The Doctor Saved Us

That’s right folks. The apocalypse didn’t happen so that means only one thing, The Doctor saved us!!!.

Wouldn’t that be a decent episode? Mayan’s predict the end of the world but some means, then in traditional Doctor fashion, he saves us last minute? Which reminds me, he’s saved us so many times, at what point do we save him from his own methods of self destruction?

Looking forward to the Christmas special.

Merry Christmas everyone!

Free Stuff

A friend sent this to me last week and it was too good not to share.

I have never heard this said as simply. Class war at its best.

The folks who are getting the free stuff don’t like the folks who are paying for the free stuff, because the folks who are paying for the free stuff can no longer afford to pay for both the free stuff and their own stuff.

And, the folks who are paying for the free stuff want the free stuff to stop.

And the folks who are getting the free stuff want even more free stuff on top of the free stuff they are already getting!

Now… the people who are forcing the people who pay for the free stuff have told the people who are RECEIVING the free stuff that the people who are PAYING for the free stuff are being mean, prejudiced, and racist.

So… the people who are GETTING the free stuff have been convinced they need to hate the people who are paying for the free stuff by the people who are forcing some people to pay for their free stuff and giving them the free stuff in the first place.

We have let the free stuff giving go on for so long that there are now more people getting free stuff than paying for the free stuff.

Now understand this. All great democracies have committed financial suicide somewhere between 200 and 250 years after being founded. The reason?

The voters figured out they could vote themselves money from the treasury by electing people who promised to give them money from the treasury in exchange for electing them.

The United States officially became a Republic in 1776236 years ago. The number of people now getting free stuff outnumbers the people paying for the free stuff.  We have one chance to change that in 2012. Failure to change that spells the end of the United States as we know it.


A Nation of Sheep Breeds a Government of Wolves!

I’M 100% for PASSING THIS ON !!!

For all our sake PLEASE Take a Stand!!!

  • Borders: Closed!
  • Language: English only
  • Culture: Constitution, and the Bill of Rights!
  • Drug Free: Mandatory Drug Screening before Welfare!
  • No freebies to: Non-Citizens!

MacHeist 4 Bundle

I’ve been a fan of the MacHeist series of bundles since MacHeist 3. (I missed the first few). This one was fun with multiple iOS missions and nanoMissions as well as the bundle itself. Lots of apps and games.

I want to point out a few this time around.

  • DiskTools Pro – Worthless in my opinion. It took over 30 minutes to do initial setup and get to a screen. Multiple times it when non-responsive. The general maintenance can be done with other utilities that are free and do a better job. If you want defragmentation, I recommend iDefrag. Clean interface, quick, and easier to use.
  • BioShock 2 – Haven’t really played it yet but runs smoothly. Only grip, the key/activation system is bullshit. I understand a developers need to protect their products, but that stuff makes it harder for people to play. It doesn’t stop people from pirating.
  • Bartender – I’ve only used it for about 30 mins now but works as advertised. My menu bar hasn’t looked this good in ages.
  • STEAM Apps – Was surprised to see these pop up, but still a decent bunch of games.
  • Gratuitous Space Battles – A bit addicting. Played for an hour the other night and didn’t realize the time going by. Enjoyed watching all the ships blow up.
  • Bellhop – Looked through it. Not sure I trust it over though. Might give it a try on my next trip.
  • CallendarPlus – Prefer Fantastical over this one. Requires less of an install and a better interface
  • Printopia – Nice addition. I have several printers on my machine from different networks. Nice addition to also be able to “Print To Evernote” and “Print To Dropbox”
  • TuneUp – Was added while I was typing this. Wish it had iTunes Match support. Looks interesting though. UPDATE: Worthless. Continually looses connection to iTunes, doesn’t find many songs that are widely available, and support basically blames the user for any issues.
  • Moneybags – Was also added while I was writing this. May be better than MoneyWell, not sure yet. Gonna run both of them side by side for a while and see which one I like better. Only issue, it’s not signed with an Apple certificate so have to manually approve it to run. An annoyance for sure but one that can be quickly fixed by the developers.

Fantastical is Fantastic!

Yea, I did that. I bought Fantastical from the Mac App Store yesterday and have enjoyed it. It really is a great app for those that are always working on their calendars or are needing quick access.

The ONLY issues I’ve had with it thus far was right after I installed it, the “Getting Started” stuff froze the app for no visible reason. After forcible killing it in Activity Monitor and reloading the app, everything was as smooth as butter.

Things I like:

  • Month at a glance (The actual month, not events)
  • Variable event list (None to 31 days out).
  • Stays out of the way until I need it.
  • Event creation is a dream.

Speaking of event creation, tried out my first one earlier today (which prompted this post) for a weekly lunch with my family. It auto filled each field correctly and quickly. Better than iCal ever has.

If you’ve been wanting an app to help with scheduling, this one is worth the money.