Carbon Five has been using TeamCity as our continuous integration server for most of our recent projects, including our iPhone work. Out continuous integration environment monitors the git repository used by each project, runs the project’s tests each time a change is pushed to the repository, and can automatically produce an ad-hoc build of an app each time the tests pass.
Continue reading ‘Continuous integration for iPhone projects in TeamCity’
Author Archive for jonah
Previously I discussed our TeamCity configuration using RVM and mentioned that we often use git to deploy projects. Today I’ll share an example of how a TeamCity build agent can trigger deployments of a application hosted on Heroku and some of the challenges I found.
Continue reading ‘Deploying to Heroku from TeamCity’
We have been using TeamCity to manage the continuous integration, testing, and deployment of many of our recent projects. We have also been using RVM on all of our recent Rails projects to allow us to install multiple ruby versions and create isolated gemsets for each project. RVM proved to be particularly useful on our TeamCity build agents where it allows a single agent to build many projects without the fear that we will see gem or ruby version conflicts between projects or introduce dependencies on gems installed on the build server but not enumerated in the project. Here’s the configuration I have used to get our build agents to use each project’s RVM settings.
Continue reading ‘Using RVM on TeamCity build agents’
All UIViews have frame and bounds properties which define their dimensions. The similarity of these properties can cause some confusion when attempting to determine which property to use to calculate view sizes or reposition views.
The frame of a view is given in the coordinates of its superview so a view controller’s view’s frame will include offsets for the status bar, navigation bar, or tab bar. The bounds of a view are given in the view’s own coordinate system which does not include these elements.
In addition the frame property’s values are undefined if the view has any transform other than the identity transform. Rotating a view into landscape mode applies a transform to the view so it is not safe to rely on frame values for an app in landscape mode.
When a transform is applied to a view it does not apply to any subviews. A UIViewController or custom UIView subclass is therefore free to adjust the frames of its subviews to reposition them regardless of the device’s orientation. For example a UIView class can change the frames of its subviews within its layoutSubviews method no matter what transform might have been applied to the parent view.
Each view’s frame will position it relative to its parent view so an origin of (0, 0) will always place a subview in the top left corner of its parent view.
See the images below for examples Continue reading ‘UIView Frames and Bounds’
I have been writing tests around my iPhone apps’ view controllers in order to follow the same TDD practices we use in other environments. Writing tests first has changed the way I structure my code in a couple of ways which I think offer immediate and emergent benefits for my applications. Most of an iPhone application’s business logic is implemented in its view controllers. Testing those controllers is therefore a priority if I want to have a well tested application.
Below are some examples of the sort of tests I have written for my view controllers using GTM, Hamcrest, and OCMock (our iPhone Unit Testing Toolkit). Hopefully this can serve as a starting point for the tests you could be writing for your own projects.
Continue reading ‘Testing iPhone View Controllers’
I’ve been following a Rails convention and defining multiple environments for my iPhone projects. This allows me to quickly switch application wide settings when running a test, development, or production version of the app.
Continue reading ‘Multiple Environments in an iPhone Project’
I’m working on a application which is deployed to Engine Yard’s Cloud infrastructure and I wanted to automatically redeploy the application whenever our tests passed on our continuous integration server.
Engine Yard will eventually allow us to push a branch to our cloud environment from git (ie “git push engineyard master”) but until that is available the best option seems to be to trigger a github post receive hook directly.
To that end I rewrote an existing script to trigger post receive hooks as a rake task; http://gist.github.com/271433
Continue reading ‘Automatically deploying to Engine Yard Cloud’
My current rails project is using Blue Ridge and the tool set it bundles together (Rhino, env.js, Screw.Unit, and Smoke) to write test driven JavaScript. The ability to write tests of my JavaScript, in JavaScript, as efficiently as I can test other languages has forced me to rethink how I structure my work and I’m writing better code because of it.
There are a couple of different options for JS testing available at this point but Blue Ridge’s plugin is the first I have seen which made writing test driven code as easy as I have come to expect while still providing all the functionality I need. In particular;
- Running my tests in a browser is fast. Refreshing fixture pages to rerun tests is dramatically more efficient than waiting for selenium tests to cycle.
- I can debug my tests as they run against their fixtures pages and inspect or manipulate the DOM at any point.
- I have mock and fake objects available to test behavior and stub out dependencies.
- My JS tests run in continuous integration, just like all the other tests.
By writing fixtures pages and tests first I am immediately using all of my code in two locations and running it against slightly different DOMs. That has pushed me to encapsulate most of my code as jQuery plugins and think carefully about how much I depend on the page’s structure. I end up with terse selectors instead of using whatever attributes are readily available and a clear configuration point for my page’s behavior as I chain together plugin calls in $(document).ready().
We’d like to see what other developers have done and share what we have learned so far so Carbon Five is hosting an open discussion of JavaScript testing in our office this week.
Topic: Javascript Testing
When: Tuesday Nov 17
6pm: arrive/network
6:30 – 8 presentation and discussion
Where: Carbon Five office: 171 2nd Street, 4th Floor
Please RSVP if you would like to attend.
Working in Xcode I almost forgot how much I like IntelliJ’s code formatting tools. Luckily for me Mike Smith recently pointed out that UniversalIndentGUI can be used to setup your own code formatting in Xcode.
Continue reading ‘Code Formatting in Xcode’
Most of my iPhone apps need to accept keyboard input somewhere and that means I need to reposition my UI elements such that the keyboard does not hide the field the user is typing in. The iPhone Application Programming Guide offers one example of Moving Content That Is Located Under The Keyboard but this is not necessarily the best solution.
Continue reading ‘Resizing views around the keyboard’

