cocoapods-user-defined-build-types 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/cocoapods-user-defined-build-types.rb +1 -0
- data/lib/cocoapods-user-defined-build-types/gem_version.rb +3 -0
- data/lib/cocoapods-user-defined-build-types/main.rb +45 -0
- data/lib/cocoapods-user-defined-build-types/podfile_options.rb +14 -0
- data/lib/cocoapods-user-defined-build-types/private_api_hooks.rb +120 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5d3cca2f15f86a96f2b7fe37aa9eb633ae0de24728decded31e272d1b9b0aa68
|
4
|
+
data.tar.gz: 98aff5cbc68a352eb6ac3f0fb7e96f96bf1ec852f27f03b2ac0caf0d2338d4e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a4c5c89aa9c93de50706f3c59283b6e3e52c77d0b4c615f81fdea75e91a3203db760209dcae70b55e5ac70b3dcb02a7e5b9db06701c2acf0a42d588e45b9b29
|
7
|
+
data.tar.gz: 9150f4be4932569839d7065ed7f326f9be283f09d871bff2ffc1969f4e09dd18caa120970db6de8c39c34d6f2c5b32d2a3c4833761768b90da28013d7eeeafb0
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-user-defined-build-types/gem_version'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'private_api_hooks'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Podfile
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
@@enable_user_defined_build_types = false
|
8
|
+
|
9
|
+
def self.enable_user_defined_build_types
|
10
|
+
@@enable_user_defined_build_types
|
11
|
+
end
|
12
|
+
|
13
|
+
def enable_user_defined_build_types!
|
14
|
+
@@enable_user_defined_build_types = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module CocoapodsUserDefinedBuildTypes
|
21
|
+
PLUGIN_NAME = 'cocoapods-user-defined-build-types'
|
22
|
+
LATEST_SUPPORTED_COCOAPODS_VERSION = '1.8.4'
|
23
|
+
|
24
|
+
@@verbose_logging = false
|
25
|
+
|
26
|
+
def self.verbose_logging
|
27
|
+
@@verbose_logging
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.verbose_log(str)
|
31
|
+
if @@verbose_logging || ENV["CP_DEV"]
|
32
|
+
Pod::UI.puts "🔥 [#{PLUGIN_NAME}] #{str}".blue
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Pod::HooksManager.register(PLUGIN_NAME, :pre_install) do |installer_context, options|
|
37
|
+
if options['verbose'] != nil
|
38
|
+
@@verbose_logging = options['verbose']
|
39
|
+
end
|
40
|
+
|
41
|
+
if not Pod::Podfile::DSL.enable_user_defined_build_types
|
42
|
+
Pod::UI.warn "#{PLUGIN_NAME} is installed but the enable_user_defined_build_types! was not found in the Podfile. No build types were changed."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Pod
|
2
|
+
class Prebuild
|
3
|
+
|
4
|
+
# [Hash{String, BuildType}] mapping of Podfile keyword to a BuildType
|
5
|
+
def self.keyword_mapping
|
6
|
+
{
|
7
|
+
:dynamic_framework => Pod::Target::BuildType.dynamic_framework,
|
8
|
+
:dynamic_library => Pod::Target::BuildType.dynamic_library,
|
9
|
+
:static_framework => Pod::Target::BuildType.static_framework,
|
10
|
+
:static_library => Pod::Target::BuildType.static_library
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require_relative 'podfile_options'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
|
5
|
+
class Podfile
|
6
|
+
class TargetDefinition
|
7
|
+
|
8
|
+
# [Hash{String, BuildType}] mapping of pod name to preferred build type if specified.
|
9
|
+
@@root_pod_building_options = Hash.new
|
10
|
+
|
11
|
+
def self.root_pod_building_options
|
12
|
+
@@root_pod_building_options
|
13
|
+
end
|
14
|
+
|
15
|
+
# ======================
|
16
|
+
# ==== PATCH METHOD ====
|
17
|
+
# ======================
|
18
|
+
swizzled_parse_subspecs = instance_method(:parse_subspecs)
|
19
|
+
|
20
|
+
define_method(:parse_subspecs) do |name, requirements|
|
21
|
+
# Update hash map of pod target names and association with their preferred linking & packing
|
22
|
+
building_options = @@root_pod_building_options
|
23
|
+
pod_name = Specification.root_name(name)
|
24
|
+
options = requirements.last
|
25
|
+
|
26
|
+
CocoapodsUserDefinedBuildTypes.verbose_log("Hooked Cocoapods parse_subspecs function to obtain Pod options. #{pod_name}")
|
27
|
+
|
28
|
+
if options.is_a?(Hash)
|
29
|
+
options.each do |k,v|
|
30
|
+
if Pod::Prebuild.keyword_mapping.key?(k) && options.delete(k)
|
31
|
+
build_type = Pod::Prebuild.keyword_mapping[k]
|
32
|
+
building_options[pod_name] = build_type
|
33
|
+
CocoapodsUserDefinedBuildTypes.verbose_log("#{pod_name} build type set to: #{build_type}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
requirements.pop if options.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
# Call old method
|
40
|
+
swizzled_parse_subspecs.bind(self).(name, requirements)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module Pod
|
48
|
+
class Target
|
49
|
+
# @return [BuildTarget]
|
50
|
+
attr_accessor :user_defined_build_type
|
51
|
+
end
|
52
|
+
|
53
|
+
class Installer
|
54
|
+
|
55
|
+
# Walk through pod dependencies and assign build_type from root through all transitive dependencies
|
56
|
+
def resolve_all_pod_build_types(pod_targets)
|
57
|
+
root_pod_building_options = Pod::Podfile::TargetDefinition.root_pod_building_options.clone
|
58
|
+
|
59
|
+
pod_targets.each do |target|
|
60
|
+
next if not root_pod_building_options.key?(target.name)
|
61
|
+
|
62
|
+
build_type = root_pod_building_options[target.name]
|
63
|
+
dependencies = target.dependent_targets
|
64
|
+
|
65
|
+
# Cascade build_type down
|
66
|
+
while not dependencies.empty?
|
67
|
+
new_dependencies = []
|
68
|
+
dependencies.each do |dep_target|
|
69
|
+
dep_target.user_defined_build_type = build_type
|
70
|
+
new_dependencies.push(*dep_target.dependent_targets)
|
71
|
+
end
|
72
|
+
dependencies = new_dependencies
|
73
|
+
end
|
74
|
+
|
75
|
+
target.user_defined_build_type = build_type
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# ======================
|
80
|
+
# ==== PATCH METHOD ====
|
81
|
+
# ======================
|
82
|
+
|
83
|
+
# Store old method reference
|
84
|
+
swizzled_analyze = instance_method(:analyze)
|
85
|
+
|
86
|
+
# Swizzle 'analyze' cocoapods core function to finalize build settings
|
87
|
+
define_method(:analyze) do |analyzer = create_analyzer|
|
88
|
+
CocoapodsUserDefinedBuildTypes.verbose_log("patching build types...")
|
89
|
+
|
90
|
+
# Run original method
|
91
|
+
swizzled_analyze.bind(self).(analyzer)
|
92
|
+
|
93
|
+
# Set user assigned build types on Target objects
|
94
|
+
resolve_all_pod_build_types(pod_targets)
|
95
|
+
|
96
|
+
|
97
|
+
# Update each of @pod_targets private @build_type variable.
|
98
|
+
# Note: @aggregate_targets holds a reference to @pod_targets under it's pod_targets variable.
|
99
|
+
pod_targets.each do |target|
|
100
|
+
next if not target.user_defined_build_type.present?
|
101
|
+
|
102
|
+
new_build_type = target.user_defined_build_type
|
103
|
+
current_build_type = target.send :build_type
|
104
|
+
|
105
|
+
CocoapodsUserDefinedBuildTypes.verbose_log("#{target.name}: #{current_build_type} ==> #{new_build_type}")
|
106
|
+
|
107
|
+
# Override the target's build time for user provided one
|
108
|
+
target.instance_variable_set(:@build_type, new_build_type)
|
109
|
+
|
110
|
+
# Verify patching status
|
111
|
+
if (target.send :build_type).to_s != new_build_type.to_s
|
112
|
+
raise Pod::Informative, "WARNING: Method injection failed on `build_type` of target #{target.name}. Most likely you have a version of cocoapods which is greater than the latest supported by this plugin (#{CocoapodsUserDefinedBuildTypes::LATEST_SUPPORTED_COCOAPODS_VERSION})"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
CocoapodsUserDefinedBuildTypes.verbose_log("finished patching user defined build types")
|
117
|
+
Pod::UI.puts "cocoapods-use-dynamic-frameworks updated build options"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-user-defined-build-types/main'
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-user-defined-build-types
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Cardasis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.5.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: A Cocoapods plugin which selectively enables use_frameworks! per pod.
|
62
|
+
email:
|
63
|
+
- joncardasis@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- lib/cocoapods-user-defined-build-types.rb
|
69
|
+
- lib/cocoapods-user-defined-build-types/gem_version.rb
|
70
|
+
- lib/cocoapods-user-defined-build-types/main.rb
|
71
|
+
- lib/cocoapods-user-defined-build-types/podfile_options.rb
|
72
|
+
- lib/cocoapods-user-defined-build-types/private_api_hooks.rb
|
73
|
+
- lib/cocoapods_plugin.rb
|
74
|
+
homepage: https://github.com/joncardasis/cocoapods-user-defined-build-types
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.0.6
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Cocoapods plugin which selectively enables use_frameworks! per pod. All Cocoapods
|
97
|
+
are bundled into a single dynamic framework, and by default all pods are statically
|
98
|
+
compiled as libraries. Specify specific pods to be compiled as dynamic frameworks.
|
99
|
+
test_files: []
|