cocoapods-fix-module 0.0.7 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/DEMO/Podfile ADDED
@@ -0,0 +1,30 @@
1
+ # 建议使用 bundle exec pod install 代替 pod install,可以统一相关 ruby gem 的版本
2
+ platform :ios, '9.0'
3
+ #use_frameworks!
4
+ # add additional config here
5
+
6
+ require 'bd_pod_extentions'
7
+ # 使用组件源(必要)
8
+ # bd_pod_extentions 更多介绍 https://mobile.bytedance.net/docs/manual/17033/
9
+ bd_use_app('public', 'thirdParty')
10
+
11
+ # 全部使用源代码
12
+ #bd_use_source!
13
+
14
+
15
+ # 静态库下使用 module (使可以在 swift 代码里直接 import PodName)
16
+ use_modular_headers!
17
+ plugin 'cocoapods-fix-module' # 修复 objc binary pod 在 use_modular_headers 时仍没有 module 的问题
18
+
19
+
20
+
21
+
22
+ target 'DEMO' do
23
+
24
+ # add pod here
25
+ pod_binary 'lottie-ios' , '2.1.5'
26
+ pod_binary 'Masonry', '1.1.0'
27
+ # pod 'Literal', path: '~/byte/test/Literal2'
28
+
29
+
30
+ end
data/DEMO/Podfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PODS:
2
+ - lottie-ios (2.1.5.1-binary)
3
+ - Masonry (1.1.0.1-binary)
4
+
5
+ DEPENDENCIES:
6
+ - lottie-ios (= 2.1.5.1-binary)
7
+ - Masonry (= 1.1.0.1-binary)
8
+
9
+ SPEC REPOS:
10
+ "git@code.byted.org:iOS_Library/publicthird_binary_repo.git":
11
+ - lottie-ios
12
+ - Masonry
13
+
14
+ SPEC CHECKSUMS:
15
+ lottie-ios: f2b8cad625e57b90974a282efac4fce375ba3860
16
+ Masonry: c9cef972c6546901fe6e8900688ffa5e55175005
17
+
18
+ PODFILE CHECKSUM: 2802dd81cd0910852de0997259f9bf8681f0ccef
19
+
20
+ COCOAPODS: 1.8.3
data/Gemfile.lock ADDED
@@ -0,0 +1,105 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-fix-module (0.1.1)
5
+ cocoapods (>= 1.6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ CFPropertyList (3.0.1)
11
+ activesupport (4.2.11.1)
12
+ i18n (~> 0.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ algoliasearch (1.27.1)
17
+ httpclient (~> 2.8, >= 2.8.3)
18
+ json (>= 1.5.1)
19
+ atomos (0.1.3)
20
+ bacon (1.2.0)
21
+ claide (1.0.3)
22
+ cocoapods (1.8.1)
23
+ activesupport (>= 4.0.2, < 5)
24
+ claide (>= 1.0.2, < 2.0)
25
+ cocoapods-core (= 1.8.1)
26
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
27
+ cocoapods-downloader (>= 1.2.2, < 2.0)
28
+ cocoapods-plugins (>= 1.0.0, < 2.0)
29
+ cocoapods-search (>= 1.0.0, < 2.0)
30
+ cocoapods-stats (>= 1.0.0, < 2.0)
31
+ cocoapods-trunk (>= 1.4.0, < 2.0)
32
+ cocoapods-try (>= 1.1.0, < 2.0)
33
+ colored2 (~> 3.1)
34
+ escape (~> 0.0.4)
35
+ fourflusher (>= 2.3.0, < 3.0)
36
+ gh_inspector (~> 1.0)
37
+ molinillo (~> 0.6.6)
38
+ nap (~> 1.0)
39
+ ruby-macho (~> 1.4)
40
+ xcodeproj (>= 1.11.1, < 2.0)
41
+ cocoapods-core (1.8.1)
42
+ activesupport (>= 4.0.2, < 6)
43
+ algoliasearch (~> 1.0)
44
+ concurrent-ruby (~> 1.1)
45
+ fuzzy_match (~> 2.0.4)
46
+ nap (~> 1.0)
47
+ cocoapods-deintegrate (1.0.4)
48
+ cocoapods-downloader (1.2.2)
49
+ cocoapods-plugins (1.0.0)
50
+ nap
51
+ cocoapods-search (1.0.0)
52
+ cocoapods-stats (1.1.0)
53
+ cocoapods-trunk (1.4.1)
54
+ nap (>= 0.8, < 2.0)
55
+ netrc (~> 0.11)
56
+ cocoapods-try (1.1.0)
57
+ colored2 (3.1.2)
58
+ concurrent-ruby (1.1.5)
59
+ escape (0.0.4)
60
+ fourflusher (2.3.1)
61
+ fuzzy_match (2.0.4)
62
+ gh_inspector (1.1.3)
63
+ httpclient (2.8.3)
64
+ i18n (0.9.5)
65
+ concurrent-ruby (~> 1.0)
66
+ json (2.2.0)
67
+ metaclass (0.0.4)
68
+ minitest (5.12.2)
69
+ mocha (1.9.0)
70
+ metaclass (~> 0.0.1)
71
+ mocha-on-bacon (0.2.3)
72
+ mocha (>= 0.13.0)
73
+ molinillo (0.6.6)
74
+ nanaimo (0.2.6)
75
+ nap (1.1.0)
76
+ netrc (0.11.0)
77
+ prettybacon (0.0.2)
78
+ bacon (~> 1.2)
79
+ rake (13.0.0)
80
+ ruby-macho (1.4.0)
81
+ thread_safe (0.3.6)
82
+ tzinfo (1.2.5)
83
+ thread_safe (~> 0.1)
84
+ xcodeproj (1.12.0)
85
+ CFPropertyList (>= 2.3.3, < 4.0)
86
+ atomos (~> 0.1.3)
87
+ claide (>= 1.0.2, < 2.0)
88
+ colored2 (~> 3.1)
89
+ nanaimo (~> 0.2.6)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ bacon
96
+ bundler
97
+ cocoapods
98
+ cocoapods-fix-module!
99
+ mocha
100
+ mocha-on-bacon
101
+ prettybacon
102
+ rake
103
+
104
+ BUNDLED WITH
105
+ 2.0.2
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_runtime_dependency 'cocoapods', '>= 1.6.0'
24
24
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsFixModule
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,20 @@
1
+
2
+
3
+ # 目前的改法对于 1.7 / 1.8,是没有考虑 app spec 的东西的,所以显示不支持
4
+ Pod::HooksManager.register('cocoapods-fix-module', :post_install) do |installer_context|
5
+ pod_name = nil
6
+ has_app_spec = installer_context.umbrella_targets.any? do |umbrella_target|
7
+ umbrella_target.specs.any? do |spec|
8
+ if spec.app_specs.length > 0
9
+ pod_name = spec.name
10
+ next true
11
+ end
12
+ end
13
+ end
14
+ if has_app_spec
15
+ puts "[!] ERROR: Plugin cocoapods-fix-module, doesn't supports pods whose spec contain app_spec. Invalid pods: #{pod_name}".red
16
+ puts "Reference: https://guides.cocoapods.org/syntax/podspec.html#app_spec".red
17
+ puts "Install failed !!".red
18
+ exit 1
19
+ end
20
+ end
@@ -9,31 +9,13 @@
9
9
  #
10
10
  # We fix it by changing the `install!` method:
11
11
  #
12
- # when a pod is (target.should_build? == true && target.uses_modular_headers?),
12
+ # when a pod is (target.should_build? == true && target.define_module?),
13
13
  # we treat it differently: like normal pods,
14
14
  # - create_umbrella_header
15
15
  # - create_module_map
16
16
  #
17
17
 
18
- module Pod
19
- class PodTarget
20
-
21
- def contain_vendored_libraries_and_no_vendored_frameworks?
22
- return @uses_libraries_no_frameworks if defined? @uses_libraries_no_frameworks
23
- @uses_libraries_no_frameworks = begin
24
- accessors = file_accessors.reject { |a| a.spec.test_specification? }
25
- !accessors.empty? && accessors.all?{ |a| a.vendored_frameworks.blank? } && accessors.any?{ |a| not a.vendored_libraries.blank? }
26
- end
27
- end
28
-
29
- def should_generate_module_map_for_a_pod_should_not_build?
30
- @should_generate_module_map_for_a_pod_should_not_build ||= begin
31
- self.uses_modular_headers? && contain_vendored_libraries_and_no_vendored_frameworks?
32
- end
33
- end
34
-
35
- end
36
- end
18
+ require_relative 'patch_common'
37
19
 
38
20
  module Pod
39
21
  class Installer
@@ -49,6 +31,7 @@ module Pod
49
31
  # special handling for pod with no source code
50
32
 
51
33
  # Most code below are copied from original install! method
34
+ # Manually checked the 1.6.0/ 1.6.1, they are all the same. So it's safe.
52
35
  native_target = add_target
53
36
  _, file_accessors = target.file_accessors.partition { |fa| fa.spec.test_specification? }
54
37
  resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten
@@ -108,45 +91,4 @@ end
108
91
 
109
92
 
110
93
 
111
- module Pod
112
- class Target
113
- # @since 1.5.0
114
- class BuildSettings
115
-
116
- class PodTargetSettings
117
-
118
- # Patch (because there is a should_build? check)
119
- #
120
- FIX_MODULE_OLD_module_map_file_to_import = instance_method(:module_map_file_to_import)
121
- define_method(:module_map_file_to_import) do
122
-
123
- if (not target.should_build?) && target.should_generate_module_map_for_a_pod_should_not_build?
124
- # ---- Code bellow is copied form the original method ----
125
- #
126
- # ---------------- this line is deleted ------------------
127
- # return unless target.should_build?
128
- # -------------------------------------------------------
129
- #
130
- return if target.requires_frameworks?
131
- return unless target.defines_module?
132
-
133
- if target.uses_swift?
134
- # for swift, we have a custom build phase that copies in the module map, appending the .Swift module
135
- "${PODS_CONFIGURATION_BUILD_DIR}/#{target.label}/#{target.product_module_name}.modulemap"
136
- else
137
- "${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}"
138
- end
139
- # ---- Code above is copied form the original method ----
140
- else
141
- # call original
142
- FIX_MODULE_OLD_module_map_file_to_import.bind(self).()
143
- end
144
-
145
- end # patch ended
146
-
147
- end
148
-
149
- end
150
- end
151
- end
152
94
 
@@ -0,0 +1,95 @@
1
+
2
+ #
3
+ # REASON:
4
+ #
5
+ # When a pod only have vendored library, and the 'use_modular_header' is on, cocoapods won't
6
+ # generate a modulemap (so module is not working), because it consider it as "should_build? == false".
7
+ #
8
+ # It's a bug of cocoapods.
9
+ #
10
+ # We fix it by changing the `install!` method:
11
+ #
12
+ # when a pod is (target.should_build? == true && target.define_module?),
13
+ # we treat it differently: like normal pods,
14
+ # - create_umbrella_header
15
+ # - create_module_map
16
+ #
17
+
18
+ require_relative 'patch_common'
19
+ require_relative 'hint_no_app_target_support'
20
+
21
+ module Pod
22
+ class Installer
23
+ class Xcode
24
+ class PodsProjectGenerator
25
+ class PodTargetInstaller
26
+
27
+
28
+ FIX_MODULE_OLD_install = instance_method(:install!)
29
+ define_method(:install!) do
30
+
31
+ if (not target.should_build?) && target.should_generate_module_map_for_a_pod_should_not_build?
32
+ # special handling for pod with no source code
33
+
34
+ # Most code below are copied from original install! method
35
+ # Manually checked the 1.7.0 ~ 1.7.5, they are all the same. So it's safe.
36
+ native_target = add_target
37
+ library_file_accessors = target.file_accessors.select { |fa| fa.spec.library_specification? }
38
+ resource_bundle_targets = add_resources_bundle_targets(library_file_accessors).values.flatten
39
+ create_xcconfig_file(native_target, resource_bundle_targets)
40
+
41
+ if target.defines_module?
42
+ create_module_map(native_target) do |generator|
43
+ generator.headers.concat module_map_additional_headers
44
+ end
45
+ create_umbrella_header(native_target) do |generator|
46
+ generator.imports += library_file_accessors.flat_map do |file_accessor|
47
+ header_dir = if !target.build_as_framework? && dir = file_accessor.spec_consumer.header_dir
48
+ Pathname.new(dir)
49
+ end
50
+
51
+ file_accessor.public_headers.map do |public_header|
52
+ public_header = if header_mappings_dir
53
+ public_header.relative_path_from(header_mappings_dir)
54
+ else
55
+ public_header.basename
56
+ end
57
+ if header_dir
58
+ public_header = header_dir.join(public_header)
59
+ end
60
+ public_header
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+ if target.build_as_framework?
68
+ unless skip_info_plist?(native_target)
69
+ create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
70
+ end
71
+ create_build_phase_to_symlink_header_folders(native_target)
72
+ end
73
+
74
+ if target.build_as_library? && target.uses_swift?
75
+ add_swift_library_compatibility_header_phase(native_target)
76
+ end
77
+
78
+ clean_support_files_temp_dir
79
+ TargetInstallationResult.new(target, native_target, resource_bundle_targets)
80
+
81
+
82
+ else
83
+ # call original
84
+ FIX_MODULE_OLD_install.bind(self).()
85
+ end
86
+
87
+ end # patch ended
88
+
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+
@@ -0,0 +1,95 @@
1
+
2
+ #
3
+ # REASON:
4
+ #
5
+ # When a pod only have vendored library, and the 'use_modular_header' is on, cocoapods won't
6
+ # generate a modulemap (so module is not working), because it consider it as "should_build? == false".
7
+ #
8
+ # It's a bug of cocoapods.
9
+ #
10
+ # We fix it by changing the `install!` method:
11
+ #
12
+ # when a pod is (target.should_build? == true && target.define_module?),
13
+ # we treat it differently: like normal pods,
14
+ # - create_umbrella_header
15
+ # - create_module_map
16
+ #
17
+
18
+ require_relative 'patch_common'
19
+ require_relative 'hint_no_app_target_support'
20
+
21
+ module Pod
22
+ class Installer
23
+ class Xcode
24
+ class PodsProjectGenerator
25
+ class PodTargetInstaller
26
+
27
+
28
+ FIX_MODULE_OLD_install = instance_method(:install!)
29
+ define_method(:install!) do
30
+
31
+ if (not target.should_build?) && target.should_generate_module_map_for_a_pod_should_not_build?
32
+ # special handling for pod with no source code
33
+
34
+ # Most code below are copied from original install! method
35
+ # Manually checked the 1.8.1/ 1.8.3, they are all the same. So it's safe.
36
+ native_target = add_target
37
+ library_file_accessors = target.file_accessors.select { |fa| fa.spec.library_specification? }
38
+ resource_bundle_targets = add_resources_bundle_targets(library_file_accessors).values.flatten
39
+ create_xcconfig_file(native_target, resource_bundle_targets)
40
+
41
+ if target.defines_module?
42
+ create_module_map(native_target) do |generator|
43
+ generator.headers.concat module_map_additional_headers
44
+ end
45
+ create_umbrella_header(native_target) do |generator|
46
+ generator.imports += library_file_accessors.flat_map do |file_accessor|
47
+ header_dir = if !target.build_as_framework? && dir = file_accessor.spec_consumer.header_dir
48
+ Pathname.new(dir)
49
+ end
50
+
51
+ file_accessor.public_headers.map do |public_header|
52
+ public_header = if header_mappings_dir(file_accessor)
53
+ public_header.relative_path_from(header_mappings_dir(file_accessor))
54
+ else
55
+ public_header.basename
56
+ end
57
+ if header_dir
58
+ public_header = header_dir.join(public_header)
59
+ end
60
+ public_header
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+ if target.build_as_framework?
68
+ unless skip_info_plist?(native_target)
69
+ create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform, :additional_entries => target.info_plist_entries)
70
+ end
71
+ create_build_phase_to_symlink_header_folders(native_target)
72
+ end
73
+
74
+ if target.build_as_library? && target.uses_swift?
75
+ add_swift_library_compatibility_header_phase(native_target)
76
+ end
77
+
78
+ clean_support_files_temp_dir
79
+ TargetInstallationResult.new(target, native_target, resource_bundle_targets)
80
+
81
+
82
+ else
83
+ # call original
84
+ FIX_MODULE_OLD_install.bind(self).()
85
+ end
86
+
87
+ end # patch ended
88
+
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+