Update build.rb to work with custom xcode build directories

This resolves an issue I had previously raised where the build script fails on machines that override the build products / intermediates directories.