Class: Pod::Command::Pack
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Pack
- Includes:
- FindFollow, Pod::Config::Mixin
- Defined in:
- lib/cocoapods-pack/command/pack.rb
Defined Under Namespace
Classes: XCArchive
Constant Summary collapse
- LICENSE_GLOB_PATTERNS =
Pod::Sandbox::FileAccessor::GLOB_PATTERNS[:license]
- CONCRETE_TARGET_NAME =
'Bin'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Pack
constructor
A new instance of Pack.
- #run ⇒ Object
- #validate! ⇒ Object
Methods included from FindFollow
Constructor Details
#initialize(argv) ⇒ Pack
Returns a new instance of Pack.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/cocoapods-pack/command/pack.rb', line 88 def initialize(argv) @podspec_path = argv.shift_argument @artifact_repo_url = argv.shift_argument @allow_warnings = argv.flag?('allow-warnings', false) @repo_update = argv.flag?('repo-update', false) @generate_module_map = argv.flag?('generate-module-map', false) @use_static_frameworks = argv.flag?('use-static-frameworks', false) @skip_validation = argv.flag?('skip-validation', false) @xcodebuild_opts = argv.option('xcodebuild-opts') @out_dir = argv.option('out-dir', Dir.getwd) @skipped_platforms = argv.option('skip-platforms', '').split(',') @source_urls = argv.option('sources', Config.instance.sources_manager.all.map(&:url).join(',')).split(',') @use_json = argv.flag?('use-json', false) @build_settings_memoized = {} @sandbox_map = {} @project_files_dir = nil @project_zips_dir = nil super end |
Class Method Details
.options ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/cocoapods-pack/command/pack.rb', line 70 def self. [ ['--use-static-frameworks', 'Produce a framework that wraps a static library from the source files. ' \ 'By default dynamic frameworks are used.'], ['--generate-module-map', 'If specified, instead of using the default generated umbrella module map one ' \ 'will be generated based on the frameworks header dirs.'], ['--allow-warnings', 'Lint validates even if warnings are present.'], ['--repo-update', 'Force running `pod repo update` before install.'], ['--out-dir', 'Optional directory to use to output results into. Defaults to current working directory.'], ['--skip-validation', 'Skips linting the generated binary podspec.'], ['--skip-platforms', 'Comma-delimited platforms to skip when creating a binary.'], ['--xcodebuild-opts', 'Options to be passed through to xcodebuild.'], ['--use-json', 'Use JSON for the generated binary podspec.'], ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependant pods ' \ '(defaults to all available repos). Multiple sources must be comma-delimited.'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/cocoapods-pack/command/pack.rb', line 114 def run podspec = Specification.from_file(podspec_to_pack) @project_files_dir = File.(File.join(@out_dir, 'files', podspec.name, podspec.version.to_s)) @project_zips_dir = File.(File.join(@out_dir, 'zips', podspec.name, podspec.version.to_s)) @artifact_repo_url ||= podspec.attributes_hash['artifact_repo_url'] FileUtils.mkdir_p(@project_files_dir) FileUtils.mkdir_p(@project_zips_dir) help! 'Must supply an artifact repo url.' unless @artifact_repo_url stage_dir = File.join(@project_files_dir, 'staged') FileUtils.rm_rf(stage_dir) FileUtils.mkdir_p(stage_dir) source_urls = @source_urls.map { |url| Config.instance.sources_manager.source_with_name_or_url(url) }.map(&:url) staged_sources = false available_platforms(podspec).each do |platform| linkage = @use_static_frameworks ? :static : :dynamic podfile = podfile_from_spec(platform, podspec, source_urls, linkage, @is_local) sandbox = install(podfile, platform, podspec) @sandbox_map[platform.name] = sandbox xcodebuild_out_dir = File.join(sandbox.root.to_s, 'xcodebuild') build(podspec, platform, sandbox, xcodebuild_out_dir) xcarchives = Dir.glob(File.join(xcodebuild_out_dir, '**', '*.xcarchive')).map do |path| XCArchive.new(path, podspec) end unless xcarchives.all?(&:empty?) stage_platform_xcframework(platform, sandbox, podspec, xcarchives, xcodebuild_out_dir, stage_dir) staged_sources = true end end stage_additional_artifacts(podspec, stage_dir) zip_output_path = pack(stage_dir, @project_zips_dir, podspec.name) binary_podspec = generate_binary_podspec(podspec, stage_dir, zip_output_path, staged_sources) validate_binary_podspec(binary_podspec) UI. "Binary pod for #{podspec.name} created successfully!".green rescue XcodeBuilder::BuildError => e raise Informative, e end |
#validate! ⇒ Object
108 109 110 111 112 |
# File 'lib/cocoapods-pack/command/pack.rb', line 108 def validate! super help! 'A podspec file is required.' unless @podspec_path help! 'Must supply an output directory.' unless @out_dir end |