cocoapods-xcframework 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e585d673b3955cf72fabe8215902f92f47634ada97c293bd2acdf3a8e42a9622
4
- data.tar.gz: 27d5a9e175c71b1701ec24bc0abaf31de9a57b396662574c08e5d485f81d085d
3
+ metadata.gz: 46213903938512037adf189a5077b72a22de58a58772079b6ed51e3d69819848
4
+ data.tar.gz: 4ca7fdc2a9eb9614a82ba357b97d109ee5c1039373432f3b6e93a2ccaa51a15c
5
5
  SHA512:
6
- metadata.gz: 62df3f2b4a90787a7101851ebe5e1d78dbac8685d7edf6e2e3543879cee31ff37c05d9365bfd08e95dbdb6acdf53a0f799397a916b1fcac02e68a244012ecf7c
7
- data.tar.gz: ea585449d6726c1ac2c5a493dfce82cc04cf58f8bc3b848c35bd779517cd111f61f883163cc4bf248c9e7b0382f30fb5de912759699ecfcaf4b090238efc68a1
6
+ metadata.gz: ed4aa32df78147ee139baa3041ff87bfd02b751a65062d8732361bca189478b0733f0df62be1ff6ad7dcdc6e1e0b5bce985a4996e2c1edae796aded3c6c8b7b4
7
+ data.tar.gz: 7b63fd3315add0ca97f5ac408bbd6a6fc2ef7bcc002f361abce8f042302c4321ecde12d8cb05db97211b854e94cb5de1a49fb8d86158f6e189fd2077c986fe91
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Example/*
@@ -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{A short description of cocoapods-xcframework.}
12
- spec.summary = %q{A longer description of cocoapods-xcframework.}
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
 
@@ -1 +1,2 @@
1
1
  require 'cocoapods-framework/command/framework'
2
+ require 'cocoapods-framework/command/muti_framework'
@@ -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
@@ -2,5 +2,7 @@ module Pod
2
2
  class Config
3
3
  attr_accessor :xcframework_enable
4
4
  alias_method :xcframework_enable?, :xcframework_enable
5
+ attr_accessor :static_library_enable
6
+ alias_method :static_library_enable?, :static_library_enable
5
7
  end
6
8
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsFramework
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.1"
3
3
  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
@@ -1,3 +1,5 @@
1
1
  require 'cocoapods-framework/util/error_util'
2
+ require 'cocoapods-framework/util/cmd'
3
+ require 'cocoapods-framework/util/git_util'
2
4
  require 'cocoapods-framework/util/pod_util'
3
5
  require 'cocoapods-framework/util/dir_util'
@@ -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,12 +59,42 @@ module Pod
44
59
  )
45
60
 
46
61
  installer = Installer.new(sandbox, podfile)
62
+ installer.repo_update = true
63
+ installer.install!
64
+
65
+ unless installer.nil?
66
+ installer.pods_project.targets.each do |target|
67
+ if target.name == spec.name
68
+ target.build_configurations.each do |configuration|
69
+ configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
70
+ end
71
+ end
72
+ end
73
+ installer.pods_project.save
74
+ end
75
+ installer
76
+ end
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
47
87
  installer.install!
48
88
 
89
+ specs = configs.map do |cfg|
90
+ cfg["name"]
91
+ end
49
92
  unless installer.nil?
50
93
  installer.pods_project.targets.each do |target|
51
- target.build_configurations.each do |configuration|
52
- # configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
94
+ if specs.include? target.name
95
+ target.build_configurations.each do |configuration|
96
+ configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
97
+ end
53
98
  end
54
99
  end
55
100
  installer.pods_project.save
@@ -58,10 +103,17 @@ module Pod
58
103
  end
59
104
 
60
105
  def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true
61
- options = Hash.new
106
+ options = Hash.new
62
107
  options[:podspec] = path.to_s
108
+ options[:subspecs] = spec.subspecs.map do |sub|
109
+ sub.base_name
110
+ end
63
111
  options[:subspecs] = subspecs if subspecs
64
-
112
+ # 非常奇怪,如果传一个空的数组过去就会出问题!!
113
+ if options[:subspecs].length == 0
114
+ options[:subspecs] = nil
115
+ end
116
+ static_library_enable = config.static_library_enable?
65
117
  Pod::Podfile.new do
66
118
  sources.each {|s| source s}
67
119
  spec.available_platforms.each do |plt|
@@ -71,13 +123,59 @@ module Pod
71
123
  end
72
124
  end
73
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
74
168
  install!('cocoapods',
75
169
  :integrate_targets => false,
76
170
  :deterministic_uuids => false)
77
171
 
78
- use_frameworks! if use_frameworks
172
+ if static_library_enable
173
+ use_frameworks! :linkage => :static if use_frameworks
174
+ else
175
+ use_frameworks! if use_frameworks
176
+ end
79
177
  use_modular_headers! if use_modular_headers
80
- end
178
+ end
81
179
  end
82
180
 
83
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 = nil
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
@@ -31,26 +35,95 @@ module Pod
31
35
  build_all_device defines
32
36
 
33
37
  collect_xc_frameworks
38
+
39
+ collect_bundles
34
40
  end
35
41
 
36
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
37
60
  export_dir = "#{@sandbox_root}/export/**/#{@spec.name}.framework"
38
61
  frameworks = Pathname.glob(export_dir)
39
- @outputs = create_xc_framework_by_frameworks frameworks
62
+ @outputs[:xcframework] = create_xc_framework_by_frameworks frameworks, @spec.name
40
63
  end
41
64
 
42
- def create_xc_framework_by_frameworks frameworks
65
+ def collect_bundles
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/**"
100
+ Pathname.glob(export_dir).each do |bundle|
101
+ if bundle.to_s.include? "#{@spec.name}.bundle/Info.plist"
102
+ return
103
+ end
104
+ @outputs[:bundle] = "#{@sandbox_root}/bundle"
105
+ native_platform = to_native_platform plat
106
+ path = Pathname.new "#{@sandbox_root}/bundle/#{native_platform}"
107
+ if not path.exist?
108
+ path.mkpath
109
+ end
110
+ FileUtils.cp_r(Dir["#{bundle}"],"#{path}")
111
+ end
112
+ end
113
+ end
114
+
115
+ def create_xc_framework_by_frameworks frameworks, spec_name
43
116
  command = 'xcodebuild -create-xcframework '
44
117
  frameworks.each do |framework|
45
118
  command << "-framework #{framework} "
46
119
  end
47
- command << "-output #{@sandbox_root}/#{@spec.name}.xcframework 2>&1"
120
+ command << "-output #{@sandbox_root}/#{spec_name}.xcframework 2>&1"
48
121
  output = `#{command}`.lines.to_a
49
122
  if $?.exitstatus != 0
50
123
  Pod::ErrorUtil.error_report command,output
51
124
  Process.exit -1
52
125
  end
53
- "#{@sandbox_root}/#{@spec.name}.xcframework"
126
+ "#{@sandbox_root}/#{spec_name}.xcframework"
54
127
  end
55
128
 
56
129
  def build_all_device defines
@@ -83,8 +156,18 @@ module Pod
83
156
  Pathname.new(target_dir).mkdir
84
157
  end
85
158
  outputs_xcframework target_dir
159
+ outputs_bundle target_dir
86
160
  new_spec_hash = generic_new_podspec_hash @spec
87
161
  new_spec_hash[:vendored_frameworks] = "#{@spec.name}.xcframework"
162
+ find_bundles(target_dir).each do |plat, value|
163
+ if new_spec_hash[plat]
164
+ new_spec_hash[plat]["resource_bundles"] = value
165
+ else
166
+ new_spec_hash[plat] = {
167
+ "resource_bundles" => value
168
+ }
169
+ end
170
+ end
88
171
  require 'json'
89
172
  spec_json = JSON.pretty_generate(new_spec_hash) << "\n"
90
173
  File.open("#{target_dir}/#{@spec.name}.podspec.json",'wb+') do |f|
@@ -93,14 +176,89 @@ module Pod
93
176
  UI.puts "result export at :#{target_dir}"
94
177
  target_dir
95
178
  end
179
+
180
+ def find_bundles target_dir
181
+ bundle_root = "#{target_dir}/bundle/"
182
+ pattern = "#{bundle_root}*"
183
+ result = {}
184
+ Pathname.glob(pattern).each do |bundle|
185
+ bundle_relative_path = bundle.to_s.gsub(bundle_root, "")
186
+ plat = bundle_relative_path
187
+ result[plat] = {
188
+ "#{@spec.name}" => "bundle/" + bundle_relative_path + "/*"
189
+ }
190
+ end
191
+ result
192
+ end
96
193
 
97
194
  def outputs_xcframework target_dir
98
- command = "cp -rp #{@outputs} #{target_dir} 2>&1"
195
+ command = "cp -rp #{@outputs[:xcframework]} #{target_dir} 2>&1"
99
196
  output = `#{command}`.lines.to_a
100
197
  if $?.exitstatus != 0
101
198
  Pod::ErrorUtil.error_report command,output
102
199
  Process.exit -1
103
200
  end
104
201
  end
202
+
203
+ def outputs_bundle target_dir
204
+ if @outputs[:bundle]
205
+ FileUtils.cp_r(Dir[@outputs[:bundle]],target_dir)
206
+ end
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
+
105
263
  end
106
264
  end
@@ -18,6 +18,17 @@ module Pod
18
18
  project.save
19
19
  end
20
20
 
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
+
21
32
  private
22
33
  def xcode_sdks
23
34
  return @x_sdks if @x_sdks
@@ -3,6 +3,7 @@ require 'cocoapods-framework/config'
3
3
  require 'cocoapods-framework/util'
4
4
  require 'cocoapods-framework/xbuilder'
5
5
  require 'cocoapods-framework/frameworker'
6
+ require 'cocoapods-framework/muti_frameworker'
6
7
 
7
8
 
8
9
  #这个放在最后一个
Binary file
Binary file
Binary file
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.0.5
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-03-30 00:00:00.000000000 Z
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: A short description of cocoapods-xcframework.
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
- - Gemfile
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
@@ -89,6 +96,10 @@ files:
89
96
  - pkg/cocoapods-framework-0.0.2.gem
90
97
  - pkg/cocoapods-framework-0.0.3.gem
91
98
  - pkg/cocoapods-xcframework-0.0.4.gem
99
+ - pkg/cocoapods-xcframework-0.0.6.gem
100
+ - pkg/cocoapods-xcframework-0.0.7.gem
101
+ - pkg/cocoapods-xcframework-0.0.8.gem
102
+ - pkg/cocoapods-xcframework-0.1.0.gem
92
103
  - spec/command/framework_spec.rb
93
104
  - spec/spec_helper.rb
94
105
  homepage: https://github.com/TyrantDante/cocoapods-framework
@@ -113,7 +124,7 @@ requirements: []
113
124
  rubygems_version: 3.0.3
114
125
  signing_key:
115
126
  specification_version: 4
116
- summary: A longer description of cocoapods-xcframework.
127
+ summary: 把podspec打包成xcframework的小工具。packager pod to a xcframework
117
128
  test_files:
118
129
  - spec/command/framework_spec.rb
119
130
  - spec/spec_helper.rb
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cocoapods-framework.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