Class: XcodeBuilder::Configuration

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/xcode_builder/configuration.rb

Instance Method Summary collapse

Instance Method Details

#app_bundle_pathObject



142
143
144
# File 'lib/xcode_builder/configuration.rb', line 142

def app_bundle_path
  "#{package_destination_path}/#{app_name}.#{app_extension}"
end

#app_file_nameObject

Raises:

  • (ArgumentError)


36
37
38
39
# File 'lib/xcode_builder/configuration.rb', line 36

def app_file_name
  raise ArgumentError, "app_name or target must be set in the BetaBuilder configuration block" if app_name.nil?
  "#{app_name}.#{app_extension}"
end

#build_argumentsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/xcode_builder/configuration.rb', line 12

def build_arguments
  args = []
  if workspace_file_path
    raise "A scheme is required if building from a workspace" unless scheme
    args << "-workspace '#{workspace_file_path}'"
    args << "-scheme '#{scheme}'"
  else
    args << "-target '#{target}'"
    args << "-project '#{project_file_path}'" if project_file_path
  end

  args << "-sdk #{sdk}"
  
  args << "-configuration '#{configuration}'"
  args << "BUILD_DIR=#{File.expand_path build_dir}" unless build_dir == :derived
  
  if xcodebuild_extra_args
      args.concat xcodebuild_extra_args if xcodebuild_extra_args.is_a? Array
      args << "#{xcodebuild_extra_args}" if xcodears.is_a? String
  end
  
  args
end

#build_numberObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/xcode_builder/configuration.rb', line 62

def build_number
  # no plist is found, return a nil version
  if (info_plist_path == nil)  || (!File.exists? info_plist_path) then
    return nil
  end

  # read the plist and extract data
  plist = CFPropertyList::List.new(:file => info_plist_path)
  data = CFPropertyList.native_types(plist.value)
  data["CFBundleVersion"]
end

#built_app_long_version_suffixObject



87
88
89
90
91
92
93
# File 'lib/xcode_builder/configuration.rb', line 87

def built_app_long_version_suffix
  if build_number == nil then
    ""
  else 
    "-#{build_number}"
  end
end

#built_app_pathObject



100
101
102
103
104
105
106
107
# File 'lib/xcode_builder/configuration.rb', line 100

def built_app_path
  sdk_extension = if sdk.eql? "macosx" then "" else "-#{sdk}" end
  if build_dir == :derived
    File.join("#{derived_build_dir}", "#{configuration}#{sdk_extension}", "#{app_file_name}")
  else
    File.join("#{build_dir}", "#{configuration}#{sdk_extension}", "#{app_file_name}")
  end
end

#built_dsym_pathObject



109
110
111
# File 'lib/xcode_builder/configuration.rb', line 109

def built_dsym_path
  "#{built_app_path}.dSYM"
end

#deploy_using(strategy_name, &block) ⇒ Object



146
147
148
149
150
151
152
153
# File 'lib/xcode_builder/configuration.rb', line 146

def deploy_using(strategy_name, &block)
  if DeploymentStrategies.valid_strategy?(strategy_name.to_sym)
    self.deployment_strategy = DeploymentStrategies.build(strategy_name, self)
    self.deployment_strategy.configure(&block)
  else
    raise "Unknown deployment strategy '#{strategy_name}'."
  end
end

#derived_build_dirObject



113
114
115
116
117
118
# File 'lib/xcode_builder/configuration.rb', line 113

def derived_build_dir 
  workspace_name = Pathname.new(workspace_file_path).basename.to_s.split(".")[0]
  for dir in Dir[File.join(File.expand_path("~/Library/Developer/Xcode/DerivedData"), "#{workspace_name}-*")]
    return "#{dir}/Build/Products" if File.read( File.join(dir, "info.plist") ).match workspace_file_path
  end
end

#derived_build_dir_from_build_outputObject



121
122
123
124
# File 'lib/xcode_builder/configuration.rb', line 121

def derived_build_dir_from_build_output
  output = BuildOutputParser.new(File.read("build.output"))
  output.build_output_dir  
end

#dsym_nameObject



134
135
136
# File 'lib/xcode_builder/configuration.rb', line 134

def dsym_name
  "#{app_name}#{built_app_long_version_suffix}.dSYM.zip"
end

#dsym_pathObject



138
139
140
# File 'lib/xcode_builder/configuration.rb', line 138

def dsym_path
  File.join(File.expand_path(package_destination_path), dsym_name)
end

#final_bundle_idObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/xcode_builder/configuration.rb', line 49

def final_bundle_id
  final_plist_path = "#{app_bundle_path}/Info.plist"
   # no plist is found, return a nil version
  if (final_plist_path == nil)  || (!File.exists? final_plist_path) then
    return nil
  end

  # read the plist and extract data
  plist = CFPropertyList::List.new(:file => final_plist_path)
  data = CFPropertyList.native_types(plist.value)
  data["CFBundleIdentifier"]
end

#info_plist_pathObject



41
42
43
44
45
46
47
# File 'lib/xcode_builder/configuration.rb', line 41

def info_plist_path
  if info_plist != nil then 
    File.expand_path info_plist
  else 
    nil
  end
end

#ipa_nameObject



95
96
97
98
# File 'lib/xcode_builder/configuration.rb', line 95

def ipa_name
  prefix = app_name == nil ? target : app_name
  "#{prefix}#{built_app_long_version_suffix}.ipa"
end

#ipa_pathObject



130
131
132
# File 'lib/xcode_builder/configuration.rb', line 130

def ipa_path
  File.join(File.expand_path(package_destination_path), ipa_name)
end

#next_build_numberObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/xcode_builder/configuration.rb', line 74

def next_build_number
  # if we don't have a current version, we don't have a next version :)
  if build_number == nil then
    return nil
  end

  # get a hold on the build number and increment it
  version_components = build_number.split(".")
  new_build_number = version_components.pop.to_i + 1
  version_components.push new_build_number.to_s
  version_components.join "."
end

#release_notes_textObject



7
8
9
10
# File 'lib/xcode_builder/configuration.rb', line 7

def release_notes_text
  return release_notes.call if release_notes.is_a? Proc
  release_notes
end

#release_using(strategy_name, &block) ⇒ Object



155
156
157
158
159
160
161
162
163
# File 'lib/xcode_builder/configuration.rb', line 155

def release_using(strategy_name, &block)
  if ReleaseStrategies.valid_strategy?(strategy_name.to_sym)
    self.release_strategy = ReleaseStrategies.build(strategy_name, self)
    self.release_strategy.configure(&block)
    self.release_strategy.prepare
  else
    raise "Unknown release strategy '#{strategy_name}'."
  end
end

#zipped_package_nameObject



126
127
128
# File 'lib/xcode_builder/configuration.rb', line 126

def zipped_package_name
  "#{app_name}#{built_app_long_version_suffix}.zip"
end