Class: XcodeBuilder::Configuration
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- XcodeBuilder::Configuration
- Defined in:
- lib/xcode_builder/configuration.rb
Instance Method Summary collapse
- #app_bundle_path ⇒ Object
- #app_file_name ⇒ Object
- #build_arguments ⇒ Object
- #build_number ⇒ Object
- #build_number_from_podspec ⇒ Object
- #built_app_long_version_suffix ⇒ Object
- #built_app_path ⇒ Object
- #built_dsym_path ⇒ Object
- #deploy_using(strategy_name, &block) ⇒ Object
- #derived_build_dir ⇒ Object
- #derived_build_dir_from_build_output ⇒ Object
- #dsym_name ⇒ Object
- #dsym_path ⇒ Object
- #final_bundle_id ⇒ Object
- #increment_plist_number ⇒ Object
- #increment_pod_number ⇒ Object
- #info_plist_path ⇒ Object
- #ipa_name ⇒ Object
- #ipa_path ⇒ Object
- #next_build_number ⇒ Object
- #release_notes_text ⇒ Object
- #release_using(strategy_name, &block) ⇒ Object
- #zipped_package_name ⇒ Object
Instance Method Details
#app_bundle_path ⇒ Object
207 208 209 |
# File 'lib/xcode_builder/configuration.rb', line 207 def app_bundle_path "#{package_destination_path}/#{app_name}.#{app_extension}" end |
#app_file_name ⇒ Object
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_arguments ⇒ Object
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. 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 xcodebuild_extra_args.is_a? String end args end |
#build_number ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/xcode_builder/configuration.rb', line 62 def build_number # we have a podspec file, so try to get the version out of that if (podspec_file != nil) && (File.exists? podspec_file) then # get hte version out of the pod file return build_number_from_podspec end # 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 |
#build_number_from_podspec ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/xcode_builder/configuration.rb', line 80 def build_number_from_podspec file = File.open(podspec_file, "r") begin version_line = file.gets end while version_line.eql? "\n" if match = version_line.match(/\s*version\s*=\s*["'](.*)["']\s*/i) version = match.captures end return version[0] end |
#built_app_long_version_suffix ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/xcode_builder/configuration.rb', line 152 def built_app_long_version_suffix if build_number == nil then "" else "-#{build_number}" end end |
#built_app_path ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/xcode_builder/configuration.rb', line 165 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_path ⇒ Object
174 175 176 |
# File 'lib/xcode_builder/configuration.rb', line 174 def built_dsym_path "#{built_app_path}.dSYM" end |
#deploy_using(strategy_name, &block) ⇒ Object
211 212 213 214 215 216 217 218 |
# File 'lib/xcode_builder/configuration.rb', line 211 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_dir ⇒ Object
178 179 180 181 182 183 |
# File 'lib/xcode_builder/configuration.rb', line 178 def derived_build_dir workspace_name = Pathname.new(workspace_file_path).basename.to_s.split(".")[0] for dir in Dir[File.join(File.("~/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_output ⇒ Object
186 187 188 189 |
# File 'lib/xcode_builder/configuration.rb', line 186 def derived_build_dir_from_build_output output = BuildOutputParser.new(File.read("build.output")) output.build_output_dir end |
#dsym_name ⇒ Object
199 200 201 |
# File 'lib/xcode_builder/configuration.rb', line 199 def dsym_name "#{app_name}#{built_app_long_version_suffix}.dSYM.zip" end |
#dsym_path ⇒ Object
203 204 205 |
# File 'lib/xcode_builder/configuration.rb', line 203 def dsym_path File.join(File.(package_destination_path), dsym_name) end |
#final_bundle_id ⇒ Object
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 |
#increment_plist_number ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/xcode_builder/configuration.rb', line 131 def increment_plist_number if !increment_plist_version then return false end if info_plist == nil then return false end # read the plist and extract data plist = CFPropertyList::List.new(:file => info_plist_path) data = CFPropertyList.native_types(plist.value) # re inject new version number into the data data["CFBundleVersion"] = next_build_number # recreate the plist and save it plist.value = CFPropertyList.guess(data) plist.save(info_plist_path, CFPropertyList::List::FORMAT_XML) end |
#increment_pod_number ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/xcode_builder/configuration.rb', line 105 def increment_pod_number if !increment_plist_version then return false end if podspec_file == nil then return false end # keep the old build number around old_build_number = build_number # bump the spec version and save it spec_content = File.open(podspec_file, "r").read old_version = "version = '#{old_build_number}'" new_version = "version = '#{next_build_number}'" spec_content = spec_content.sub old_version, new_version File.open(podspec_file, "w") {|f| f.write spec_content } true end |
#info_plist_path ⇒ Object
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. info_plist else nil end end |
#ipa_name ⇒ Object
160 161 162 163 |
# File 'lib/xcode_builder/configuration.rb', line 160 def ipa_name prefix = app_name == nil ? target : app_name "#{prefix}#{built_app_long_version_suffix}.ipa" end |
#ipa_path ⇒ Object
195 196 197 |
# File 'lib/xcode_builder/configuration.rb', line 195 def ipa_path File.join(File.(package_destination_path), ipa_name) end |
#next_build_number ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/xcode_builder/configuration.rb', line 92 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_text ⇒ Object
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
220 221 222 223 224 225 226 227 228 |
# File 'lib/xcode_builder/configuration.rb', line 220 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_name ⇒ Object
191 192 193 |
# File 'lib/xcode_builder/configuration.rb', line 191 def zipped_package_name "#{app_name}#{built_app_long_version_suffix}.zip" end |