cocoapods-xcframework 0.0.7 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +7 -2
- data/lib/cocoapods-framework/command/muti_framework.rb +61 -0
- data/lib/cocoapods-framework/config.rb +2 -0
- data/lib/cocoapods-framework/frameworker.rb +5 -2
- 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 +155 -7
- data/lib/cocoapods-framework/xbuilder.rb +136 -14
- data/lib/cocoapods-framework/xbuilder/xcodeproj_helper.rb +1 -11
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +12 -10
- data/Gemfile +0 -13
- data/pkg/cocoapods-framework-0.0.1.gem +0 -0
- data/pkg/cocoapods-framework-0.0.2.gem +0 -0
- data/pkg/cocoapods-framework-0.0.3.gem +0 -0
- data/pkg/cocoapods-xcframework-0.0.4.gem +0 -0
- data/pkg/cocoapods-xcframework-0.0.6.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff3c1aebde9549b0113050ae273c3a3734d58861aff9cf3a7f7a599a1971e008
|
4
|
+
data.tar.gz: 439607a9462c3c4ba1c4b98401b37c18e23348ef31f0aae9fcc67344f6081bb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d3718b1cf29d43aae97250f8eecf97bd8731127dbd22c63a896332021c7fedce56ecca046db192d756644e0fc9e602bf3e3b3ed6590deb2afd46629a5b222a1
|
7
|
+
data.tar.gz: d54fb38728e40737e76fd1ce73b6ae7c4b1497a53e7246926525a090a2dce426d75266235e4e4db0de3dfe848d3b037812119858ced9556185fc3edd77c276e6
|
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,9 @@ 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'],
|
36
|
+
['--enable-bitcode', 'package enable bitcode']
|
35
37
|
].concat super
|
36
38
|
end
|
37
39
|
|
@@ -44,6 +46,9 @@ module Pod
|
|
44
46
|
@configuration = argv.option('configuration', 'Release')
|
45
47
|
@use_modular_headers = argv.option('use-modular-headers', true)
|
46
48
|
@force = argv.flag?('force', true)
|
49
|
+
@use_static_library = argv.flag?('static-library',true)
|
50
|
+
@enable_bitcode = argv.flag?('enable-bitcode',false)
|
51
|
+
config.static_library_enable = @use_static_library
|
47
52
|
super
|
48
53
|
end
|
49
54
|
|
@@ -53,7 +58,7 @@ module Pod
|
|
53
58
|
end
|
54
59
|
|
55
60
|
def run
|
56
|
-
frameworker = Frameworker.new(@name, @source, @spec_sources, @subspecs, @configuration, @force, @use_modular_headers)
|
61
|
+
frameworker = Frameworker.new(@name, @source, @spec_sources, @subspecs, @configuration, @force, @use_modular_headers, @enable_bitcode)
|
57
62
|
frameworker.run
|
58
63
|
end
|
59
64
|
end
|
@@ -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
|
@@ -3,7 +3,7 @@ module Pod
|
|
3
3
|
include PodUtil
|
4
4
|
include DirUtil
|
5
5
|
include Config::Mixin
|
6
|
-
def initialize(name, source, spec_sources, subspecs, configuration, force, use_modular_headers)
|
6
|
+
def initialize(name, source, spec_sources, subspecs, configuration, force, use_modular_headers, enable_bitcode)
|
7
7
|
@name = name
|
8
8
|
@source = source
|
9
9
|
@spec_sources = spec_sources
|
@@ -11,6 +11,7 @@ module Pod
|
|
11
11
|
@configuration = configuration
|
12
12
|
@force = force
|
13
13
|
@use_modular_headers = use_modular_headers
|
14
|
+
@enable_bitcode = enable_bitcode
|
14
15
|
end
|
15
16
|
|
16
17
|
def run
|
@@ -36,7 +37,9 @@ module Pod
|
|
36
37
|
spec,
|
37
38
|
@subspecs,
|
38
39
|
@spec_sources,
|
39
|
-
|
40
|
+
true,
|
41
|
+
@use_modular_headers,
|
42
|
+
@enable_bitcode
|
40
43
|
)
|
41
44
|
|
42
45
|
perform_build(
|
@@ -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,35 @@
|
|
1
1
|
module Pod
|
2
2
|
module PodUtil
|
3
|
+
include Config::Mixin
|
4
|
+
|
5
|
+
def to_native_platform name
|
6
|
+
case name
|
7
|
+
when 'iphoneos' then 'ios'
|
8
|
+
when 'macOS' then 'osx'
|
9
|
+
when 'appletvos' then 'tvos'
|
10
|
+
when 'watchos' then 'watchos'
|
11
|
+
when 'ios' then 'ios'
|
12
|
+
when 'macos' then 'osx'
|
13
|
+
when 'tvos' then 'tvos'
|
14
|
+
else
|
15
|
+
name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def muti_config_with_file(path)
|
20
|
+
return nil if path.nil?
|
21
|
+
path = Pathname.new(path)
|
22
|
+
path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
|
23
|
+
@path = path.expand_path
|
24
|
+
content = File.open(path, 'rb').read
|
25
|
+
result = JSON.parse content
|
26
|
+
if not result.is_a? Array
|
27
|
+
UI.error "#{path} format not support"
|
28
|
+
exit -1
|
29
|
+
end
|
30
|
+
result
|
31
|
+
end
|
32
|
+
|
3
33
|
def spec_with_path(path)
|
4
34
|
return if path.nil?
|
5
35
|
path = Pathname.new(path)
|
@@ -33,7 +63,7 @@ module Pod
|
|
33
63
|
Sandbox.new(config.sandbox_root)
|
34
64
|
end
|
35
65
|
|
36
|
-
def installation_root sandbox, spec, subspecs, sources,use_frameworks = true,use_modular_headers = true
|
66
|
+
def installation_root sandbox, spec, subspecs, sources,use_frameworks = true,use_modular_headers = true, enable_bitcode = false
|
37
67
|
podfile = podfile_from_spec(
|
38
68
|
@path,
|
39
69
|
spec,
|
@@ -44,12 +74,54 @@ module Pod
|
|
44
74
|
)
|
45
75
|
|
46
76
|
installer = Installer.new(sandbox, podfile)
|
77
|
+
installer.repo_update = true
|
78
|
+
installer.install!
|
79
|
+
|
80
|
+
unless installer.nil?
|
81
|
+
installer.pods_project.targets.each do |target|
|
82
|
+
target.build_configurations.each do |configuration|
|
83
|
+
if enable_bitcode && configuration.name == "Release"
|
84
|
+
configuration.build_settings['ENABLE_BITCODE'] = 'YES'
|
85
|
+
configuration.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
if target.name == spec.name
|
89
|
+
target.build_configurations.each do |configuration|
|
90
|
+
configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
installer.pods_project.save
|
95
|
+
end
|
96
|
+
installer
|
97
|
+
end
|
98
|
+
|
99
|
+
def installation_root_muti sandbox, configs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false
|
100
|
+
podfile = podfile_from_muti_configs(
|
101
|
+
configs,
|
102
|
+
sources,
|
103
|
+
use_frameworks,
|
104
|
+
use_modular_headers
|
105
|
+
)
|
106
|
+
installer = Installer.new(sandbox, podfile)
|
107
|
+
installer.repo_update = true
|
47
108
|
installer.install!
|
48
109
|
|
110
|
+
specs = configs.map do |cfg|
|
111
|
+
cfg["name"]
|
112
|
+
end
|
49
113
|
unless installer.nil?
|
50
114
|
installer.pods_project.targets.each do |target|
|
51
|
-
target.build_configurations.each do |configuration|
|
52
|
-
configuration.
|
115
|
+
target.build_configurations.each do |configuration|
|
116
|
+
if enable_bitcode && configuration.name == "Release"
|
117
|
+
configuration.build_settings['ENABLE_BITCODE'] = 'YES'
|
118
|
+
configuration.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
if specs.include? target.name
|
122
|
+
target.build_configurations.each do |configuration|
|
123
|
+
configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
|
124
|
+
end
|
53
125
|
end
|
54
126
|
end
|
55
127
|
installer.pods_project.save
|
@@ -58,10 +130,17 @@ module Pod
|
|
58
130
|
end
|
59
131
|
|
60
132
|
def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true
|
61
|
-
|
133
|
+
options = Hash.new
|
62
134
|
options[:podspec] = path.to_s
|
135
|
+
options[:subspecs] = spec.subspecs.map do |sub|
|
136
|
+
sub.base_name
|
137
|
+
end
|
63
138
|
options[:subspecs] = subspecs if subspecs
|
64
|
-
|
139
|
+
# 非常奇怪,如果传一个空的数组过去就会出问题!!
|
140
|
+
if options[:subspecs].length == 0
|
141
|
+
options[:subspecs] = nil
|
142
|
+
end
|
143
|
+
static_library_enable = config.static_library_enable?
|
65
144
|
Pod::Podfile.new do
|
66
145
|
sources.each {|s| source s}
|
67
146
|
spec.available_platforms.each do |plt|
|
@@ -71,13 +150,59 @@ module Pod
|
|
71
150
|
end
|
72
151
|
end
|
73
152
|
|
153
|
+
install!('cocoapods',:integrate_targets => false,:deterministic_uuids => false)
|
154
|
+
if static_library_enable
|
155
|
+
use_frameworks! :linkage => :static if use_frameworks
|
156
|
+
else
|
157
|
+
use_frameworks! if use_frameworks
|
158
|
+
end
|
159
|
+
use_modular_headers! if use_modular_headers
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def podfile_from_muti_configs configs, sources, use_frameworks = true, use_modular_headers = true
|
164
|
+
installation_root = config.installation_root.to_s
|
165
|
+
static_library_enable = config.static_library_enable?
|
166
|
+
Pod::Podfile.new do
|
167
|
+
sources.each {|s| source s}
|
168
|
+
configs.each do |cfg|
|
169
|
+
pod_spec_path = installation_root + "/#{cfg["name"]}/#{cfg["name"]}.podspec"
|
170
|
+
pod_spec_json_path = pod_spec_path + ".json"
|
171
|
+
(Pathname.glob(pod_spec_path) + Pathname.glob(pod_spec_json_path)).each do |real_path|
|
172
|
+
spec = Pod::Specification.from_file real_path.to_s
|
173
|
+
options = Hash.new
|
174
|
+
options[:podspec] = real_path.to_s
|
175
|
+
if cfg["subspecs"]
|
176
|
+
options[:subspecs] = cfg["subspecs"]
|
177
|
+
else
|
178
|
+
options[:subspecs] = spec.subspecs.map do |sub|
|
179
|
+
sub.base_name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
# 非常奇怪,如果传一个空的数组过去就会出问题!!
|
183
|
+
if options[:subspecs].length == 0
|
184
|
+
options[:subspecs] = nil
|
185
|
+
end
|
186
|
+
spec.available_platforms.each do |plt|
|
187
|
+
target "#{spec.name}-#{plt.name}" do
|
188
|
+
puts "#{plt.name} #{spec.name} #{options}"
|
189
|
+
platform(plt.name, spec.deployment_target(plt.name))
|
190
|
+
pod(spec.name, options)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
74
195
|
install!('cocoapods',
|
75
196
|
:integrate_targets => false,
|
76
197
|
:deterministic_uuids => false)
|
77
198
|
|
78
|
-
|
199
|
+
if static_library_enable
|
200
|
+
use_frameworks! :linkage => :static if use_frameworks
|
201
|
+
else
|
202
|
+
use_frameworks! if use_frameworks
|
203
|
+
end
|
79
204
|
use_modular_headers! if use_modular_headers
|
80
|
-
|
205
|
+
end
|
81
206
|
end
|
82
207
|
|
83
208
|
def generic_new_podspec_hash spec
|
@@ -104,5 +229,28 @@ module Pod
|
|
104
229
|
end
|
105
230
|
spec_hash
|
106
231
|
end
|
232
|
+
|
233
|
+
def fix_header_file spec_hash, xcframework_path
|
234
|
+
puts "Dir.glob(#{xcframework_path}/*/) : #{Dir.glob("#{xcframework_path}/*/")}"
|
235
|
+
Dir.glob("#{xcframework_path}/*/").each do |file|
|
236
|
+
['ios','macos','tvos', 'watchos'].each do |prefix|
|
237
|
+
last_path = file.split("/").last
|
238
|
+
if last_path =~ /#{prefix}/ and not last_path =~ /simulator/
|
239
|
+
platform = to_native_platform prefix
|
240
|
+
if spec_hash[platform]
|
241
|
+
spec_hash[platform]["public_header_files"] = "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h"
|
242
|
+
spec_hash[platform]["source_files"] = "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h"
|
243
|
+
else
|
244
|
+
spec_hash[platform] = {
|
245
|
+
"public_header_files" => "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h",
|
246
|
+
"source_files" => "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h"
|
247
|
+
}
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
puts spec_hash.to_json
|
253
|
+
spec_hash
|
254
|
+
end
|
107
255
|
end
|
108
256
|
end
|
@@ -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,15 +40,67 @@ 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
|
-
|
46
|
-
|
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|
|
99
|
+
export_dir = "#{@sandbox_root}/export/*-#{plat}/**/#{@spec.name}.bundle/**"
|
47
100
|
Pathname.glob(export_dir).each do |bundle|
|
101
|
+
if bundle.to_s.include? "#{@spec.name}.bundle/Info.plist"
|
102
|
+
return
|
103
|
+
end
|
48
104
|
@outputs[:bundle] = "#{@sandbox_root}/bundle"
|
49
105
|
native_platform = to_native_platform plat
|
50
106
|
path = Pathname.new "#{@sandbox_root}/bundle/#{native_platform}"
|
@@ -56,18 +112,18 @@ module Pod
|
|
56
112
|
end
|
57
113
|
end
|
58
114
|
|
59
|
-
def create_xc_framework_by_frameworks frameworks
|
115
|
+
def create_xc_framework_by_frameworks frameworks, spec_name
|
60
116
|
command = 'xcodebuild -create-xcframework '
|
61
117
|
frameworks.each do |framework|
|
62
118
|
command << "-framework #{framework} "
|
63
119
|
end
|
64
|
-
command << "-output #{@sandbox_root}/#{
|
120
|
+
command << "-output #{@sandbox_root}/#{spec_name}.xcframework 2>&1"
|
65
121
|
output = `#{command}`.lines.to_a
|
66
122
|
if $?.exitstatus != 0
|
67
123
|
Pod::ErrorUtil.error_report command,output
|
68
124
|
Process.exit -1
|
69
125
|
end
|
70
|
-
"#{@sandbox_root}/#{
|
126
|
+
"#{@sandbox_root}/#{spec_name}.xcframework"
|
71
127
|
end
|
72
128
|
|
73
129
|
def build_all_device defines
|
@@ -103,7 +159,16 @@ module Pod
|
|
103
159
|
outputs_bundle target_dir
|
104
160
|
new_spec_hash = generic_new_podspec_hash @spec
|
105
161
|
new_spec_hash[:vendored_frameworks] = "#{@spec.name}.xcframework"
|
106
|
-
new_spec_hash
|
162
|
+
new_spec_hash = fix_header_file new_spec_hash, "#{target_dir}/#{@spec.name}.xcframework"
|
163
|
+
find_bundles(target_dir).each do |plat, value|
|
164
|
+
if new_spec_hash[plat]
|
165
|
+
new_spec_hash[plat]["resource_bundles"] = value
|
166
|
+
else
|
167
|
+
new_spec_hash[plat] = {
|
168
|
+
"resource_bundles" => value
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
107
172
|
require 'json'
|
108
173
|
spec_json = JSON.pretty_generate(new_spec_hash) << "\n"
|
109
174
|
File.open("#{target_dir}/#{@spec.name}.podspec.json",'wb+') do |f|
|
@@ -115,13 +180,14 @@ module Pod
|
|
115
180
|
|
116
181
|
def find_bundles target_dir
|
117
182
|
bundle_root = "#{target_dir}/bundle/"
|
118
|
-
|
119
|
-
pattern = "#{bundle_root}*#{bundle_name}"
|
183
|
+
pattern = "#{bundle_root}*"
|
120
184
|
result = {}
|
121
185
|
Pathname.glob(pattern).each do |bundle|
|
122
186
|
bundle_relative_path = bundle.to_s.gsub(bundle_root, "")
|
123
|
-
plat = bundle_relative_path
|
124
|
-
result[plat] =
|
187
|
+
plat = bundle_relative_path
|
188
|
+
result[plat] = {
|
189
|
+
"#{@spec.name}" => "bundle/" + bundle_relative_path + "/*"
|
190
|
+
}
|
125
191
|
end
|
126
192
|
result
|
127
193
|
end
|
@@ -140,5 +206,61 @@ module Pod
|
|
140
206
|
FileUtils.cp_r(Dir[@outputs[:bundle]],target_dir)
|
141
207
|
end
|
142
208
|
end
|
209
|
+
|
210
|
+
def outputs_muti target_dir
|
211
|
+
if not File.exist? target_dir
|
212
|
+
Pathname.new(target_dir).mkdir
|
213
|
+
end
|
214
|
+
outputs_xcframework_muti target_dir
|
215
|
+
outputs_bundle_muti target_dir
|
216
|
+
generic_new_podspec_hash_muti target_dir
|
217
|
+
end
|
218
|
+
|
219
|
+
def generic_new_podspec_hash_muti target_dir
|
220
|
+
work_dir = config.installation_root
|
221
|
+
@configs.map do |cfg|
|
222
|
+
podspec_path = "#{work_dir}/#{cfg["name"]}/#{cfg["name"]}.podspec"
|
223
|
+
if not File.exist? podspec_path
|
224
|
+
podspec_path = "#{podspec_path}.json"
|
225
|
+
end
|
226
|
+
podspec = Pod::Specification.from_file podspec_path
|
227
|
+
new_spec_hash = generic_new_podspec_hash podspec
|
228
|
+
new_spec_hash[:vendored_frameworks] = "#{podspec.name}.xcframework"
|
229
|
+
new_spec_hash = fix_header_file new_spec_hash, "#{target_dir}/#{@spec.name}.xcframework"
|
230
|
+
find_bundles("#{target_dir}/#{podspec.name}").each do |plat, value|
|
231
|
+
if new_spec_hash[plat]
|
232
|
+
new_spec_hash[plat]["resource_bundles"] = value
|
233
|
+
else
|
234
|
+
new_spec_hash[plat] = {
|
235
|
+
"resource_bundles" => value
|
236
|
+
}
|
237
|
+
end
|
238
|
+
end
|
239
|
+
require 'json'
|
240
|
+
spec_json = JSON.pretty_generate(new_spec_hash) << "\n"
|
241
|
+
File.open("#{target_dir}/#{podspec.name}/#{podspec.name}.podspec.json",'wb+') do |f|
|
242
|
+
f.write(spec_json)
|
243
|
+
end
|
244
|
+
UI.puts "result export at :#{target_dir}/#{podspec.name}"
|
245
|
+
"#{target_dir}/#{podspec.name}"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def outputs_xcframework_muti target_dir
|
250
|
+
@outputs[:xcframework].each do |name, path|
|
251
|
+
target_dir_path = "#{target_dir}/#{name}/"
|
252
|
+
Pathname.new(target_dir_path).mkpath
|
253
|
+
FileUtils.cp_r(path, target_dir_path)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def outputs_bundle_muti target_dir
|
258
|
+
@outputs[:bundle].each do |name, path|
|
259
|
+
target_dir_path = "#{target_dir}/#{name}/bundle/"
|
260
|
+
Pathname.new(target_dir_path).mkpath
|
261
|
+
FileUtils.cp_r(path, target_dir_path)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
143
265
|
end
|
144
266
|
end
|
@@ -2,6 +2,7 @@ require 'xcodeproj'
|
|
2
2
|
module Pod
|
3
3
|
class XBuilder
|
4
4
|
module XcodeProjHelper
|
5
|
+
include PodUtil
|
5
6
|
def modify_xcode_project_sdk_to_simullator path
|
6
7
|
sdks = xcode_sdks
|
7
8
|
project = Xcodeproj::Project.open path
|
@@ -18,17 +19,6 @@ module Pod
|
|
18
19
|
project.save
|
19
20
|
end
|
20
21
|
|
21
|
-
def to_native_platform name
|
22
|
-
case name
|
23
|
-
when 'iphoneos' then 'ios'
|
24
|
-
when 'macOS' then 'osx'
|
25
|
-
when 'appletvos' then 'tvos'
|
26
|
-
when 'watchos' then 'watchos'
|
27
|
-
else
|
28
|
-
name
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
22
|
private
|
33
23
|
def xcode_sdks
|
34
24
|
return @x_sdks if @x_sdks
|
data/lib/cocoapods_plugin.rb
CHANGED
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.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 戴易超
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04
|
11
|
+
date: 2021-07-04 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,23 +76,22 @@ 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
|
85
92
|
- lib/cocoapods-framework/xbuilder/xcodeproj_helper.rb
|
86
93
|
- lib/cocoapods_plugin.rb
|
87
94
|
- pic/allplatform.png
|
88
|
-
- pkg/cocoapods-framework-0.0.1.gem
|
89
|
-
- pkg/cocoapods-framework-0.0.2.gem
|
90
|
-
- pkg/cocoapods-framework-0.0.3.gem
|
91
|
-
- pkg/cocoapods-xcframework-0.0.4.gem
|
92
|
-
- pkg/cocoapods-xcframework-0.0.6.gem
|
93
95
|
- spec/command/framework_spec.rb
|
94
96
|
- spec/spec_helper.rb
|
95
97
|
homepage: https://github.com/TyrantDante/cocoapods-framework
|
@@ -114,7 +116,7 @@ requirements: []
|
|
114
116
|
rubygems_version: 3.0.3
|
115
117
|
signing_key:
|
116
118
|
specification_version: 4
|
117
|
-
summary:
|
119
|
+
summary: 把podspec打包成xcframework的小工具。packager pod to a xcframework
|
118
120
|
test_files:
|
119
121
|
- spec/command/framework_spec.rb
|
120
122
|
- spec/spec_helper.rb
|
data/Gemfile
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|