rayh/xcoder — Issue #18: Additional builder operations
Author: burtlo
Created: 2012-03-05 00:16:25+00:00
State: open

I have some code that I personally have [monkeypatched](https://github.com/burtlo/xcoder-cedar/blob/master/lib/xcode/builder_cedar.rb) onto Xcoder to provide support for running [Cedar](https://github.com/pivotal/cedar) from a `Builder` object. I thought maybe Xcoder could implement some [plugin system](https://github.com/burtlo/xcoder/commit/f548654c4d3bb40f56ae9c0ae4b56e61f0fc768c) that could auto require gems with a prefixed name **xcoder-**.

I linked a branch I created awhile back that implements a rudimentary solution to this problem. I was wondering if you had any thoughts about allowing a more formal way to allow for additional tools. Whether we should just include them in the gem or talk about some plugin system.

If we did choose a plugin system I think that it would likely be a good idea to not have the plugins just monkey-patch like I have done and instead do something like a DSL that add's available tasks to the Builder's that are created.

```ruby

Xcode::Builder.add_task :cedar do

require 'tmpdir'

cmd = BuildCommand.new

# Similar to the xcoder gem these platform values and paths are hard-coded.
# This is likely a poor choice and one that will get this little plugin
# into some trouble when the iOS library upgrades.

cmd << "DYLD_ROOT_PATH=\"/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk\""
cmd << "IPHONE_SIMULATOR_ROOT=\"/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk\""

tempHome = Dir.mktmpdir("Cedar")
Dir.mkdir File.join(tempHome, "Documents")
Dir.mkdir File.join(tempHome, "Library")
Dir.mkdir File.join(tempHome, "Library/Preferences")
Dir.mkdir File.join(tempHome, "Library/Caches")
Dir.mkdir File.join(tempHome, "tmp")

cmd << "CFFIXED_USER_HOME=#{tempHome}"
cmd << "CEDAR_HEADLESS_SPECS=1"
cmd << "CEDAR_REPORTER_CLASS=CDRColorizedReporter"
cmd << "CEDAR_REPORTER_OPTS=nested"

cmd << "\"#{@build_path}#{@config.name}-iphonesimulator/#{@target.name}.app/#{@target.name}\""
cmd << "-RegisterForSystemEvents"

yield cmd if block_given?

Xcode::Shell.execute(cmd.to_a)

end

```