cocoapods-xcframework 0.1.0 → 0.1.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 +4 -4
- data/.gitignore +1 -0
- data/cocoapods-framework.gemspec +2 -2
- data/lib/cocoapods-framework/command.rb +1 -0
- data/lib/cocoapods-framework/command/framework.rb +4 -1
- data/lib/cocoapods-framework/command/muti_framework.rb +61 -0
- data/lib/cocoapods-framework/config.rb +2 -0
- data/lib/cocoapods-framework/gem_version.rb +1 -1
- data/lib/cocoapods-framework/muti_frameworker.rb +57 -0
- data/lib/cocoapods-framework/util.rb +2 -0
- data/lib/cocoapods-framework/util/cmd.rb +24 -0
- data/lib/cocoapods-framework/util/dir_util.rb +25 -0
- data/lib/cocoapods-framework/util/git_util.rb +14 -0
- data/lib/cocoapods-framework/util/pod_util.rb +100 -4
- data/lib/cocoapods-framework/xbuilder.rb +116 -8
- data/lib/cocoapods_plugin.rb +1 -0
- data/pkg/cocoapods-xcframework-0.1.0.gem +0 -0
- metadata +13 -5
- data/Gemfile +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46213903938512037adf189a5077b72a22de58a58772079b6ed51e3d69819848
|
4
|
+
data.tar.gz: 4ca7fdc2a9eb9614a82ba357b97d109ee5c1039373432f3b6e93a2ccaa51a15c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed4aa32df78147ee139baa3041ff87bfd02b751a65062d8732361bca189478b0733f0df62be1ff6ad7dcdc6e1e0b5bce985a4996e2c1edae796aded3c6c8b7b4
|
7
|
+
data.tar.gz: 7b63fd3315add0ca97f5ac408bbd6a6fc2ef7bcc002f361abce8f042302c4321ecde12d8cb05db97211b854e94cb5de1a49fb8d86158f6e189fd2077c986fe91
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Example/*
|
data/cocoapods-framework.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = CocoapodsFramework::VERSION
|
9
9
|
spec.authors = ['戴易超']
|
10
10
|
spec.email = ['daiyichao@corp.netease.com']
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{把podspec打包成xcframework的小工具。packager pod to a xcframework}
|
12
|
+
spec.summary = %q{把podspec打包成xcframework的小工具。packager pod to a xcframework}
|
13
13
|
spec.homepage = 'https://github.com/TyrantDante/cocoapods-framework'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -31,7 +31,8 @@ module Pod
|
|
31
31
|
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
32
32
|
['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent pods from (defaults to https://github.com/CocoaPods/Specs.git)'],
|
33
33
|
['--subspecs', 'Only include the given subspecs'],
|
34
|
-
['--use-modular-headers', 'pakcage uses modular headers during packaging']
|
34
|
+
['--use-modular-headers', 'pakcage uses modular headers during packaging'],
|
35
|
+
['--no-static-library', 'package not use static library']
|
35
36
|
].concat super
|
36
37
|
end
|
37
38
|
|
@@ -44,6 +45,8 @@ module Pod
|
|
44
45
|
@configuration = argv.option('configuration', 'Release')
|
45
46
|
@use_modular_headers = argv.option('use-modular-headers', true)
|
46
47
|
@force = argv.flag?('force', true)
|
48
|
+
@use_static_library = argv.flag?('static-library',true)
|
49
|
+
config.static_library_enable = @use_static_library
|
47
50
|
super
|
48
51
|
end
|
49
52
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
4
|
+
# to the 'pod' command.
|
5
|
+
#
|
6
|
+
# You can also create subcommands of existing or new commands. Say you
|
7
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
8
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
9
|
+
# to change.
|
10
|
+
#
|
11
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
12
|
+
# the class to exist in the the Pod::Command::List namespace
|
13
|
+
# - change this class to extend from `List` instead of `Command`. This
|
14
|
+
# tells the plugin system that it is a subcommand of `list`.
|
15
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
16
|
+
#
|
17
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
18
|
+
# in the `plugins.json` file, once your plugin is released.
|
19
|
+
#
|
20
|
+
class MutiFramework < Command
|
21
|
+
self.summary = 'Package some podspec into a xcframework.'
|
22
|
+
self.arguments = [
|
23
|
+
CLAide::Argument.new('NAME', true),
|
24
|
+
CLAide::Argument.new('SOURCE', false)
|
25
|
+
]
|
26
|
+
include Config::Mixin
|
27
|
+
|
28
|
+
def self.options
|
29
|
+
[
|
30
|
+
['--no-force', 'Overwrite existing files.'],
|
31
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
32
|
+
['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent pods from (defaults to https://github.com/CocoaPods/Specs.git)'],
|
33
|
+
['--use-modular-headers', 'pakcage uses modular headers during packaging'],
|
34
|
+
['--no-static-library', 'package not use static library']
|
35
|
+
].concat super
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize(argv)
|
39
|
+
@name = argv.shift_argument
|
40
|
+
@source = argv.shift_argument
|
41
|
+
@spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')
|
42
|
+
@configuration = argv.option('configuration', 'Release')
|
43
|
+
@use_modular_headers = argv.option('use-modular-headers', true)
|
44
|
+
@force = argv.flag?('force', true)
|
45
|
+
@use_static_library = argv.flag?('static-library', true)
|
46
|
+
config.static_library_enable = @use_static_library
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate!
|
51
|
+
super
|
52
|
+
help! 'A file written some pods need package is needed' unless @name
|
53
|
+
end
|
54
|
+
|
55
|
+
def run
|
56
|
+
frameworker = MutiFrameworker.new(@name, @source, @spec_sources, @configuration, @force, @use_modular_headers)
|
57
|
+
frameworker.run
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Pod
|
2
|
+
class MutiFrameworker
|
3
|
+
include Pod::PodUtil
|
4
|
+
include Pod::GitUtil
|
5
|
+
include Pod::DirUtil
|
6
|
+
include Config::Mixin
|
7
|
+
def initialize(name, source, spec_sources, configuration, force, use_modular_headers)
|
8
|
+
@name = name
|
9
|
+
@source = source
|
10
|
+
@spec_sources = spec_sources
|
11
|
+
@configuration = configuration
|
12
|
+
@force = force
|
13
|
+
@use_modular_headers = use_modular_headers
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
configs = muti_config_with_file @name
|
18
|
+
target_dir, work_dir = create_working_directory_by_spec "xcframeworks", @force
|
19
|
+
prepare_git_with_configs configs, work_dir
|
20
|
+
build_frameworks configs, work_dir, target_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_frameworks configs, work_dir, target_dir
|
24
|
+
config.installation_root = Pathname.new work_dir
|
25
|
+
config.sandbox_root = "#{work_dir}/Pods"
|
26
|
+
sandbox = build_static_sandbox
|
27
|
+
|
28
|
+
sandbox_installer = installation_root_muti(
|
29
|
+
sandbox,
|
30
|
+
configs,
|
31
|
+
@spec_sources,
|
32
|
+
@use_modular_headers
|
33
|
+
)
|
34
|
+
perform_build(
|
35
|
+
sandbox,
|
36
|
+
sandbox_installer,
|
37
|
+
configs,
|
38
|
+
target_dir
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def perform_build sandbox, installer, configs, target_dir
|
43
|
+
sandbox_root = config.sandbox_root.to_s
|
44
|
+
builder = Pod::XBuilder.new(
|
45
|
+
installer,
|
46
|
+
Dir.pwd,
|
47
|
+
sandbox_root,
|
48
|
+
configs,
|
49
|
+
@configuration
|
50
|
+
)
|
51
|
+
builder.build
|
52
|
+
builder.outputs_muti target_dir
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pod
|
2
|
+
class Cmmd
|
3
|
+
class << self
|
4
|
+
def sh! command
|
5
|
+
UI.puts command
|
6
|
+
output = `#{command}`.lines.to_a
|
7
|
+
if $?.exitstatus != 0
|
8
|
+
Pod::ErrorUtil.error_report command,output
|
9
|
+
Process.exit -1
|
10
|
+
end
|
11
|
+
output
|
12
|
+
end
|
13
|
+
|
14
|
+
def sh? command
|
15
|
+
UI.puts command
|
16
|
+
output = `#{command}`.lines.to_a
|
17
|
+
if $?.exitstatus != 0
|
18
|
+
Pod::ErrorUtil.error_report command,output
|
19
|
+
end
|
20
|
+
output
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -14,6 +14,9 @@ module Pod
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_working_directory_by_spec spec,force
|
17
|
+
if spec.is_a? String
|
18
|
+
return create_working_directory_by_name spec,force
|
19
|
+
end
|
17
20
|
target_dir = create_target_directory_path_by_spec spec,force
|
18
21
|
# Pathname.new(target_dir).mkdir
|
19
22
|
work_dir = Dir.tmpdir + '/frameworks-' + Array.new(8) { rand(36).to_s(36) }.join
|
@@ -21,5 +24,27 @@ module Pod
|
|
21
24
|
Pathname.new(work_dir).mkdir
|
22
25
|
[target_dir, work_dir]
|
23
26
|
end
|
27
|
+
|
28
|
+
def create_target_directory_path_by_name name, force
|
29
|
+
target_dir = "#{Dir.pwd}/#{name}-muti"
|
30
|
+
|
31
|
+
if File.exist? target_dir
|
32
|
+
if @force
|
33
|
+
Pathname.new(target_dir).rmtree
|
34
|
+
else
|
35
|
+
UI.warn "Target directory '#{target_dir}' already exists."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
target_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_working_directory_by_name name, force
|
42
|
+
target_dir = create_target_directory_path_by_name name,force
|
43
|
+
# Pathname.new(target_dir).mkdir
|
44
|
+
work_dir = Dir.tmpdir + '/frameworks-' + Array.new(8) { rand(36).to_s(36) }.join
|
45
|
+
|
46
|
+
Pathname.new(work_dir).mkdir
|
47
|
+
[target_dir, work_dir]
|
48
|
+
end
|
24
49
|
end
|
25
50
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Pod
|
2
|
+
module GitUtil
|
3
|
+
def prepare_git_with_configs configs, work_dir
|
4
|
+
index = 0
|
5
|
+
configs.each do |config|
|
6
|
+
name = config["name"]
|
7
|
+
git_url = config["git_url"]
|
8
|
+
git_branch = config["git_branch"]
|
9
|
+
command = "git clone #{git_url} -b #{git_branch} #{work_dir}/#{name}"
|
10
|
+
Cmmd.sh! command
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,5 +1,20 @@
|
|
1
1
|
module Pod
|
2
2
|
module PodUtil
|
3
|
+
include Config::Mixin
|
4
|
+
def muti_config_with_file(path)
|
5
|
+
return nil if path.nil?
|
6
|
+
path = Pathname.new(path)
|
7
|
+
path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
|
8
|
+
@path = path.expand_path
|
9
|
+
content = File.open(path, 'rb').read
|
10
|
+
result = JSON.parse content
|
11
|
+
if not result.is_a? Array
|
12
|
+
UI.error "#{path} format not support"
|
13
|
+
exit -1
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
|
3
18
|
def spec_with_path(path)
|
4
19
|
return if path.nil?
|
5
20
|
path = Pathname.new(path)
|
@@ -44,6 +59,7 @@ module Pod
|
|
44
59
|
)
|
45
60
|
|
46
61
|
installer = Installer.new(sandbox, podfile)
|
62
|
+
installer.repo_update = true
|
47
63
|
installer.install!
|
48
64
|
|
49
65
|
unless installer.nil?
|
@@ -59,11 +75,45 @@ module Pod
|
|
59
75
|
installer
|
60
76
|
end
|
61
77
|
|
78
|
+
def installation_root_muti sandbox, configs, sources, use_frameworks = true, use_modular_headers = true
|
79
|
+
podfile = podfile_from_muti_configs(
|
80
|
+
configs,
|
81
|
+
sources,
|
82
|
+
use_frameworks,
|
83
|
+
use_modular_headers
|
84
|
+
)
|
85
|
+
installer = Installer.new(sandbox, podfile)
|
86
|
+
installer.repo_update = true
|
87
|
+
installer.install!
|
88
|
+
|
89
|
+
specs = configs.map do |cfg|
|
90
|
+
cfg["name"]
|
91
|
+
end
|
92
|
+
unless installer.nil?
|
93
|
+
installer.pods_project.targets.each do |target|
|
94
|
+
if specs.include? target.name
|
95
|
+
target.build_configurations.each do |configuration|
|
96
|
+
configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
installer.pods_project.save
|
101
|
+
end
|
102
|
+
installer
|
103
|
+
end
|
104
|
+
|
62
105
|
def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true
|
63
|
-
|
106
|
+
options = Hash.new
|
64
107
|
options[:podspec] = path.to_s
|
108
|
+
options[:subspecs] = spec.subspecs.map do |sub|
|
109
|
+
sub.base_name
|
110
|
+
end
|
65
111
|
options[:subspecs] = subspecs if subspecs
|
66
|
-
|
112
|
+
# 非常奇怪,如果传一个空的数组过去就会出问题!!
|
113
|
+
if options[:subspecs].length == 0
|
114
|
+
options[:subspecs] = nil
|
115
|
+
end
|
116
|
+
static_library_enable = config.static_library_enable?
|
67
117
|
Pod::Podfile.new do
|
68
118
|
sources.each {|s| source s}
|
69
119
|
spec.available_platforms.each do |plt|
|
@@ -73,13 +123,59 @@ module Pod
|
|
73
123
|
end
|
74
124
|
end
|
75
125
|
|
126
|
+
install!('cocoapods',:integrate_targets => false,:deterministic_uuids => false)
|
127
|
+
if static_library_enable
|
128
|
+
use_frameworks! :linkage => :static if use_frameworks
|
129
|
+
else
|
130
|
+
use_frameworks! if use_frameworks
|
131
|
+
end
|
132
|
+
use_modular_headers! if use_modular_headers
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def podfile_from_muti_configs configs, sources, use_frameworks = true, use_modular_headers = true
|
137
|
+
installation_root = config.installation_root.to_s
|
138
|
+
static_library_enable = config.static_library_enable?
|
139
|
+
Pod::Podfile.new do
|
140
|
+
sources.each {|s| source s}
|
141
|
+
configs.each do |cfg|
|
142
|
+
pod_spec_path = installation_root + "/#{cfg["name"]}/#{cfg["name"]}.podspec"
|
143
|
+
pod_spec_json_path = pod_spec_path + ".json"
|
144
|
+
(Pathname.glob(pod_spec_path) + Pathname.glob(pod_spec_json_path)).each do |real_path|
|
145
|
+
spec = Pod::Specification.from_file real_path.to_s
|
146
|
+
options = Hash.new
|
147
|
+
options[:podspec] = real_path.to_s
|
148
|
+
if cfg["subspecs"]
|
149
|
+
options[:subspecs] = cfg["subspecs"]
|
150
|
+
else
|
151
|
+
options[:subspecs] = spec.subspecs.map do |sub|
|
152
|
+
sub.base_name
|
153
|
+
end
|
154
|
+
end
|
155
|
+
# 非常奇怪,如果传一个空的数组过去就会出问题!!
|
156
|
+
if options[:subspecs].length == 0
|
157
|
+
options[:subspecs] = nil
|
158
|
+
end
|
159
|
+
spec.available_platforms.each do |plt|
|
160
|
+
target "#{spec.name}-#{plt.name}" do
|
161
|
+
puts "#{plt.name} #{spec.name} #{options}"
|
162
|
+
platform(plt.name, spec.deployment_target(plt.name))
|
163
|
+
pod(spec.name, options)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
76
168
|
install!('cocoapods',
|
77
169
|
:integrate_targets => false,
|
78
170
|
:deterministic_uuids => false)
|
79
171
|
|
80
|
-
|
172
|
+
if static_library_enable
|
173
|
+
use_frameworks! :linkage => :static if use_frameworks
|
174
|
+
else
|
175
|
+
use_frameworks! if use_frameworks
|
176
|
+
end
|
81
177
|
use_modular_headers! if use_modular_headers
|
82
|
-
|
178
|
+
end
|
83
179
|
end
|
84
180
|
|
85
181
|
def generic_new_podspec_hash spec
|
@@ -13,15 +13,19 @@ module Pod
|
|
13
13
|
@source_dir = source_dir
|
14
14
|
@sandbox_root = sandbox_root
|
15
15
|
@spec = spec
|
16
|
+
@muti = @spec.is_a? Array
|
17
|
+
@configs = @spec if @muti
|
18
|
+
@spec = "muti" if @muti
|
19
|
+
|
16
20
|
@configuration = configuration
|
17
|
-
@outputs =
|
21
|
+
@outputs = Hash.new
|
18
22
|
end
|
19
23
|
|
20
24
|
def build
|
21
25
|
UI.puts("Building framework #{@spec} with configuration #{@configuration}")
|
22
26
|
UI.puts "Work dir is :#{@sandbox_root}"
|
23
|
-
defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
|
24
|
-
|
27
|
+
# defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
|
28
|
+
defines = ""
|
25
29
|
if @configuration == 'Debug'
|
26
30
|
defines << 'GCC_GENERATE_DEBUGGING_SYMBOLS=YES ONLY_ACTIVE_ARCH=NO'
|
27
31
|
else
|
@@ -36,13 +40,62 @@ module Pod
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def collect_xc_frameworks
|
43
|
+
if @muti
|
44
|
+
collect_muti_xcframworks
|
45
|
+
else
|
46
|
+
collect_single_xcframeworks
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def collect_muti_xcframworks
|
51
|
+
@outputs[:xcframework] = Hash.new
|
52
|
+
@configs.each do |cfg|
|
53
|
+
export_dir = "#{@sandbox_root}/export/**/#{cfg["name"]}.framework"
|
54
|
+
frameworks = Pathname.glob(export_dir)
|
55
|
+
@outputs[:xcframework][cfg["name"]] = create_xc_framework_by_frameworks frameworks, cfg["name"]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def collect_single_xcframeworks
|
39
60
|
export_dir = "#{@sandbox_root}/export/**/#{@spec.name}.framework"
|
40
61
|
frameworks = Pathname.glob(export_dir)
|
41
|
-
@outputs[:xcframework] = create_xc_framework_by_frameworks frameworks
|
62
|
+
@outputs[:xcframework] = create_xc_framework_by_frameworks frameworks, @spec.name
|
42
63
|
end
|
43
64
|
|
44
65
|
def collect_bundles
|
45
|
-
|
66
|
+
if @muti
|
67
|
+
colelct_muti_bundles
|
68
|
+
else
|
69
|
+
collect_single_bundles
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def colelct_muti_bundles
|
74
|
+
@outputs[:bundle] = Hash.new
|
75
|
+
@configs.each do |cfg|
|
76
|
+
# "" 这个是用来代表mac os的 macos 没有后缀奇怪吧
|
77
|
+
["iphoneos","","appletvos","watchos"].each do |plat|
|
78
|
+
export_dir = "#{@sandbox_root}/export/*-#{plat}/**/#{cfg["name"]}.bundle/**"
|
79
|
+
Pathname.glob(export_dir).each do |bundle|
|
80
|
+
if bundle.to_s.include? "#{@spec.name}.bundle/Info.plist"
|
81
|
+
return
|
82
|
+
end
|
83
|
+
target_path = "#{@sandbox_root}/bundle/#{cfg["name"]}"
|
84
|
+
@outputs[:bundle][cfg["name"]] = target_path
|
85
|
+
native_platform = to_native_platform plat
|
86
|
+
path = Pathname.new "#{target_path}/#{native_platform}"
|
87
|
+
if not path.exist?
|
88
|
+
path.mkpath
|
89
|
+
end
|
90
|
+
FileUtils.cp_r(Dir["#{bundle}"],"#{path}")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def collect_single_bundles
|
97
|
+
# "" 这个是用来代表mac os的 macos 没有后缀奇怪吧
|
98
|
+
["iphoneos","","appletvos","watchos"].each do |plat|
|
46
99
|
export_dir = "#{@sandbox_root}/export/*-#{plat}/**/#{@spec.name}.bundle/**"
|
47
100
|
Pathname.glob(export_dir).each do |bundle|
|
48
101
|
if bundle.to_s.include? "#{@spec.name}.bundle/Info.plist"
|
@@ -59,18 +112,18 @@ module Pod
|
|
59
112
|
end
|
60
113
|
end
|
61
114
|
|
62
|
-
def create_xc_framework_by_frameworks frameworks
|
115
|
+
def create_xc_framework_by_frameworks frameworks, spec_name
|
63
116
|
command = 'xcodebuild -create-xcframework '
|
64
117
|
frameworks.each do |framework|
|
65
118
|
command << "-framework #{framework} "
|
66
119
|
end
|
67
|
-
command << "-output #{@sandbox_root}/#{
|
120
|
+
command << "-output #{@sandbox_root}/#{spec_name}.xcframework 2>&1"
|
68
121
|
output = `#{command}`.lines.to_a
|
69
122
|
if $?.exitstatus != 0
|
70
123
|
Pod::ErrorUtil.error_report command,output
|
71
124
|
Process.exit -1
|
72
125
|
end
|
73
|
-
"#{@sandbox_root}/#{
|
126
|
+
"#{@sandbox_root}/#{spec_name}.xcframework"
|
74
127
|
end
|
75
128
|
|
76
129
|
def build_all_device defines
|
@@ -152,5 +205,60 @@ module Pod
|
|
152
205
|
FileUtils.cp_r(Dir[@outputs[:bundle]],target_dir)
|
153
206
|
end
|
154
207
|
end
|
208
|
+
|
209
|
+
def outputs_muti target_dir
|
210
|
+
if not File.exist? target_dir
|
211
|
+
Pathname.new(target_dir).mkdir
|
212
|
+
end
|
213
|
+
outputs_xcframework_muti target_dir
|
214
|
+
outputs_bundle_muti target_dir
|
215
|
+
generic_new_podspec_hash_muti target_dir
|
216
|
+
end
|
217
|
+
|
218
|
+
def generic_new_podspec_hash_muti target_dir
|
219
|
+
work_dir = config.installation_root
|
220
|
+
@configs.map do |cfg|
|
221
|
+
podspec_path = "#{work_dir}/#{cfg["name"]}/#{cfg["name"]}.podspec"
|
222
|
+
if not File.exist? podspec_path
|
223
|
+
podspec_path = "#{podspec_path}.json"
|
224
|
+
end
|
225
|
+
podspec = Pod::Specification.from_file podspec_path
|
226
|
+
new_spec_hash = generic_new_podspec_hash podspec
|
227
|
+
new_spec_hash[:vendored_frameworks] = "#{podspec.name}.xcframework"
|
228
|
+
find_bundles("#{target_dir}/#{podspec.name}").each do |plat, value|
|
229
|
+
if new_spec_hash[plat]
|
230
|
+
new_spec_hash[plat]["resource_bundles"] = value
|
231
|
+
else
|
232
|
+
new_spec_hash[plat] = {
|
233
|
+
"resource_bundles" => value
|
234
|
+
}
|
235
|
+
end
|
236
|
+
end
|
237
|
+
require 'json'
|
238
|
+
spec_json = JSON.pretty_generate(new_spec_hash) << "\n"
|
239
|
+
File.open("#{target_dir}/#{podspec.name}/#{podspec.name}.podspec.json",'wb+') do |f|
|
240
|
+
f.write(spec_json)
|
241
|
+
end
|
242
|
+
UI.puts "result export at :#{target_dir}/#{podspec.name}"
|
243
|
+
"#{target_dir}/#{podspec.name}"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def outputs_xcframework_muti target_dir
|
248
|
+
@outputs[:xcframework].each do |name, path|
|
249
|
+
target_dir_path = "#{target_dir}/#{name}/"
|
250
|
+
Pathname.new(target_dir_path).mkpath
|
251
|
+
FileUtils.cp_r(path, target_dir_path)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def outputs_bundle_muti target_dir
|
256
|
+
@outputs[:bundle].each do |name, path|
|
257
|
+
target_dir_path = "#{target_dir}/#{name}/bundle/"
|
258
|
+
Pathname.new(target_dir_path).mkpath
|
259
|
+
FileUtils.cp_r(path, target_dir_path)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
155
263
|
end
|
156
264
|
end
|
data/lib/cocoapods_plugin.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-xcframework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 戴易超
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -58,14 +58,17 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
description:
|
61
|
+
description: 把podspec打包成xcframework的小工具。packager pod to a xcframework
|
62
62
|
email:
|
63
63
|
- daiyichao@corp.netease.com
|
64
64
|
executables: []
|
65
65
|
extensions: []
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
|
-
-
|
68
|
+
- ".gitignore"
|
69
|
+
- Example/Gemfile
|
70
|
+
- Example/Gemfile.lock
|
71
|
+
- Example/podfile.package
|
69
72
|
- LICENSE.txt
|
70
73
|
- README.md
|
71
74
|
- Rakefile
|
@@ -73,12 +76,16 @@ files:
|
|
73
76
|
- lib/cocoapods-framework.rb
|
74
77
|
- lib/cocoapods-framework/command.rb
|
75
78
|
- lib/cocoapods-framework/command/framework.rb
|
79
|
+
- lib/cocoapods-framework/command/muti_framework.rb
|
76
80
|
- lib/cocoapods-framework/config.rb
|
77
81
|
- lib/cocoapods-framework/frameworker.rb
|
78
82
|
- lib/cocoapods-framework/gem_version.rb
|
83
|
+
- lib/cocoapods-framework/muti_frameworker.rb
|
79
84
|
- lib/cocoapods-framework/util.rb
|
85
|
+
- lib/cocoapods-framework/util/cmd.rb
|
80
86
|
- lib/cocoapods-framework/util/dir_util.rb
|
81
87
|
- lib/cocoapods-framework/util/error_util.rb
|
88
|
+
- lib/cocoapods-framework/util/git_util.rb
|
82
89
|
- lib/cocoapods-framework/util/pod_util.rb
|
83
90
|
- lib/cocoapods-framework/xbuilder.rb
|
84
91
|
- lib/cocoapods-framework/xbuilder/xcode_xbuild.rb
|
@@ -92,6 +99,7 @@ files:
|
|
92
99
|
- pkg/cocoapods-xcframework-0.0.6.gem
|
93
100
|
- pkg/cocoapods-xcframework-0.0.7.gem
|
94
101
|
- pkg/cocoapods-xcframework-0.0.8.gem
|
102
|
+
- pkg/cocoapods-xcframework-0.1.0.gem
|
95
103
|
- spec/command/framework_spec.rb
|
96
104
|
- spec/spec_helper.rb
|
97
105
|
homepage: https://github.com/TyrantDante/cocoapods-framework
|
@@ -116,7 +124,7 @@ requirements: []
|
|
116
124
|
rubygems_version: 3.0.3
|
117
125
|
signing_key:
|
118
126
|
specification_version: 4
|
119
|
-
summary:
|
127
|
+
summary: 把podspec打包成xcframework的小工具。packager pod to a xcframework
|
120
128
|
test_files:
|
121
129
|
- spec/command/framework_spec.rb
|
122
130
|
- spec/spec_helper.rb
|
data/Gemfile
DELETED