Class: FWToolkit::Xcode

Inherits:
Thor
  • Object
show all
Includes:
ThorUtils, Thor::Actions
Defined in:
lib/fwtoolkit/cli/xcode.rb

Instance Method Summary collapse

Methods included from ThorUtils

included

Methods included from Thor::Actions

#run, #run!, #run_base, #template_directory

Instance Method Details

#build(project_dir) ⇒ Object

Raises:

  • (Thor::Error)


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fwtoolkit/cli/xcode.rb', line 61

def build(project_dir)
  build_types = ['dev', 'testing', 'release']
  raise Thor::Error, 'Build type should be one of the following: dev, testing, release' unless build_types.include?(options[:type].downcase) 

  Projectfile.load! project_dir
  output_dir = File.join artifacts_dir_for_project(Config.project_name), Projectfile.project_name
  say_status :run, "Compiling the project and putting the output in: #{output_dir}", :blue

  t = XcodeBuild::Tasks::BuildTask.new
  t.invoke_from_within = 'project_dir'
  t.sdk = options[:sdk]
  t.workspace = Projectfile.xcode_workspace
  t.scheme = Projectfile.xcode_scheme[options[:type].to_sym]
  t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
  t.add_build_setting 'CONFIGURATION_BUILD_DIR', output_dir

  if options[:clean]
    FileUtils.rm_rf output_dir
    t.clean!
  end
  options[:archive] ? t.archive! : t.build!
end

#new(project_language, project_name, class_prefix, root_dir = File.join(Dir.pwd, project_name)) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fwtoolkit/cli/xcode.rb', line 29

def new(project_language, project_name, class_prefix, root_dir=File.join(Dir.pwd, project_name))
  say 'Creating Xcode project'
  destination_root = root_dir

  #raise Thor::Error, "Can't create the project. The directory #{destination_root} already exists" if Dir.exist?(destination_root)

  Projectfile.load_with_config! :project_name => project_name, :class_prefix => class_prefix.upcase

  template_config = { :target_platform => Config.target_platform,
                      :organization_name => Config.organization_name,
                      :project_creator => Config.developer_name } 
  template_config.merge! Projectfile.config 
  template_directory "templates/#{project_language}_project/xcode", destination_root, template_config
end