Class: Pod::Generate::Configuration
- Inherits:
-
Object
- Object
- Pod::Generate::Configuration
- Defined in:
- lib/cocoapods/generate/configuration.rb
Class Attribute Summary collapse
-
.options ⇒ Array<Option>
readonly
All of the options available in the configuration.
Instance Attribute Summary collapse
-
#app_host_source_dir ⇒ [String, Pathname]
readonly
defaults to
nil. -
#auto_open ⇒ BOOLEAN
readonly
defaults to
false. -
#clean ⇒ BOOLEAN
readonly
defaults to
false. -
#deterministic_uuids ⇒ BOOLEAN
readonly
defaults to
(use_podfile && podfile) ? podfile.installation_options.deterministic_uuids : false. -
#disable_input_output_paths ⇒ BOOLEAN
readonly
defaults to
(use_podfile && podfile) ? podfile.installation_options.disable_input_output_paths : false. -
#external_source_pods ⇒ new
readonly
defaults to
[]. -
#gen_directory ⇒ [String, Pathname]
readonly
defaults to
Pathname("gen").expand_path. -
#generate_multiple_pod_projects ⇒ BOOLEAN
readonly
defaults to
false. -
#incremental_installation ⇒ BOOLEAN
readonly
defaults to
false. -
#local_sources ⇒ new
readonly
defaults to
[]. -
#lockfile ⇒ [Pod::Lockfile]
readonly
defaults to
pod_config.lockfile. -
#platforms ⇒ new
readonly
defaults to
nil. -
#pod_config ⇒ Config
readonly
defaults to
Pod::Config.instance. -
#podfile ⇒ [Podfile]
readonly
defaults to
Podfile.from_file(podfile_path) if (podfile_path && File.file?(File.expand_path(podfile_path))). -
#podfile_path ⇒ [String, Pathname]
readonly
defaults to
pod_config.podfile_path. -
#podfile_plugins ⇒ new
readonly
defaults to
(use_podfile && podfile) ? podfile.plugins : {}. -
#podspec_paths ⇒ new
readonly
defaults to
[Pathname(?.)]. -
#podspecs ⇒ new
readonly
defaults to
self.class.podspecs_from_paths(podspec_paths, gen_directory). -
#repo_update ⇒ BOOLEAN
readonly
defaults to
false. -
#share_schemes_for_development_pods ⇒ [TrueClass, FalseClass, Array]
readonly
defaults to
(use_podfile && podfile) ? podfile.installation_options.share_schemes_for_development_pods : true. -
#single_workspace ⇒ BOOLEAN
readonly
defaults to
false. -
#sources ⇒ new
readonly
defaults to
if use_podfile && podfile then ::Pod::Installer::Analyzer.new(:sandbox, podfile).sources.map(&:url) else pod_config.sources_manager.all.map(&:url) end. -
#use_default_plugins ⇒ BOOLEAN
readonly
defaults to
false. -
#use_libraries ⇒ BOOLEAN
readonly
defaults to
false. -
#use_lockfile ⇒ BOOLEAN
readonly
defaults to
!!lockfile. -
#use_lockfile_versions ⇒ BOOLEAN
readonly
defaults to
use_lockfile. -
#use_modular_headers ⇒ BOOLEAN
readonly
defaults to
false. -
#use_podfile ⇒ BOOLEAN
readonly
defaults to
!!podfile. -
#use_podfile_plugins ⇒ BOOLEAN
readonly
defaults to
use_podfile. -
#warn_for_multiple_pod_sources ⇒ BOOLEAN
readonly
defaults to
(use_podfile && podfile) ? podfile.installation_options.warn_for_multiple_pod_sources : false. -
#xcode_version ⇒ Pod::Version
readonly
defaults to
Pod::Version.new(\'9.3\').
Class Method Summary collapse
-
.from_env(env = ENV) ⇒ Hash<Symbol,Object>
The configuration hash parsed from the env.
-
.from_file(path) ⇒ Hash<Symbol,Object>
The configuration hash parsed from the given file.
-
.podspecs_from_paths(paths, gen_directory) ⇒ Array<Specification>
The podspecs found at the given paths.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether this configuration is equivalent to other.
-
#gen_dir_for_specs(specs) ⇒ Pathname
The directory for installation of the generated workspace.
-
#project_name_for_specs(specs) ⇒ String
The project name to use for generating this workspace.
-
#to_h ⇒ Hash<Symbol,Object>
A hash where the keys are option names and values are the non-nil set values.
-
#to_s ⇒ String
A string describing the configuration, suitable for UI presentation.
-
#use_frameworks? ⇒ Boolean
Whether gen should install with dynamic frameworks.
-
#validate ⇒ Array<String>
Errors in the configuration.
-
#with_changes(changes) ⇒ Configuration
A new configuration object with the given changes applies.
Class Attribute Details
.options ⇒ Array<Option> (readonly)
Returns all of the options available in the configuration.
11 12 13 |
# File 'lib/cocoapods/generate/configuration.rb', line 11 def @options end |
Instance Attribute Details
#app_host_source_dir ⇒ [String, Pathname] (readonly)
defaults to nil
163 164 165 166 167 |
# File 'lib/cocoapods/generate/configuration.rb', line 163 option :app_host_source_dir, [String, Pathname], 'nil', 'A directory containing sources to use for the app host', 'DIR', ->(dir) { 'not a directory' unless dir.directory? }, coerce_to_pathname |
#auto_open ⇒ BOOLEAN (readonly)
defaults to false
160 |
# File 'lib/cocoapods/generate/configuration.rb', line 160 option :auto_open, BOOLEAN, 'false', 'Whether to automatically open the generated workspaces', nil, nil, coerce_to_bool |
#clean ⇒ BOOLEAN (readonly)
defaults to false
161 |
# File 'lib/cocoapods/generate/configuration.rb', line 161 option :clean, BOOLEAN, 'false', 'Whether to clean the generated directories before generating', nil, nil, coerce_to_bool |
#deterministic_uuids ⇒ BOOLEAN (readonly)
defaults to (use_podfile && podfile) ? podfile.installation_options.deterministic_uuids : false
206 |
# File 'lib/cocoapods/generate/configuration.rb', line 206 option :deterministic_uuids, BOOLEAN, '(use_podfile && podfile) ? podfile.installation_options.deterministic_uuids : false', 'Whether installation should use deterministic UUIDs for pods projects', nil, nil, coerce_to_bool |
#disable_input_output_paths ⇒ BOOLEAN (readonly)
defaults to (use_podfile && podfile) ? podfile.installation_options.disable_input_output_paths : false
207 |
# File 'lib/cocoapods/generate/configuration.rb', line 207 option :disable_input_output_paths, BOOLEAN, '(use_podfile && podfile) ? podfile.installation_options.disable_input_output_paths : false', 'Whether to disable the input & output paths of the CocoaPods script phases (Copy Frameworks & Copy Resources)', nil, nil, coerce_to_bool |
#external_source_pods ⇒ new (readonly)
defaults to []
213 214 215 216 217 218 |
# File 'lib/cocoapods/generate/configuration.rb', line 213 option :external_source_pods, ArrayOf.new(HashOf.new(keys: [String], values: [ArrayOf.new(HashOf.new(keys: [String], values: [String]))])), [], nil, nil, nil, ->(external_sources) { Array(external_sources) } |
#gen_directory ⇒ [String, Pathname] (readonly)
defaults to Pathname("gen").expand_path
159 |
# File 'lib/cocoapods/generate/configuration.rb', line 159 option :gen_directory, [String, Pathname], 'Pathname("gen").expand_path', 'Path to generate workspaces in', 'PATH', ->(path) { 'path is file' if path.file? }, coerce_to_pathname |
#generate_multiple_pod_projects ⇒ BOOLEAN (readonly)
defaults to false
156 |
# File 'lib/cocoapods/generate/configuration.rb', line 156 option :generate_multiple_pod_projects, BOOLEAN, 'false', 'Whether to generate multiple Xcode projects', nil, nil, coerce_to_bool |
#incremental_installation ⇒ BOOLEAN (readonly)
defaults to false
157 |
# File 'lib/cocoapods/generate/configuration.rb', line 157 option :incremental_installation, BOOLEAN, 'false', 'Whether to use incremental installation', nil, nil, coerce_to_bool |
#local_sources ⇒ new (readonly)
defaults to []
189 190 191 192 193 194 |
# File 'lib/cocoapods/generate/configuration.rb', line 189 option :local_sources, ArrayOf.new(String), [], 'Paths from which to find local podspecs for transitive dependencies. Multiple local-sources must be comma-delimited.', 'SOURCE1,SOURCE2', ->(_) { nil }, ->(local_sources) { Array(local_sources).flat_map { |s| s.split(',') } } |
#lockfile ⇒ [Pod::Lockfile] (readonly)
defaults to pod_config.lockfile
150 |
# File 'lib/cocoapods/generate/configuration.rb', line 150 option :lockfile, [Pod::Lockfile], 'pod_config.lockfile', nil |
#platforms ⇒ new (readonly)
defaults to nil
195 196 197 198 199 200 201 202 203 |
# File 'lib/cocoapods/generate/configuration.rb', line 195 option :platforms, ArrayOf.new(String), nil, 'Limit to specific platforms. Default is all platforms supported by the podspec. Multiple platforms must be comma-delimited.', 'ios,macos', lambda { |platforms| valid_platforms = Platform.all.map { |p| p.string_name.downcase } valid_platforms unless (platforms - valid_platforms).empty? }, # validates platforms is a subset of Platform.all ->(platforms) { Array(platforms).flat_map { |s| s.split(',') } } |
#pod_config ⇒ Config (readonly)
defaults to Pod::Config.instance
137 |
# File 'lib/cocoapods/generate/configuration.rb', line 137 option :pod_config, Config, 'Pod::Config.instance', nil |
#podfile ⇒ [Podfile] (readonly)
defaults to Podfile.from_file(podfile_path) if (podfile_path && File.file?(File.expand_path(podfile_path)))
140 |
# File 'lib/cocoapods/generate/configuration.rb', line 140 option :podfile, [Podfile], 'Podfile.from_file(podfile_path) if (podfile_path && File.file?(File.expand_path(podfile_path)))' |
#podfile_path ⇒ [String, Pathname] (readonly)
defaults to pod_config.podfile_path
139 |
# File 'lib/cocoapods/generate/configuration.rb', line 139 option :podfile_path, [String, Pathname], 'pod_config.podfile_path', 'Path to podfile to use', 'PATH', ->(path) { 'file does not exist' unless path.file? }, coerce_to_pathname |
#podfile_plugins ⇒ new (readonly)
defaults to (use_podfile && podfile) ? podfile.plugins : {}
143 144 145 146 147 148 |
# File 'lib/cocoapods/generate/configuration.rb', line 143 option :podfile_plugins, HashOf.new(keys: [String], values: [NilClass, HashOf.new(keys: [String], values: [TrueClass, FalseClass, NilClass, String, Hash, Array])]), '(use_podfile && podfile) ? podfile.plugins : {}', nil, nil, nil, ->(hash) { Hash[hash] } |
#podspec_paths ⇒ new (readonly)
defaults to [Pathname(?.)]
169 170 171 172 173 174 |
# File 'lib/cocoapods/generate/configuration.rb', line 169 option :podspec_paths, ArrayOf.new(String, Pathname, URI), '[Pathname(?.)]', nil, nil, ->(paths) { ('paths do not exist' unless paths.all? { |p| p.is_a?(URI) || p.exist? }) }, ->(paths) { paths && paths.map { |path| path.to_s =~ %r{https?://} ? URI(path) : Pathname(path). } } |
#podspecs ⇒ new (readonly)
defaults to self.class.podspecs_from_paths(podspec_paths, gen_directory)
175 176 177 178 179 180 |
# File 'lib/cocoapods/generate/configuration.rb', line 175 option :podspecs, ArrayOf.new(Pod::Specification), 'self.class.podspecs_from_paths(podspec_paths, gen_directory)', nil, nil, ->(specs) { 'no podspecs found' if specs.empty? }, ->(paths) { paths && paths.map { |path| Pathname(path). } } |
#repo_update ⇒ BOOLEAN (readonly)
defaults to false
204 |
# File 'lib/cocoapods/generate/configuration.rb', line 204 option :repo_update, BOOLEAN, 'false', 'Force running `pod repo update` before install', nil, nil, coerce_to_bool |
#share_schemes_for_development_pods ⇒ [TrueClass, FalseClass, Array] (readonly)
defaults to (use_podfile && podfile) ? podfile.installation_options.share_schemes_for_development_pods : true
208 |
# File 'lib/cocoapods/generate/configuration.rb', line 208 option :share_schemes_for_development_pods, [TrueClass, FalseClass, Array], '(use_podfile && podfile) ? podfile.installation_options.share_schemes_for_development_pods : true', 'Whether installation should share schemes for development pods', nil, nil |
#single_workspace ⇒ BOOLEAN (readonly)
defaults to false
211 |
# File 'lib/cocoapods/generate/configuration.rb', line 211 option :single_workspace, BOOLEAN, 'false', 'Whether to produce a single workspace for all podspecs specified.', nil, nil, coerce_to_bool |
#sources ⇒ new (readonly)
defaults to if use_podfile && podfile then ::Pod::Installer::Analyzer.new(:sandbox, podfile).sources.map(&:url) else pod_config.sources_manager.all.map(&:url) end
183 184 185 186 187 188 |
# File 'lib/cocoapods/generate/configuration.rb', line 183 option :sources, ArrayOf.new(String), 'if use_podfile && podfile then ::Pod::Installer::Analyzer.new(:sandbox, podfile).sources.map(&:url) else pod_config.sources_manager.all.map(&:url) end', 'The sources from which to pull dependent pods (defaults to all repos in the podfile if using the podfile, else all available repos). Can be a repo name or URL. Multiple sources must be comma-delimited.', 'SOURCE1,SOURCE2', ->(_) { nil }, ->(sources) { Array(sources).flat_map { |s| s.split(',') } } |
#use_default_plugins ⇒ BOOLEAN (readonly)
defaults to false
205 |
# File 'lib/cocoapods/generate/configuration.rb', line 205 option :use_default_plugins, BOOLEAN, 'false', 'Whether installation should activate default plugins', nil, nil, coerce_to_bool |
#use_libraries ⇒ BOOLEAN (readonly)
defaults to false
154 |
# File 'lib/cocoapods/generate/configuration.rb', line 154 option :use_libraries, BOOLEAN, 'false', 'Whether to use libraries instead of frameworks', nil, nil, coerce_to_bool |
#use_lockfile ⇒ BOOLEAN (readonly)
defaults to !!lockfile
151 |
# File 'lib/cocoapods/generate/configuration.rb', line 151 option :use_lockfile, BOOLEAN, '!!lockfile', 'Whether the lockfile should be used to discover transitive dependencies', nil, nil, coerce_to_bool |
#use_lockfile_versions ⇒ BOOLEAN (readonly)
defaults to use_lockfile
152 |
# File 'lib/cocoapods/generate/configuration.rb', line 152 option :use_lockfile_versions, BOOLEAN, 'use_lockfile', 'Whether versions from the lockfile should be used', nil, nil, coerce_to_bool |
#use_modular_headers ⇒ BOOLEAN (readonly)
defaults to false
210 |
# File 'lib/cocoapods/generate/configuration.rb', line 210 option :use_modular_headers, BOOLEAN, 'false', 'Whether the target should be generated as a clang module, treating dependencies as modules, as if `use_modular_headers!` were specified. Will error if both this option and a podfile are specified', nil, nil, coerce_to_bool |
#use_podfile ⇒ BOOLEAN (readonly)
defaults to !!podfile
141 |
# File 'lib/cocoapods/generate/configuration.rb', line 141 option :use_podfile, BOOLEAN, '!!podfile', 'Whether restrictions should be copied from the podfile', nil, nil, coerce_to_bool |
#use_podfile_plugins ⇒ BOOLEAN (readonly)
defaults to use_podfile
142 |
# File 'lib/cocoapods/generate/configuration.rb', line 142 option :use_podfile_plugins, BOOLEAN, 'use_podfile', 'Whether plugins should be copied from the podfile', nil, nil, coerce_to_bool |
#warn_for_multiple_pod_sources ⇒ BOOLEAN (readonly)
defaults to (use_podfile && podfile) ? podfile.installation_options.warn_for_multiple_pod_sources : false
209 |
# File 'lib/cocoapods/generate/configuration.rb', line 209 option :warn_for_multiple_pod_sources, BOOLEAN, '(use_podfile && podfile) ? podfile.installation_options.warn_for_multiple_pod_sources : false', 'Whether installation should warn when a pod is found in multiple sources', nil, nil, coerce_to_bool |
#xcode_version ⇒ Pod::Version (readonly)
defaults to Pod::Version.new(\'9.3\')
212 |
# File 'lib/cocoapods/generate/configuration.rb', line 212 option :xcode_version, Pod::Version, 'Pod::Version.new(\'9.3\')', 'The Xcode version to use for producing the consumer sample project', 'xcode_version', nil, coerce_to_version |
Class Method Details
.from_env(env = ENV) ⇒ Hash<Symbol,Object>
Returns the configuration hash parsed from the env.
265 266 267 268 269 270 |
# File 'lib/cocoapods/generate/configuration.rb', line 265 def self.from_env(env = ENV) .each_with_object({}) do |option, config| next unless (value = env["COCOAPODS_GENERATE_#{option.name.upcase}"]) config[option.name] = option.coerce(value) end end |
.from_file(path) ⇒ Hash<Symbol,Object>
Returns the configuration hash parsed from the given file.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/cocoapods/generate/configuration.rb', line 241 def self.from_file(path) raise Informative, "No cocoapods-generate configuration found at #{UI.path path}" unless path.file? require 'yaml' yaml = YAML.load_file(path) unless yaml.is_a?(Hash) unless path.read.strip.empty? raise Informative, "Hash not found in configuration at #{UI.path path} -- got #{yaml.inspect}" end yaml = {} end yaml = yaml.with_indifferent_access Dir.chdir(path.dirname) do .each_with_object({}) do |option, config| next unless yaml.key?(option.name) config[option.name] = option.coerce yaml[option.name] end end end |
.podspecs_from_paths(paths, gen_directory) ⇒ Array<Specification>
Returns the podspecs found at the given paths. This method will download specs from URLs and traverse a directory's children.
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/cocoapods/generate/configuration.rb', line 355 def self.podspecs_from_paths(paths, gen_directory) paths = [Pathname('.')] if paths.empty? paths.flat_map do |path| if path.is_a?(URI) require 'cocoapods/open-uri' begin contents = open(path.to_s).read rescue StandardError => e next e end begin Pod::Specification.from_string contents, path.to_s rescue StandardError $ERROR_INFO end elsif path.directory? glob = Pathname.glob(path. + '**/*.podspec{.json,}').select { |f| f.relative_path_from(gen_directory).to_s.start_with?('..') } glob.reject! { |f| File.basename(f.dirname) == 'Local Podspecs' && f.parent.parent.join('Manifest.lock').file? } next StandardError.new "no specs found in #{UI.path path}" if glob.empty? podspecs = glob.map { |f| Pod::Specification.from_file(f) } podspecs.group_by(&:name).sort_by(&:first).flat_map do |name, specs| if specs.size != 1 Pod::UI.warn("Multiple podspecs found for pod #{name}, which one will be used is undefined:#{specs.map { |s| "\n - #{s.defined_in_file}" }.join}") end specs end else Pod::Specification.from_file(path) end end end |
Instance Method Details
#==(other) ⇒ Boolean
Returns whether this configuration is equivalent to other.
302 303 304 305 |
# File 'lib/cocoapods/generate/configuration.rb', line 302 def ==(other) self.class == other.class && to_h == other.to_h end |
#gen_dir_for_specs(specs) ⇒ Pathname
Returns the directory for installation of the generated workspace.
322 323 324 325 |
# File 'lib/cocoapods/generate/configuration.rb', line 322 def gen_dir_for_specs(specs) basename = specs.count == 1 ? specs.first.name : 'Workspace' gen_directory.join(basename) end |
#project_name_for_specs(specs) ⇒ String
Returns The project name to use for generating this workspace.
338 339 340 341 342 343 344 |
# File 'lib/cocoapods/generate/configuration.rb', line 338 def project_name_for_specs(specs) project_name = specs.count == 1 ? +specs.first.name.dup : +'Workspace' # When using multiple Xcode project the project name will collide with the actual .xcodeproj meant for the pod # that we are generating the workspace for. project_name << 'Sample' if generate_multiple_pod_projects? && specs.count == 1 project_name end |
#to_h ⇒ Hash<Symbol,Object>
Returns a hash where the keys are option names and values are the non-nil set values.
292 293 294 295 296 297 298 |
# File 'lib/cocoapods/generate/configuration.rb', line 292 def to_h self.class..each_with_object({}) do |option, hash| value = send(option.name) next if value.nil? hash[option.name] = value end end |
#to_s ⇒ String
Returns a string describing the configuration, suitable for UI presentation.
309 310 311 312 313 314 315 316 |
# File 'lib/cocoapods/generate/configuration.rb', line 309 def to_s hash = to_h hash.delete(:pod_config) hash.each_with_index.each_with_object('`pod gen` configuration {'.dup) do |((k, v), i), s| s << ',' unless i.zero? s << "\n" << ' ' << k.to_s << ': ' << v.to_s.gsub(/:0x\h+/, '') end << ' }' end |
#use_frameworks? ⇒ Boolean
Returns whether gen should install with dynamic frameworks.
329 330 331 |
# File 'lib/cocoapods/generate/configuration.rb', line 329 def use_frameworks? !use_libraries? end |
#validate ⇒ Array<String>
Returns errors in the configuration.
274 275 276 277 278 279 |
# File 'lib/cocoapods/generate/configuration.rb', line 274 def validate hash = to_h self.class..map do |option| option.validate(hash[option.name]) end.compact end |
#with_changes(changes) ⇒ Configuration
Returns a new configuration object with the given changes applies.
285 286 287 |
# File 'lib/cocoapods/generate/configuration.rb', line 285 def with_changes(changes) self.class.new(**to_h.merge(changes)) end |