├── .gitignore ├── .rspec ├── .rubocop.yml ├── .rubocop_todo.yml ├── .travis.yml ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── LICENSE.txt ├── README.md ├── Rakefile ├── VERSION ├── cocoapods-packing-cubes.gemspec ├── lib ├── cocoapods_packing_cubes.rb └── cocoapods_plugin.rb └── spec ├── cocoapods_packing_cubes_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | --require spec_helper 4 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_from: .rubocop_todo.yml 2 | 3 | AllCops: 4 | TargetRubyVersion: 2.0 5 | 6 | Metrics: 7 | Enabled: false 8 | 9 | LineLength: 10 | Enabled: true 11 | Max: 100 12 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2018-10-29 22:41:22 -0500 using RuboCop version 0.49.1. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | 9 | # Offense count: 4 10 | Style/Documentation: 11 | Exclude: 12 | - 'spec/**/*' 13 | - 'test/**/*' 14 | - 'lib/cocoapods_packing_cubes.rb' 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | branches: 2 | only: 3 | - master 4 | 5 | language: ruby 6 | cache: bundler 7 | rvm: 8 | - 2.0.0-p647 9 | - 2.3.4 10 | - 2.4.1 11 | - 2.5.1 12 | - 2.6.1 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CocoaPods Packing Cubes Changelog 2 | 3 | ## Master 4 | 5 | ##### Enhancements 6 | 7 | * None. 8 | 9 | ##### Bug Fixes 10 | 11 | * None. 12 | 13 | 14 | ## 0.4.0 (2019-03-08) 15 | 16 | ##### Enhancements 17 | 18 | * Allow specifying defaults for unspecified pods using the `'*'` key. 19 | [Samuel Giddins](https://github.com/segiddins) 20 | 21 | 22 | ##### Bug Fixes 23 | 24 | * None. 25 | 26 | 27 | ## 0.3.1 (2018-11-14) 28 | 29 | ##### Enhancements 30 | 31 | * None. 32 | 33 | ##### Bug Fixes 34 | 35 | * Fix warning incorrectly being printed for incompatible CocoaPods. 36 | [Samuel Giddins](https://github.com/segiddins) 37 | 38 | 39 | ## 0.2.0 (2018-11-07) 40 | 41 | ##### Enhancements 42 | 43 | * Allow overriding `PodTarget#defines_module?` via the 44 | `'defines_module'` key. 45 | [Samuel Giddins](https://github.com/segiddins) 46 | 47 | 48 | ## 0.1.1 49 | 50 | ##### Bug Fixes 51 | 52 | * Fix running with old versions of CocoaPods. 53 | [Samuel Giddins](https://github.com/segiddins) 54 | 55 | 56 | ## 0.1.0 57 | 58 | ##### Enhancements 59 | 60 | * Initial implementation. 61 | [Samuel Giddins](https://github.com/segiddins) 62 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | # Specify your gem's dependencies in cocoapods-amicable.gemspec 6 | gemspec 7 | 8 | group :development do 9 | gem 'cocoapods', git: 'https://github.com/CocoaPods/CocoaPods.git' 10 | gem 'cocoapods-core', git: 'https://github.com/CocoaPods/Core.git' 11 | 12 | gem 'rspec' 13 | gem 'rubocop', '<=0.50' 14 | end 15 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/CocoaPods/CocoaPods.git 3 | revision: 78dfabb92bdd71af45c9490ee1658a26e01b0dc9 4 | specs: 5 | cocoapods (1.6.0.beta.2) 6 | activesupport (>= 4.0.2, < 5) 7 | claide (>= 1.0.2, < 2.0) 8 | cocoapods-core (= 1.6.0.beta.2) 9 | cocoapods-deintegrate (>= 1.0.2, < 2.0) 10 | cocoapods-downloader (>= 1.2.2, < 2.0) 11 | cocoapods-plugins (>= 1.0.0, < 2.0) 12 | cocoapods-search (>= 1.0.0, < 2.0) 13 | cocoapods-stats (>= 1.0.0, < 2.0) 14 | cocoapods-trunk (>= 1.3.1, < 2.0) 15 | cocoapods-try (>= 1.1.0, < 2.0) 16 | colored2 (~> 3.1) 17 | escape (~> 0.0.4) 18 | fourflusher (~> 2.1.0) 19 | gh_inspector (~> 1.0) 20 | molinillo (~> 0.6.6) 21 | nap (~> 1.0) 22 | ruby-macho (~> 1.3, >= 1.3.1) 23 | xcodeproj (>= 1.7.0, < 2.0) 24 | 25 | GIT 26 | remote: https://github.com/CocoaPods/Core.git 27 | revision: c9e43154a46fe88af32b776e7cada16fa521602f 28 | specs: 29 | cocoapods-core (1.6.0.beta.2) 30 | activesupport (>= 4.0.2, < 6) 31 | fuzzy_match (~> 2.0.4) 32 | nap (~> 1.0) 33 | 34 | PATH 35 | remote: . 36 | specs: 37 | cocoapods-packing-cubes (0.4.0) 38 | 39 | GEM 40 | remote: https://rubygems.org/ 41 | specs: 42 | CFPropertyList (3.0.0) 43 | activesupport (4.2.10) 44 | i18n (~> 0.7) 45 | minitest (~> 5.1) 46 | thread_safe (~> 0.3, >= 0.3.4) 47 | tzinfo (~> 1.1) 48 | ast (2.4.0) 49 | atomos (0.1.3) 50 | claide (1.0.2) 51 | cocoapods-deintegrate (1.0.2) 52 | cocoapods-downloader (1.2.2) 53 | cocoapods-plugins (1.0.0) 54 | nap 55 | cocoapods-search (1.0.0) 56 | cocoapods-stats (1.0.0) 57 | cocoapods-trunk (1.3.1) 58 | nap (>= 0.8, < 2.0) 59 | netrc (~> 0.11) 60 | cocoapods-try (1.1.0) 61 | colored2 (3.1.2) 62 | concurrent-ruby (1.1.3) 63 | diff-lcs (1.3) 64 | escape (0.0.4) 65 | fourflusher (2.1.0) 66 | fuzzy_match (2.0.4) 67 | gh_inspector (1.1.3) 68 | i18n (0.9.5) 69 | concurrent-ruby (~> 1.0) 70 | minitest (5.11.3) 71 | molinillo (0.6.6) 72 | nanaimo (0.2.6) 73 | nap (1.1.0) 74 | netrc (0.11.0) 75 | parallel (1.12.1) 76 | parser (2.4.0.2) 77 | ast (~> 2.3) 78 | powerpack (0.1.1) 79 | rainbow (2.2.2) 80 | rake 81 | rake (12.3.0) 82 | rspec (3.7.0) 83 | rspec-core (~> 3.7.0) 84 | rspec-expectations (~> 3.7.0) 85 | rspec-mocks (~> 3.7.0) 86 | rspec-core (3.7.1) 87 | rspec-support (~> 3.7.0) 88 | rspec-expectations (3.7.0) 89 | diff-lcs (>= 1.2.0, < 2.0) 90 | rspec-support (~> 3.7.0) 91 | rspec-mocks (3.7.0) 92 | diff-lcs (>= 1.2.0, < 2.0) 93 | rspec-support (~> 3.7.0) 94 | rspec-support (3.7.1) 95 | rubocop (0.49.1) 96 | parallel (~> 1.10) 97 | parser (>= 2.3.3.1, < 3.0) 98 | powerpack (~> 0.1) 99 | rainbow (>= 1.99.1, < 3.0) 100 | ruby-progressbar (~> 1.7) 101 | unicode-display_width (~> 1.0, >= 1.0.1) 102 | ruby-macho (1.3.1) 103 | ruby-progressbar (1.9.0) 104 | thread_safe (0.3.6) 105 | tzinfo (1.2.5) 106 | thread_safe (~> 0.1) 107 | unicode-display_width (1.3.0) 108 | xcodeproj (1.7.0) 109 | CFPropertyList (>= 2.3.3, < 4.0) 110 | atomos (~> 0.1.3) 111 | claide (>= 1.0.2, < 2.0) 112 | colored2 (~> 3.1) 113 | nanaimo (~> 0.2.6) 114 | 115 | PLATFORMS 116 | ruby 117 | 118 | DEPENDENCIES 119 | bundler (~> 1.16) 120 | cocoapods! 121 | cocoapods-core! 122 | cocoapods-packing-cubes! 123 | rake (~> 12.3) 124 | rspec 125 | rubocop (<= 0.50) 126 | 127 | BUNDLED WITH 128 | 1.17.3 129 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Samuel Giddins 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocoapods-packing-cubes 2 | 3 | A small CocoaPods plugin that allows specifying how individual pods are packaged and linked. 4 | 5 | ## Installation 6 | 7 | $ gem install cocoapods-packing-cubes 8 | 9 | ## Usage 10 | 11 | ```ruby 12 | # Podfile 13 | 14 | plugin 'cocoapods-packing-cubes', 15 | 'AFNetworking' => { 'linkage' => 'static', 'packaging' => 'framework' }, 16 | 'SVGKit' => { 'linkage' => 'dynamic', 'packaging' => 'framework' }, 17 | 'JSONKit' => { 'linkage' => 'static', 'packaging' => 'framework' } 18 | ``` 19 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'bundler/gem_tasks' 4 | require 'rspec/core/rake_task' 5 | require 'rubocop/rake_task' 6 | 7 | RSpec::Core::RakeTask.new 8 | RuboCop::RakeTask.new 9 | 10 | task default: %i[rubocop spec] 11 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.4.0 2 | -------------------------------------------------------------------------------- /cocoapods-packing-cubes.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = 'cocoapods-packing-cubes' 5 | spec.version = File.read(File.expand_path('VERSION', __dir__)) 6 | spec.authors = ['Samuel Giddins'] 7 | spec.email = ['segiddins@segiddins.me'] 8 | spec.summary = 'A CocoaPods plugin that allows customizing how ' \ 9 | 'individual pods are packaged and linked.' 10 | spec.homepage = 'https://github.com/segiddins/cocoapods-packing-cubes' 11 | spec.license = 'MIT' 12 | 13 | spec.files = Dir['lib/**/*'] 14 | 15 | spec.add_development_dependency 'bundler', '~> 1.16' 16 | spec.add_development_dependency 'rake', '~> 12.3' 17 | 18 | spec.required_ruby_version = '~> 2.0' 19 | end 20 | -------------------------------------------------------------------------------- /lib/cocoapods_packing_cubes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module CocoaPodsPackingCubes 4 | def self.warn_for_outdated_cocoapods 5 | @warn_for_outdated_cocoapods ||= begin 6 | Pod::UI.warn '[cocoapods-packing-cubes] Pod::Target::BuildType must be defined, either:', 7 | ['Update to CocoaPods master or 1.6.0+', 'Downgrade to packing cubes < 0.3'] 8 | true 9 | end 10 | end 11 | 12 | module PodTargetMixin 13 | def initialize(*) 14 | super 15 | 16 | return if packing_cube.empty? 17 | return CocoaPodsPackingCubes.warn_for_outdated_cocoapods unless defined?(::Pod::Target::BuildType) 18 | compute_packing_cube_override_type 19 | compute_packing_cube_override_defines_module 20 | end 21 | 22 | def packing_cube 23 | @packing_cube ||= begin 24 | packing_cubes_config = podfile.plugins.fetch('cocoapods-packing-cubes', {}) 25 | packing_cubes_config.fetch(pod_name) { packing_cubes_config.fetch('*', {}) } 26 | end 27 | rescue 28 | raise ::Pod::Informative, 'The cocoapods-packing-cubes plugin requires a hash of options.' 29 | end 30 | 31 | def compute_packing_cube_override_type 32 | linkage = packing_cube.fetch('linkage') { build_type.linkage }.to_sym 33 | packaging = packing_cube.fetch('packaging') { build_type.packaging }.to_sym 34 | 35 | @build_type = ::Pod::Target::BuildType.new(linkage: linkage, packaging: packaging) 36 | end 37 | 38 | def compute_packing_cube_override_defines_module 39 | return unless packing_cube.key?('defines_module') 40 | 41 | @defines_module = packing_cube['defines_module'] 42 | end 43 | end 44 | end 45 | 46 | module Pod 47 | class PodTarget 48 | prepend ::CocoaPodsPackingCubes::PodTargetMixin 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'cocoapods_packing_cubes' 4 | -------------------------------------------------------------------------------- /spec/cocoapods_packing_cubes_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'cocoapods_packing_cubes' 4 | require 'tmpdir' 5 | 6 | RSpec.describe CocoaPodsPackingCubes do 7 | describe described_class::PodTargetMixin do 8 | Spec = Struct.new(:static_framework) do 9 | def root 10 | self 11 | end 12 | end 13 | 14 | let(:pod_name) { 'FooBar' } 15 | let(:plugin_options) { {} } 16 | let(:podfile) { Struct.new(:plugins).new('cocoapods-packing-cubes' => plugin_options) } 17 | let(:root_spec_static_framework) { false } 18 | let(:root_spec) { Spec.new(root_spec_static_framework) } 19 | let(:host_requires_frameworks) { false } 20 | 21 | let(:described_class) do 22 | mixin = super() 23 | Class.new do 24 | prepend mixin 25 | 26 | attr_reader :podfile, :type, :defines_module, :pod_name, :host_requires_frameworks, :root_spec, :build_type 27 | alias_method :host_requires_frameworks?, :host_requires_frameworks 28 | def initialize(podfile, pod_name, host_requires_frameworks, root_spec) 29 | @podfile = podfile 30 | @pod_name = pod_name 31 | @host_requires_frameworks = host_requires_frameworks 32 | @build_type = ::Pod::Target::BuildType.infer_from_spec(root_spec, host_requires_frameworks: host_requires_frameworks) 33 | @root_spec = root_spec 34 | end 35 | end 36 | end 37 | 38 | let(:static_library) { ::Pod::Target::BuildType.static_library } 39 | let(:static_framework) { ::Pod::Target::BuildType.static_framework } 40 | let(:dynamic_library) { ::Pod::Target::BuildType.dynamic_library } 41 | let(:dynamic_framework) { ::Pod::Target::BuildType.dynamic_framework } 42 | 43 | subject(:pod_target) { described_class.new(podfile, pod_name, host_requires_frameworks, root_spec) } 44 | 45 | it 'has a packing_cube' do 46 | expect(pod_target.packing_cube).to eq({}) 47 | end 48 | 49 | it 'has a build type' do 50 | expect(pod_target.build_type).to eq static_library 51 | end 52 | 53 | context 'when host_requires_frameworks' do 54 | let(:host_requires_frameworks) { true } 55 | 56 | it 'defaults to a dynamic framework' do 57 | expect(pod_target.build_type).to eq dynamic_framework 58 | end 59 | 60 | context 'and linkage is static' do 61 | let(:plugin_options) { { pod_name => { 'linkage' => :static } } } 62 | 63 | it 'is a static framework' do 64 | expect(pod_target.build_type).to eq static_framework 65 | end 66 | end 67 | end 68 | 69 | context 'when * is specified' do 70 | let(:plugin_options) { { '*' => { 'linkage' => :static, 'packaging' => :framework } } } 71 | 72 | it 'uses the default' do 73 | expect(pod_target.build_type).to eq static_framework 74 | end 75 | 76 | context 'and the per-pod configuration is specified' do 77 | let(:plugin_options) { super().merge(pod_name => { 'linkage' => 'dynamic' }) } 78 | it 'uses the per-pod configuration' do 79 | expect(pod_target.build_type).to eq dynamic_library 80 | end 81 | end 82 | end 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'cocoapods' 4 | 5 | module Pod 6 | # Disable the wrapping so the output is deterministic in the tests. 7 | # 8 | UI.disable_wrap = true 9 | 10 | # Redirects the messages to an internal store. 11 | # 12 | module UI 13 | class << self 14 | attr_accessor :output 15 | attr_accessor :warnings 16 | attr_accessor :next_input 17 | 18 | def puts(message = '') 19 | @output << "#{message}\n" 20 | end 21 | 22 | def warn(message = '', _actions = []) 23 | @warnings << "#{message}\n" 24 | end 25 | 26 | def print(message) 27 | @output << message 28 | end 29 | 30 | alias gets next_input 31 | 32 | def print_warnings; end 33 | end 34 | end 35 | end 36 | 37 | RSpec.configure do |config| 38 | config.before(:each) do 39 | Pod::UI.output = ''.dup 40 | Pod::UI.warnings = ''.dup 41 | Pod::UI.next_input = ''.dup 42 | Pod::Config.instance = nil 43 | end 44 | end 45 | --------------------------------------------------------------------------------