cocoapods-xcframework 0.0.4 → 0.1.0

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: 21eebd4159dfb6bb5f9ce1ff183edec5ec27f03711cecc7acf5d8d709083c537
4
- data.tar.gz: 36505a48d941b64cfd935fe51879abc4d463128aed8ff8452f8eb35c13a1ef81
3
+ metadata.gz: e8410820adae7d30066089eff5f0a79633d4ecbaf70ede3b06ebcce87f9d6e40
4
+ data.tar.gz: f1bf1e1adffb03e021b4f60bc7ee08e9ab7b039760968d56c43a5eede00066be
5
5
  SHA512:
6
- metadata.gz: 2f5591a1b65359fbc2fbff1d2a9a2158634ef95cb7e0c999d8a489c58276a6954ed30895676f13964fec0e0f29750ce3dcee412b38121ad786266902bd419249
7
- data.tar.gz: a79c9b4b557543cf890b19fe9148853f0e64b497ec513cb7bf9f9ad1232fe544e4fcc4b4f643df4f830e89098af44cf4521679a553128f6ea6d49e2185b579db
6
+ metadata.gz: 14f5bf93a518920efd391519e14f45c2a52b3ecd21b9f463025e7e6623e77e2c2e8a39014c21cc53e0c8ab7503aaa6fcb3f1a9ae44de7f8aaa17f1ad76dfb17f
7
+ data.tar.gz: da97711ac349944fe9fa51d1620ae45e34ba0e1e44f9085f4a232071d39894d0a0212c8311608e97cec4bc6b63fc8f1e0c9520cebc73d505959327d87960f02c
data/README.md CHANGED
@@ -14,7 +14,8 @@
14
14
  - 支持 `subspec` 打包
15
15
  ## Installation
16
16
 
17
- $ gem install cocoapods-framework
17
+ $ gem install cocoapods-xcframework
18
+ $ gem install cocoapods-xcframework-*.gem //本地安装
18
19
 
19
20
  ## Usage
20
21
  $ pod framework NAME [SOURCE]
@@ -30,7 +30,8 @@ module Pod
30
30
  ['--no-force', 'Overwrite existing files.'],
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
- ['--subspecs', 'Only include the given subspecs']
33
+ ['--subspecs', 'Only include the given subspecs'],
34
+ ['--use-modular-headers', 'pakcage uses modular headers during packaging']
34
35
  ].concat super
35
36
  end
36
37
 
@@ -41,6 +42,7 @@ module Pod
41
42
  subspecs = argv.option('subspecs')
42
43
  @subspecs = subspecs.split(',') unless subspecs.nil?
43
44
  @configuration = argv.option('configuration', 'Release')
45
+ @use_modular_headers = argv.option('use-modular-headers', true)
44
46
  @force = argv.flag?('force', true)
45
47
  super
46
48
  end
@@ -51,7 +53,7 @@ module Pod
51
53
  end
52
54
 
53
55
  def run
54
- frameworker = Frameworker.new(@name, @source, @spec_sources, @subspecs, @configuration, @force)
56
+ frameworker = Frameworker.new(@name, @source, @spec_sources, @subspecs, @configuration, @force, @use_modular_headers)
55
57
  frameworker.run
56
58
  end
57
59
  end
@@ -3,13 +3,14 @@ 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)
6
+ def initialize(name, source, spec_sources, subspecs, configuration, force, use_modular_headers)
7
7
  @name = name
8
8
  @source = source
9
9
  @spec_sources = spec_sources
10
10
  @subspecs = subspecs
11
11
  @configuration = configuration
12
12
  @force = force
13
+ @use_modular_headers = use_modular_headers
13
14
  end
14
15
 
15
16
  def run
@@ -35,6 +36,7 @@ module Pod
35
36
  spec,
36
37
  @subspecs,
37
38
  @spec_sources,
39
+ @use_modular_headers
38
40
  )
39
41
 
40
42
  perform_build(
@@ -1,3 +1,3 @@
1
1
  module CocoapodsFramework
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,2 +1,3 @@
1
+ require 'cocoapods-framework/util/error_util'
1
2
  require 'cocoapods-framework/util/pod_util'
2
3
  require 'cocoapods-framework/util/dir_util'
@@ -0,0 +1,13 @@
1
+ module Pod
2
+ module ErrorUtil
3
+ class << self
4
+ def error_report(command, output)
5
+ UI.puts "<<-EOF
6
+ Build command failed: #{command}
7
+ Output:
8
+ #{output.map { |line| " #{line}" }.join}
9
+ EOF"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -8,12 +8,12 @@ module Pod
8
8
  @path = path.expand_path
9
9
 
10
10
  if @path.directory?
11
- help! @path + ': is a directory.'
11
+ raise @path + ': is a directory.'
12
12
  return
13
13
  end
14
14
 
15
15
  unless ['.podspec', '.json'].include? @path.extname
16
- help! @path + ': is not a podspec.'
16
+ raise @path + ': is not a podspec.'
17
17
  return
18
18
  end
19
19
 
@@ -33,25 +33,25 @@ module Pod
33
33
  Sandbox.new(config.sandbox_root)
34
34
  end
35
35
 
36
- def installation_root sandbox, spec, subspecs, sources,use_frameworks = true
36
+ def installation_root sandbox, spec, subspecs, sources,use_frameworks = true,use_modular_headers = true
37
37
  podfile = podfile_from_spec(
38
38
  @path,
39
39
  spec,
40
- # platform,
41
40
  subspecs,
42
41
  sources,
43
- use_frameworks
42
+ use_frameworks,
43
+ use_modular_headers
44
44
  )
45
45
 
46
46
  installer = Installer.new(sandbox, podfile)
47
- puts podfile.to_hash.to_json
48
47
  installer.install!
49
48
 
50
49
  unless installer.nil?
51
50
  installer.pods_project.targets.each do |target|
52
- target.build_configurations.each do |configuration|
53
- configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
54
- configuration.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
51
+ if target.name == spec.name
52
+ target.build_configurations.each do |configuration|
53
+ configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
54
+ end
55
55
  end
56
56
  end
57
57
  installer.pods_project.save
@@ -59,7 +59,7 @@ module Pod
59
59
  installer
60
60
  end
61
61
 
62
- def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true
62
+ def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true
63
63
  options = Hash.new
64
64
  options[:podspec] = path.to_s
65
65
  options[:subspecs] = subspecs if subspecs
@@ -77,8 +77,9 @@ module Pod
77
77
  :integrate_targets => false,
78
78
  :deterministic_uuids => false)
79
79
 
80
- use_frameworks! if use_frameworks
81
- end
80
+ use_frameworks! if use_frameworks
81
+ use_modular_headers! if use_modular_headers
82
+ end
82
83
  end
83
84
 
84
85
  def generic_new_podspec_hash spec
@@ -106,4 +107,4 @@ module Pod
106
107
  spec_hash
107
108
  end
108
109
  end
109
- end
110
+ end
@@ -14,28 +14,49 @@ module Pod
14
14
  @sandbox_root = sandbox_root
15
15
  @spec = spec
16
16
  @configuration = configuration
17
- @outputs = nil
17
+ @outputs = {}
18
18
  end
19
19
 
20
20
  def build
21
21
  UI.puts("Building framework #{@spec} with configuration #{@configuration}")
22
22
  UI.puts "Work dir is :#{@sandbox_root}"
23
23
  defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
24
- # defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
25
24
 
26
25
  if @configuration == 'Debug'
27
26
  defines << 'GCC_GENERATE_DEBUGGING_SYMBOLS=YES ONLY_ACTIVE_ARCH=NO'
27
+ else
28
+ defines << "GCC_GENERATE_DEBUGGING_SYMBOLS=NO"
28
29
  end
29
30
 
30
31
  build_all_device defines
31
32
 
32
33
  collect_xc_frameworks
34
+
35
+ collect_bundles
33
36
  end
34
37
 
35
38
  def collect_xc_frameworks
36
39
  export_dir = "#{@sandbox_root}/export/**/#{@spec.name}.framework"
37
40
  frameworks = Pathname.glob(export_dir)
38
- @outputs = create_xc_framework_by_frameworks frameworks
41
+ @outputs[:xcframework] = create_xc_framework_by_frameworks frameworks
42
+ end
43
+
44
+ def collect_bundles
45
+ ["iphoneos","macOS","appletvos","watchos"].each do |plat|
46
+ export_dir = "#{@sandbox_root}/export/*-#{plat}/**/#{@spec.name}.bundle/**"
47
+ Pathname.glob(export_dir).each do |bundle|
48
+ if bundle.to_s.include? "#{@spec.name}.bundle/Info.plist"
49
+ return
50
+ end
51
+ @outputs[:bundle] = "#{@sandbox_root}/bundle"
52
+ native_platform = to_native_platform plat
53
+ path = Pathname.new "#{@sandbox_root}/bundle/#{native_platform}"
54
+ if not path.exist?
55
+ path.mkpath
56
+ end
57
+ FileUtils.cp_r(Dir["#{bundle}"],"#{path}")
58
+ end
59
+ end
39
60
  end
40
61
 
41
62
  def create_xc_framework_by_frameworks frameworks
@@ -44,10 +65,10 @@ module Pod
44
65
  command << "-framework #{framework} "
45
66
  end
46
67
  command << "-output #{@sandbox_root}/#{@spec.name}.xcframework 2>&1"
47
- UI.puts `#{command}`
68
+ output = `#{command}`.lines.to_a
48
69
  if $?.exitstatus != 0
49
- UI.puts(output)
50
- Process.exit
70
+ Pod::ErrorUtil.error_report command,output
71
+ Process.exit -1
51
72
  end
52
73
  "#{@sandbox_root}/#{@spec.name}.xcframework"
53
74
  end
@@ -82,8 +103,18 @@ module Pod
82
103
  Pathname.new(target_dir).mkdir
83
104
  end
84
105
  outputs_xcframework target_dir
106
+ outputs_bundle target_dir
85
107
  new_spec_hash = generic_new_podspec_hash @spec
86
108
  new_spec_hash[:vendored_frameworks] = "#{@spec.name}.xcframework"
109
+ find_bundles(target_dir).each do |plat, value|
110
+ if new_spec_hash[plat]
111
+ new_spec_hash[plat]["resource_bundles"] = value
112
+ else
113
+ new_spec_hash[plat] = {
114
+ "resource_bundles" => value
115
+ }
116
+ end
117
+ end
87
118
  require 'json'
88
119
  spec_json = JSON.pretty_generate(new_spec_hash) << "\n"
89
120
  File.open("#{target_dir}/#{@spec.name}.podspec.json",'wb+') do |f|
@@ -92,13 +123,34 @@ module Pod
92
123
  UI.puts "result export at :#{target_dir}"
93
124
  target_dir
94
125
  end
126
+
127
+ def find_bundles target_dir
128
+ bundle_root = "#{target_dir}/bundle/"
129
+ pattern = "#{bundle_root}*"
130
+ result = {}
131
+ Pathname.glob(pattern).each do |bundle|
132
+ bundle_relative_path = bundle.to_s.gsub(bundle_root, "")
133
+ plat = bundle_relative_path
134
+ result[plat] = {
135
+ "#{@spec.name}" => "bundle/" + bundle_relative_path + "/*"
136
+ }
137
+ end
138
+ result
139
+ end
95
140
 
96
141
  def outputs_xcframework target_dir
97
- `cp -rp #{@outputs} #{target_dir} 2>&1`
142
+ command = "cp -rp #{@outputs[:xcframework]} #{target_dir} 2>&1"
143
+ output = `#{command}`.lines.to_a
98
144
  if $?.exitstatus != 0
99
- UI.puts output
100
- Process.exit
145
+ Pod::ErrorUtil.error_report command,output
146
+ Process.exit -1
147
+ end
148
+ end
149
+
150
+ def outputs_bundle target_dir
151
+ if @outputs[:bundle]
152
+ FileUtils.cp_r(Dir[@outputs[:bundle]],target_dir)
101
153
  end
102
154
  end
103
155
  end
104
- end
156
+ end
@@ -3,18 +3,18 @@ module Pod
3
3
  module XcodeXBuilder
4
4
  def xcode_xbuild(defines, configuration, work_dir, build_dir = 'export')
5
5
  if defined?(Pod::DONT_CODESIGN)
6
- args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
6
+ defines = "#{defines} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
7
7
  end
8
8
  pwd = Pathname.pwd
9
9
  Dir.chdir work_dir
10
10
  command = "xcodebuild #{defines} BUILD_DIR=#{build_dir} BUILD_LIBRARY_FOR_DISTRIBUTION=YES clean build -configuration #{configuration} -alltargets 2>&1"
11
- outputs = `#{command}`.lines.to_s
11
+ output = `#{command}`.lines.to_a
12
12
  Dir.chdir pwd
13
13
  if $?.exitstatus != 0
14
- UI.puts output
15
- Process.exit
14
+ Pod::ErrorUtil.error_report command,output
15
+ Process.exit -1
16
16
  end
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ 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
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.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 戴易超
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -78,6 +78,7 @@ files:
78
78
  - lib/cocoapods-framework/gem_version.rb
79
79
  - lib/cocoapods-framework/util.rb
80
80
  - lib/cocoapods-framework/util/dir_util.rb
81
+ - lib/cocoapods-framework/util/error_util.rb
81
82
  - lib/cocoapods-framework/util/pod_util.rb
82
83
  - lib/cocoapods-framework/xbuilder.rb
83
84
  - lib/cocoapods-framework/xbuilder/xcode_xbuild.rb
@@ -87,6 +88,10 @@ files:
87
88
  - pkg/cocoapods-framework-0.0.1.gem
88
89
  - pkg/cocoapods-framework-0.0.2.gem
89
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
+ - pkg/cocoapods-xcframework-0.0.7.gem
94
+ - pkg/cocoapods-xcframework-0.0.8.gem
90
95
  - spec/command/framework_spec.rb
91
96
  - spec/spec_helper.rb
92
97
  homepage: https://github.com/TyrantDante/cocoapods-framework