Method: Xcode::Buildspec::TaskBuilder#builder

Defined in:
lib/xcode/buildspec.rb

#builderObject

Internally used to lazily instantiate the builder given the properties that have been set.

Returns:

  • the appropriate builder



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/xcode/buildspec.rb', line 186

def builder
  return @builder unless @builder.nil?

  raise "profile must be defined" if @profile.nil?
  raise "project/workspace must be defined" if @filename.nil?

  begin 
    project = Xcode.project @filename
    @builder = project.target(@args[:target]).config(@args[:config]).builder
  rescue
    workspace = Xcode.workspace @filename
    @builder = workspace.scheme(@args[:scheme]).builder
  rescue
    raise "You must provide a project or workspace"          
  end          

  raise "Could not create a builder using #{@args}" if @builder.nil?
  
  unless @platform.nil?
    builder.sdk = @platform.sdk
  end 

  unless @identity.nil?
    builder.identity = @identity
  end

  unless @keychain.nil?
    keychain = Xcode::Keychain.new @keychain[:path]
    keychain.unlock @keychain[:password] unless @keychain[:password].nil?

    builder.identity = keychain.identities.first
    builder.keychain = keychain
  end
  
  builder.profile = @profile

  @before.call builder

  @builder
end