├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── cocoapods-static-frameworks.gemspec ├── lib ├── cocoapods-static-frameworks.rb ├── cocoapods-static-frameworks │ ├── command.rb │ ├── command │ │ ├── frameworks.rb │ │ └── patch │ │ │ ├── aggregate_target.rb │ │ │ ├── pod_xcconfig.rb │ │ │ └── xcconfig_helper.rb │ └── gem_version.rb └── cocoapods_plugin.rb └── spec ├── command └── frameworks_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in cocoapods-static-frameworks.gemspec 4 | gemspec 5 | 6 | group :development do 7 | gem 'cocoapods' 8 | 9 | gem 'mocha' 10 | gem 'bacon' 11 | gem 'mocha-on-bacon' 12 | gem 'prettybacon' 13 | end 14 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Stefan Pühringer 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-static-frameworks 2 | 3 | Build static instead of dynamic frameworks. 4 | Requires Xcode 9 and CocoaPods 1.3.1 5 | 6 | ## Installation 7 | 8 | $ gem install cocoapods-static-frameworks 9 | 10 | ## Usage 11 | 12 | In your podfile: 13 | 14 | ``` 15 | plugin 'cocoapods-static-frameworks' 16 | static_frameworks 17 | ``` 18 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | def specs(dir) 4 | FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ') 5 | end 6 | 7 | desc 'Runs all the specs' 8 | task :specs do 9 | sh "bundle exec bacon #{specs('**')}" 10 | end 11 | 12 | task :default => :specs 13 | 14 | -------------------------------------------------------------------------------- /cocoapods-static-frameworks.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'cocoapods-static-frameworks/gem_version.rb' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'cocoapods-static-frameworks' 8 | spec.version = CocoapodsStaticFrameworks::VERSION 9 | spec.authors = ['Stefan Pühringer'] 10 | spec.email = ['me@stefanpuehringer.com'] 11 | spec.description = %q{Build static instead of dynamic frameworks.} 12 | spec.summary = %q{Build static instead of dynamic frameworks.} 13 | spec.homepage = 'https://github.com/b-ray/cocoapods-static-frameworks' 14 | spec.license = 'MIT' 15 | 16 | spec.files = `git ls-files`.split($/) 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ['lib'] 20 | 21 | spec.add_runtime_dependency 'cocoapods', '1.3.1' 22 | 23 | spec.add_development_dependency 'bundler', '~> 1.3' 24 | spec.add_development_dependency 'rake' 25 | end 26 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-static-frameworks/gem_version' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/command.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-static-frameworks/command/frameworks' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/command/frameworks.rb: -------------------------------------------------------------------------------- 1 | module Pod 2 | class Podfile 3 | def static_frameworks 4 | require 'cocoapods-static-frameworks/command/patch/aggregate_target.rb' 5 | require 'cocoapods-static-frameworks/command/patch/pod_xcconfig.rb' 6 | require 'cocoapods-static-frameworks/command/patch/xcconfig_helper.rb' 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/command/patch/aggregate_target.rb: -------------------------------------------------------------------------------- 1 | module Pod 2 | class AggregateTarget < Target 3 | 4 | def framework_paths_by_config 5 | @framework_paths_by_config ||= begin 6 | framework_paths_by_config = {} 7 | user_build_configurations.keys.each do |config| 8 | relevant_pod_targets = pod_targets.select do |pod_target| 9 | !pod_target.should_build? && pod_target.include_in_build_config?(target_definition, config) 10 | end 11 | framework_paths_by_config[config] = relevant_pod_targets.flat_map(&:framework_paths) 12 | end 13 | framework_paths_by_config 14 | end 15 | end 16 | 17 | def resource_paths_by_config 18 | @resource_paths_by_config ||= begin 19 | relevant_pod_targets = pod_targets 20 | user_build_configurations.keys.each_with_object({}) do |config, resources_by_config| 21 | resources_by_config[config] = relevant_pod_targets.flat_map do |pod_target| 22 | next [] unless pod_target.include_in_build_config?(target_definition, config) 23 | (pod_target.resource_paths + [bridge_support_file].compact).uniq 24 | end 25 | end 26 | end 27 | end 28 | 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/command/patch/pod_xcconfig.rb: -------------------------------------------------------------------------------- 1 | module Pod 2 | module Generator 3 | module XCConfig 4 | class PodXCConfig 5 | 6 | def generate 7 | target_search_paths = target.build_headers.search_paths(target.platform) 8 | sandbox_search_paths = target.sandbox.public_headers.search_paths(target.platform) 9 | search_paths = target_search_paths.concat(sandbox_search_paths).uniq 10 | 11 | config = { 12 | 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ', 13 | 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 14 | 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths), 15 | 'LIBRARY_SEARCH_PATHS' => '$(inherited) ', 16 | 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target, @test_xcconfig), 17 | 'PODS_ROOT' => '${SRCROOT}', 18 | 'PODS_TARGET_SRCROOT' => target.pod_target_srcroot, 19 | 'PRODUCT_BUNDLE_IDENTIFIER' => 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}', 20 | 'SKIP_INSTALL' => 'YES', 21 | 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => '$(inherited) ', 22 | 'MACH_O_TYPE' => 'staticlib', 23 | # 'USE_HEADERMAP' => 'NO' 24 | } 25 | 26 | @xcconfig = Xcodeproj::Config.new(config) 27 | 28 | XCConfigHelper.add_settings_for_file_accessors_of_target(nil, target, @xcconfig) 29 | target.file_accessors.each do |file_accessor| 30 | @xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig) 31 | end 32 | XCConfigHelper.add_target_specific_settings(target, @xcconfig) 33 | recursive_dependent_targets = target.recursive_dependent_targets 34 | @xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, recursive_dependent_targets, @test_xcconfig) 35 | if @test_xcconfig 36 | test_dependent_targets = [target, *target.recursive_test_dependent_targets].uniq 37 | @xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, test_dependent_targets - recursive_dependent_targets, @test_xcconfig) 38 | XCConfigHelper.generate_vendored_build_settings(nil, target.all_test_dependent_targets, @xcconfig) 39 | XCConfigHelper.generate_other_ld_flags(nil, target.all_test_dependent_targets, @xcconfig) 40 | XCConfigHelper.generate_ld_runpath_search_paths(target, false, true, @xcconfig) 41 | end 42 | @xcconfig 43 | end 44 | 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/command/patch/xcconfig_helper.rb: -------------------------------------------------------------------------------- 1 | module Pod 2 | module Generator 3 | module XCConfig 4 | module XCConfigHelper 5 | 6 | def self.generate_vendored_build_settings(aggregate_target, pod_targets, xcconfig) 7 | pod_targets.each do |pod_target| 8 | XCConfigHelper.add_settings_for_file_accessors_of_target(aggregate_target, pod_target, xcconfig) 9 | end 10 | end 11 | 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/cocoapods-static-frameworks/gem_version.rb: -------------------------------------------------------------------------------- 1 | module CocoapodsStaticFrameworks 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-static-frameworks/command' 2 | -------------------------------------------------------------------------------- /spec/command/frameworks_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../spec_helper', __FILE__) 2 | 3 | module Pod 4 | describe Command::Frameworks do 5 | describe 'CLAide' do 6 | it 'registers it self' do 7 | Command.parse(%w{ frameworks }).should.be.instance_of Command::Frameworks 8 | end 9 | end 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | ROOT = Pathname.new(File.expand_path('../../', __FILE__)) 3 | $:.unshift((ROOT + 'lib').to_s) 4 | $:.unshift((ROOT + 'spec').to_s) 5 | 6 | require 'bundler/setup' 7 | require 'bacon' 8 | require 'mocha-on-bacon' 9 | require 'pretty_bacon' 10 | require 'pathname' 11 | require 'cocoapods' 12 | 13 | Mocha::Configuration.prevent(:stubbing_non_existent_method) 14 | 15 | require 'cocoapods_plugin' 16 | 17 | #-----------------------------------------------------------------------------# 18 | 19 | module Pod 20 | 21 | # Disable the wrapping so the output is deterministic in the tests. 22 | # 23 | UI.disable_wrap = true 24 | 25 | # Redirects the messages to an internal store. 26 | # 27 | module UI 28 | @output = '' 29 | @warnings = '' 30 | 31 | class << self 32 | attr_accessor :output 33 | attr_accessor :warnings 34 | 35 | def puts(message = '') 36 | @output << "#{message}\n" 37 | end 38 | 39 | def warn(message = '', actions = []) 40 | @warnings << "#{message}\n" 41 | end 42 | 43 | def print(message) 44 | @output << message 45 | end 46 | end 47 | end 48 | end 49 | 50 | #-----------------------------------------------------------------------------# 51 | --------------------------------------------------------------------------------