Class: IOSBox::Tools::Build

Inherits:
Thor
  • Object
show all
Defined in:
lib/ios-box/tools/build.rb

Instance Method Summary collapse

Instance Method Details

#prepareObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ios-box/tools/build.rb', line 6

def prepare
  # Make sure we are in XCode environment
  require_xcode

  # Update build cache
  update_cache

  version = IOSBox.new.version

  puts "Bundle Version: #{version[:bundle]}"
  puts " Short Version: #{version[:short]}"
  puts "         Build: #{version[:build]}"

  # Inject information to Info.plist
  product_plist = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH'])

  # Convert PList to XML
  `/usr/bin/plutil -convert xml1 \"#{product_plist}\"`
  pl = Plist::parse_xml(product_plist)
  if (pl)
    # pl["CFBundleVersion"] = @config._bundle_version
    pl["IBBuildNum"] = version[:build]
    pl["IBBuildDate"] = Time.new.strftime("%a %e %b %Y %H:%M:%S %Z %z")
    pl["IBBuildType"] = ENV['CONFIGURATION']
    pl["GCGitCommitHash"] = version[:commit] # for airbrake
    pl.save_plist(product_plist)
  end
  # Convert PList back to binary
  `/usr/bin/plutil -convert binary1 \"#{product_plist}\"`
end