cocoapods-util 0.0.15 → 0.0.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3e136a04158a95c53ec3bf85971b13f137f85ad816633d64cf9655fca06234c
4
- data.tar.gz: 32fd218bb662f121551dd394782a97691fee24c86d7105cf3d5c0f7d5a16275c
3
+ metadata.gz: 83da9a9a68fa2cc89f013255846c38e0ff5f7dd8631c96ac21555b4a30d58e14
4
+ data.tar.gz: 39a88b6de2d54f2d68a3ae0b84727650a3b89fb006d5a3aa3f03eef7070d0f06
5
5
  SHA512:
6
- metadata.gz: 14561d493194c787d69f8749f30e14c57227f623a3954cf8017376a84544df4dbd23906e4041b3361211e31340cae48344ff4c0b61601bd02d9cb27db96bf07b
7
- data.tar.gz: dc4fcb6c4dafd62b2b107d6f7d40f254b2544e91beeaaa9ca75296c2816c5af3b48c46f1dd44c9af622835a25db823f6eec9b606e57f87ec14535f1aad5c39c0
6
+ metadata.gz: 17ad6705b93f62ed103cccf0d8c102c684bc662506c682053b2e1c2120aa6f70522c24af830b1e7f8ac5148a6ae4096525889c4de1abab1d254d5f254d0db913
7
+ data.tar.gz: '09847e25cdcd0f23b107322a2ab76fb47f792031824bce7d0ef369d161765c144c80c56f9b566cf5374f9e612c21a160c22577c73c863528803a9523bf6c7c2a'
@@ -0,0 +1,23 @@
1
+ module BinaryPrebuild
2
+ def self.config
3
+ BinaryPrebuild::Config.instance
4
+ end
5
+
6
+ class Config
7
+ attr_accessor :enable_all, :enable_targets
8
+
9
+ def initialize()
10
+ @enable_all = false
11
+ @enable_targets = []
12
+ end
13
+
14
+ def self.instance
15
+ @instance ||= new()
16
+ end
17
+
18
+ def add_enable_target(name)
19
+ @enable_targets.push name
20
+ @enable_targets.uniq!
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'pre_install'
2
+ require_relative 'post_install'
3
+
4
+ module CocoapodsUtilHook
5
+ Pod::HooksManager.register('cocoapods-util', :pre_install) do |installer_context, _|
6
+ BinaryPrebuild::PreInstall.new(installer_context).run
7
+ end
8
+
9
+ Pod::HooksManager.register('cocoapods-util', :pre_integrate) do |context, _|
10
+
11
+ end
12
+
13
+ Pod::HooksManager.register('cocoapods-util', :post_install) do |context, _|
14
+ BinaryPrebuild::PostInstall.new(context).run
15
+ end
16
+
17
+ Pod::HooksManager.register('cocoapods-util', :post_integrate) do |context, _|
18
+
19
+ end
20
+
21
+ Pod::HooksManager.register('cocoapods-util', :source_provider) do |context, _|
22
+
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module BinaryPrebuild
2
+ class PostInstall
3
+ def initialize(installer_context)
4
+ @installer_context = installer_context
5
+ end
6
+
7
+ def run
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../targets/pod_target'
2
+
3
+ module BinaryPrebuild
4
+ class PreInstall
5
+ def initialize(installer_context)
6
+ @installer_context = installer_context
7
+ end
8
+
9
+ def run
10
+ # [Check Environment]
11
+ # podfile = @installer_context.podfile
12
+ # podfile.target_definition_list.each do |target_definition|
13
+ # if not target_definition.uses_frameworks?
14
+ # STDERR.puts "[!] Cocoapods-binary requires `use_frameworks!`".red
15
+ # exit
16
+ # end
17
+ # end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ require_relative 'config'
2
+ require_relative 'podfile_dsl'
3
+ require_relative 'prebuild'
4
+ require_relative 'hooks/CocoapodsUtilHook'
@@ -0,0 +1,27 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ def self.enable_framework_header_keyword
5
+ :enable_framework_header
6
+ end
7
+
8
+ def enable_all_framework_header!(enable: true)
9
+ BinaryPrebuild.config.enable_all = enable
10
+ end
11
+
12
+ # hook
13
+ old_method = instance_method(:pod)
14
+ define_method(:pod) do |name, *args|
15
+ enable = BinaryPrebuild.config.enable_all
16
+ options = args.last
17
+ keyword = DSL.enable_framework_header_keyword
18
+ if options.is_a?(Hash) && options[keyword] != nil
19
+ enable = options.delete(keyword)
20
+ args.pop if options.empty?
21
+ end
22
+ BinaryPrebuild.config.add_enable_target name.to_s.gsub(/\/.*$/, '') if enable
23
+ old_method.bind(self).(name, *args)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module BinaryPrebuild
2
+
3
+ end
@@ -0,0 +1,76 @@
1
+ module Pod
2
+ class Target
3
+ # @since 1.5.0
4
+ class BuildSettings
5
+ # missing framework header search paths
6
+ def missing_framework_header_search_path(pt)
7
+ return [] unless BinaryPrebuild.config.enable_targets.include? pt.name
8
+
9
+ paths = []
10
+ pt.file_accessors.each do |file_accessor|
11
+ # xcframeworks
12
+ greater_than_or_equal_to_1_10_0 = Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
13
+ greater_than_or_equal_to_1_11_0 = Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.11.0')
14
+ file_accessor.vendored_xcframeworks.map { |path|
15
+ if greater_than_or_equal_to_1_11_0
16
+ Xcode::XCFramework.new(file_accessor.spec.name, path)
17
+ else
18
+ Xcode::XCFramework.new(path)
19
+ end
20
+ }.each { |xcfwk|
21
+ xcfwk.slices.each { |slice|
22
+ fwk_name = slice.path.basename
23
+ if greater_than_or_equal_to_1_11_0
24
+ paths.push "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{xcfwk.target_name}/#{fwk_name}/Headers"
25
+ elsif greater_than_or_equal_to_1_10_0
26
+ paths.push "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{fwk_name.to_s.gsub(/\.framework$/, '')}/#{fwk_name}/Headers"
27
+ else
28
+ paths.push "${PODS_CONFIGURATION_BUILD_DIR}/#{fwk_name}/Headers"
29
+ end
30
+ }
31
+ }
32
+ # Cocoapods 1.9.x bugs
33
+ if Gem::Version.new(Pod::VERSION) < Gem::Version.new('1.10.0')
34
+ file_accessor.vendored_xcframeworks.each { |path|
35
+ Dir.glob("#{path.to_s}/**/*.framework").each do |fwk_path|
36
+ header_path = Pathname.new("#{fwk_path}/Headers")
37
+ next unless header_path.exist?
38
+ paths.push "${PODS_ROOT}/#{header_path.relative_path_from(pt.sandbox.root)}"
39
+ end
40
+ }
41
+ end
42
+
43
+ # frameworks
44
+ (file_accessor.vendored_frameworks - file_accessor.vendored_xcframeworks).each { |framework|
45
+ header_path = Pathname.new("#{framework}/Headers")
46
+ next unless header_path.exist?
47
+ paths.push "${PODS_ROOT}/#{header_path.relative_path_from(pt.sandbox.root)}"
48
+ }
49
+ end
50
+ paths.uniq
51
+ end
52
+
53
+ # A subclass that generates build settings for a `PodTarget`
54
+ class AggregateTargetSettings
55
+ # @return [Array<String>]
56
+ alias_method :old_raw_header_search_paths, :_raw_header_search_paths
57
+ def _raw_header_search_paths
58
+ header_search_paths = old_raw_header_search_paths
59
+ header_search_paths.concat pod_targets.flat_map { |pt| missing_framework_header_search_path(pt) }
60
+ header_search_paths.uniq
61
+ end
62
+ end
63
+
64
+ # A subclass that generates build settings for a {PodTarget}
65
+ class PodTargetSettings
66
+ # @return [Array<String>]
67
+ alias_method :old_raw_header_search_paths, :_raw_header_search_paths
68
+ def _raw_header_search_paths
69
+ header_search_paths = old_raw_header_search_paths
70
+ header_search_paths.concat dependent_targets.flat_map { |pt| missing_framework_header_search_path(pt) } if target.should_build?
71
+ header_search_paths.uniq
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -67,10 +67,11 @@ module Pod
67
67
  UI.puts " - SPEC REPO: ".yellow "#{repo_name}".green unless repo_name.nil?
68
68
 
69
69
  # external sources
70
- external_dict = @lockfile.internal_data['EXTERNAL SOURCES']
71
- unless external_dict.nil?
72
- external = external_dict[name]
73
- external.each { |key, value| UI.puts " - #{key}: ".yellow "#{value}".green } unless external.nil?
70
+ external_sources = @lockfile.internal_data['EXTERNAL SOURCES']
71
+ unless external_sources.nil?
72
+ external_dict = external_sources[name]
73
+ UI.puts " - EXTERNAL SOURCES: ".yellow unless external_dict.nil?
74
+ external_dict.each { |key, value| UI.puts " - #{key}: ".yellow "#{value}".green } unless external_dict.nil?
74
75
  end
75
76
 
76
77
  # subspecs、dependencies、parents
@@ -78,23 +79,33 @@ module Pod
78
79
  end
79
80
 
80
81
  def show_moreinfo(name)
81
- subspecs = []
82
- dependencies = []
83
- parents = Array.new
82
+ # checkout options
83
+ checkout_options = @lockfile.internal_data['CHECKOUT OPTIONS']
84
+ unless checkout_options.nil?
85
+ checkout_dict = checkout_options[name]
86
+ UI.puts " - CHECKOUT OPTIONS: ".yellow unless checkout_dict.nil?
87
+ checkout_dict.each { |key, value| UI.puts " - #{key}: ".yellow "#{value}".green } unless checkout_dict.nil?
88
+ end
89
+
90
+ subspecs, dependencies, parents = [], [], []
84
91
  @lockfile.internal_data["PODS"].each { |item|
92
+ # 取遍历的pod名称
85
93
  pod_name = item.keys.first if item.is_a?(Hash) && item.count == 1
86
94
  pod_name = item if item.is_a?(String)
87
- if pod_name =~ /^#{name}.*$/
88
- subspecs.push(pod_name.match(/^[^\s]*/).to_s) if pod_name =~ /^#{name}\/.*$/
95
+ if pod_name =~ /^#{name}[\s\/]/ # 以#{name}开头,后跟一个'空格'或一个'/'
96
+ subspecs.push(pod_name.match(/^[^\s]*/).to_s) if pod_name =~ /^#{name}\// # 如果#{name}后跟的是'/',则是subspec
89
97
  if item.is_a?(Hash)
90
98
  item.each_value do |value|
99
+ # 如果不是以#{name}开头的,则是dependency
91
100
  value.each {|dependency| dependencies.push(dependency.to_s) unless dependency =~ /^#{name}/ }
92
101
  end
93
102
  elsif item.is_a?(String)
103
+ # 如果不是以#{name}开头的,则是dependency
94
104
  dependencies.push(item.to_s) unless item =~ /^#{name}/
95
105
  end
96
106
  else
97
107
  next if pod_name.nil?
108
+ # 如果不是匹配到的pod名称,则检查是不是依赖了该pod
98
109
  if item.is_a?(Hash)
99
110
  item.each_value do |value|
100
111
  value.each {|dependency| parents.push(pod_name.match(/^[^\s\/]*/).to_s) if dependency =~ /^#{name}/ }
@@ -102,12 +113,9 @@ module Pod
102
113
  end
103
114
  end
104
115
  }
105
- subspecs.uniq!
106
- dependencies.uniq!
107
- parents.uniq!
108
- UI.puts " - SUBSPECS: ".yellow "#{subspecs.join('、')}".green unless subspecs.empty?
109
- UI.puts " - DEPENDENCIES: ".yellow "#{dependencies.join('、')}".green unless dependencies.empty?
110
- UI.puts " - WHO DEPENDS ON IT: ".yellow "#{parents.join('、')}".green unless parents.empty?
116
+ UI.puts " - SUBSPECS: ".yellow "#{subspecs.uniq.join('、')}".green unless subspecs.empty?
117
+ UI.puts " - DEPENDENCIES: ".yellow "#{dependencies.uniq.join('、')}".green unless dependencies.empty?
118
+ UI.puts " - DEPENDS ON IT: ".yellow "#{parents.uniq.join('、')}".green unless parents.empty?
111
119
  end
112
120
 
113
121
  def pod_tags_info
@@ -118,10 +126,10 @@ module Pod
118
126
  @lockfile.internal_data["PODS"].each do |item|
119
127
  info = item.keys.first if item.is_a?(Hash) && item.count == 1
120
128
  info = item if item.is_a?(String)
121
- if info =~ /^[^\/]*$/
122
- name = info.match(/^[^\/\s]*/)
123
- tag = info.match(/\(.*\)/) || ''
124
- @tags_info[name.to_s] = tag.to_s
129
+ name = info.match(/^[^\/\s]*/).to_s
130
+ unless @tags_info.keys.include?(name)
131
+ tag = info.match(/\(.*\)/).to_s
132
+ @tags_info[name] = tag unless tag.empty?
125
133
  end
126
134
  end
127
135
  @tags_info
@@ -29,8 +29,8 @@ module Pod
29
29
  default_build_settings = Hash.new
30
30
  default_build_settings["CLANG_MODULES_AUTOLINK"] = "NO"
31
31
  default_build_settings["GCC_GENERATE_DEBUGGING_SYMBOLS"] = "YES" # 生成Debug编译信息
32
- default_build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" unless @xcframework && self.match_pod_version?('~> 1.11') # 非xcframework排除ios simulator 64位架构
33
- default_build_settings["EXCLUDED_ARCHS[sdk=appletvsimulator*]"] = "arm64" unless @xcframework && self.match_pod_version?('~> 1.11') # 非xcframework排除tvos simulator 64位架构
32
+ default_build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" # unless @xcframework && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.11')# 非xcframework排除ios simulator 64位架构
33
+ default_build_settings["EXCLUDED_ARCHS[sdk=appletvsimulator*]"] = "arm64" # unless @xcframework && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.11') # 非xcframework排除tvos simulator 64位架构
34
34
  default_build_settings["BUILD_LIBRARY_FOR_DISTRIBUTION"] = "YES" # 编译swift生成swiftinterface文件
35
35
  default_build_settings["CODE_SIGN_IDENTITY"] = "" if `xcodebuild -version`.lines.shift.gsub!('Xcode ', '') >= "14" #xcode版本大于等于xcode 14时需要添加
36
36
 
@@ -121,10 +121,6 @@ module Pod
121
121
 
122
122
  Specification.from_file(@path)
123
123
  end
124
-
125
- def match_pod_version?(*version)
126
- Gem::Dependency.new('', *version).match?('', Pod::VERSION)
127
- end
128
124
  end
129
125
  end
130
126
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsUtil
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  require 'cocoapods-util/tool'
2
2
  require 'cocoapods-util/command'
3
- require 'cocoapods-util/CocoapodsUtilHook.rb'
3
+ require 'cocoapods-util/binary/main.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - guojiashuang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -68,7 +68,14 @@ files:
68
68
  - LICENSE
69
69
  - README.md
70
70
  - lib/cocoapods-util.rb
71
- - lib/cocoapods-util/CocoapodsUtilHook.rb
71
+ - lib/cocoapods-util/binary/config.rb
72
+ - lib/cocoapods-util/binary/hooks/CocoapodsUtilHook.rb
73
+ - lib/cocoapods-util/binary/hooks/post_install.rb
74
+ - lib/cocoapods-util/binary/hooks/pre_install.rb
75
+ - lib/cocoapods-util/binary/main.rb
76
+ - lib/cocoapods-util/binary/podfile_dsl.rb
77
+ - lib/cocoapods-util/binary/prebuild.rb
78
+ - lib/cocoapods-util/binary/targets/pod_target.rb
72
79
  - lib/cocoapods-util/command.rb
73
80
  - lib/cocoapods-util/command/cocoapods-extend/extend.rb
74
81
  - lib/cocoapods-util/command/cocoapods-extend/install.rb
@@ -90,9 +97,6 @@ files:
90
97
  - lib/cocoapods-util/command/xcframework/xcframework.rb
91
98
  - lib/cocoapods-util/command/xcframework/xcframework_build.rb
92
99
  - lib/cocoapods-util/gem_version.rb
93
- - lib/cocoapods-util/hooks/feature_switch.rb
94
- - lib/cocoapods-util/hooks/installer.rb
95
- - lib/cocoapods-util/hooks/prebuild_sandbox.rb
96
100
  - lib/cocoapods-util/tool.rb
97
101
  - lib/cocoapods_plugin.rb
98
102
  homepage: https://github.com/CaryGo/cocoapods-util
@@ -1,63 +0,0 @@
1
- module CocoapodsUtilHook
2
- Pod::HooksManager.register('cocoapods-util', :pre_install) do |installer_context, _|
3
- puts "pre_install"
4
- require_relative 'hooks/feature_switch'
5
- if Pod.is_prebuild_stage
6
- next
7
- end
8
-
9
- # [Check Environment]
10
- podfile = installer_context.podfile
11
- # podfile.target_definition_list.each do |target_definition|
12
- # # next if target_definition.prebuild_framework_pod_names.empty?
13
- # # if not target_definition.uses_frameworks?
14
- # # STDERR.puts "[!] Cocoapods-binary requires `use_frameworks!`".red
15
- # # exit
16
- # # end
17
- # end
18
-
19
- require_relative 'hooks/prebuild_sandbox'
20
-
21
- # 读取update和repo_update参数
22
- update = nil
23
- repo_update = nil
24
- include ObjectSpace
25
- ObjectSpace.each_object(Pod::Installer) { |installer|
26
- update = installer.update
27
- repo_update = installer.repo_update
28
- }
29
-
30
- # switches setting
31
- Pod.is_prebuild_stage = true
32
-
33
- # make another custom sandbox
34
- standard_sandbox = installer_context.sandbox
35
- prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
36
-
37
- # get the podfile for prebuild
38
- prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
39
-
40
- # install
41
- lockfile = installer_context.lockfile
42
- binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
43
-
44
- binary_installer.update = update
45
- binary_installer.repo_update = repo_update
46
- # binary_installer.install!
47
-
48
- # reset switches setting
49
- Pod.is_prebuild_stage = false
50
- end
51
- Pod::HooksManager.register('cocoapods-util', :pre_integrate) do |context, _|
52
- puts "pre_integrate"
53
- end
54
- Pod::HooksManager.register('cocoapods-util', :post_install) do |context, _|
55
- puts "post_install"
56
- end
57
- Pod::HooksManager.register('cocoapods-util', :post_integrate) do |context, _|
58
- puts "post_integrate"
59
- end
60
- Pod::HooksManager.register('cocoapods-util', :source_provider) do |context, _|
61
- puts "source_provider"
62
- end
63
- end
@@ -1,3 +0,0 @@
1
- module Pod
2
- class_attr_accessor :is_prebuild_stage
3
- end
@@ -1,4 +0,0 @@
1
- module Pod
2
- class Installer < Command
3
- end
4
- end
@@ -1,14 +0,0 @@
1
- module Pod
2
- class PrebuildSandbox < Sandbox
3
-
4
- # [String] standard_sandbox_path
5
- def self.from_standard_sanbox_path(path)
6
- prebuild_sandbox_path = Pathname.new(path).realpath + "_Prebuild"
7
- self.new(prebuild_sandbox_path)
8
- end
9
-
10
- def self.from_standard_sandbox(sandbox)
11
- self.from_standard_sanbox_path(sandbox.root)
12
- end
13
- end
14
- end