Class: Xcode::Buildfile
- Inherits:
-
Object
show all
- Defined in:
- lib/xcode/buildfile.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Buildfile.
4
5
6
7
8
|
# File 'lib/xcode/buildfile.rb', line 4
def initialize
@values = {}
@before = {:clean => [], :build => [], :package => []}
@after = {:clean => [], :build => [], :package => []}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
10
11
12
|
# File 'lib/xcode/buildfile.rb', line 10
def method_missing(method, *args)
@values[method.to_sym] = args[0]
end
|
Class Method Details
.load(file) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/xcode/buildfile.rb', line 26
def self.load(file)
file = File.expand_path file
raise "Unable to find the buildfile #{file}" if !File.exists? file
puts "Loading Buildfile: #{file}"
bc = Xcode::Buildfile.new
eval(File.read(file), bc.getBinding, file)
bc
end
|
Instance Method Details
#after(event, &block) ⇒ Object
18
19
20
|
# File 'lib/xcode/buildfile.rb', line 18
def after(event, &block)
@after[event]<< block
end
|
#before(event, &block) ⇒ Object
14
15
16
|
# File 'lib/xcode/buildfile.rb', line 14
def before(event, &block)
@before[event]<< block
end
|
#build ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/xcode/buildfile.rb', line 37
def build
label = "#{@values[:target]}"
puts "[#{label}] Loading project #{@values[:project]}, target #{@values[:target]}, config #{@values[:config]}"
config = Xcode.project(@values[:project]).target(@values[:target]).config(@values[:config])
config.info_plist do |info|
puts "[#{label}] Update info plist version to #{@values[:version]}"
info.version = @values[:version]
end
builder = config.builder
unless @values[:profile].nil?
builder.profile = @values[:profile]
puts "[#{label}] Set build profile to #{@values[:profile]}"
end
Keychain.temp do |kc|
kc.import @values[:certificate], @values[:password]
builder.identity = @values[:identity] || kc.identities.first
builder.keychain = kc
puts "[#{label}] CLEAN"
@before[:clean].each do |b|
b.call(builder)
end
builder.clean
@after[:clean].each do |b|
b.call(builder)
end
puts "[#{label}] BUILD"
@before[:build].each do |b|
b.call(builder)
end
builder.build
@after[:build].each do |b|
b.call(builder)
end
puts "[#{label}] PACKAGE"
@before[:package].each do |b|
b.call(builder)
end
builder.package
@after[:package].each do |b|
b.call(builder)
end
end
if @values.has_key? :testflight_api_token and @values.has_key? :testflight_team_token
puts "[#{label}] Uploading to testflight"
`curl -X POST http://testflightapp.com/api/builds.json -F file=@"#{builder.ipa_path}" -F dsym=@"#{builder.dsym_zip_path}" -F api_token='#{@values[:testflight_api_token]}' -F team_token='#{@values[:testflight_team_token]}' -F notify=True -F notes=\"#{@values[:testflight_notes]}\" -F distribution_lists='#{@values[:testflight_lists].join(',')}'`
end
builder
end
|
#getBinding ⇒ Object
22
23
24
|
# File 'lib/xcode/buildfile.rb', line 22
def getBinding
binding()
end
|