cocoapods-fix-module 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 2c8cc782f3225da99e9859a9e3e2de9266121d88
4
- data.tar.gz: 1cdf07f68c9c9507d8991824c8cc8956192d10fd
3
+ metadata.gz: 7b8a1bd8d8eaf1ca31e5ecbfab3fe0ba8e210829
4
+ data.tar.gz: 7ce1d7156c9c52d113bc1ee2e321cf92793a9525
5
5
  SHA512:
6
- metadata.gz: ab443fe71711f43b4fd48afabc149f7c526f98ddbf0c5e65020c776fc8252184cb69c676035ca9c93cf7a495920a8f17ef63c92b43215e6de8b208558f73c1ab
7
- data.tar.gz: 3040ef64c06268aaa6ac5a49889353cadbdb4f15c5d4ea5e9cdf450238048aba5ac15ccc0babcb2b8205e0b144e062272733aad4d56dfe3ffb56d69376594800
6
+ metadata.gz: fe1229733fa16a9bc1c908060ef2161e05b38889b0ee1759a85e48e62bfd6f1c6a138145420fe42ff728c7f9ff6108f529033a5c3507bde8893cd295efc99b28
7
+ data.tar.gz: 9501100d321a09e59a65c58a8ac06d5ced5d5f58f6d0e91443f248abdb1480f9eb7fb11e8c178de85629d8e8f3955007b1f3ee1933deb90f9f8f1ae190478220
@@ -1,3 +1,3 @@
1
1
  module CocoapodsFixModule
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -2,78 +2,155 @@
2
2
  #
3
3
  # REASON:
4
4
  #
5
- # When a pod only have vendored library, and the 'use_modular_header' is on, cocoapods won't
5
+ # When a pod only have vendored library, and the 'use_modular_header' is on, cocoapods won't
6
6
  # generate a modulemap (so module is not working), beacause it consider it as "should_build? == false".
7
7
  #
8
8
  # It's a bug of cocoapods.
9
9
  #
10
- # We fix it by patch the should_build? method.
11
- # When should_build? == true, it will add
12
- # - dummy_source file to compile
13
- # - prefix header
14
- # - modulemap file
15
- # - link the library, set the OTHER_SWIFT_FLAG (to use module -fmodule-map-file)
10
+ # We fix it by changing the `install!` method:
11
+ #
12
+ # when a pod is (target.should_build? == true && target.uses_modular_headers?),
13
+ # we treat it differently: like nomarl pods,
14
+ # - create_umbrella_header
15
+ # - create_module_map
16
+ #
16
17
  #
17
18
  module Pod
18
- class PodTarget
19
-
20
- # when using modular header, should_build? should return YES
21
- alias_method :FIX_MODULE_old_should_build? , :should_build?
22
- def should_build?
23
- return @FIX_MODULE_saved_should_build if defined? @FIX_MODULE_saved_should_build
24
- if uses_modular_headers?
25
- @FIX_MODULE_saved_should_build = true
26
- return @FIX_MODULE_saved_should_build
27
- else
28
- return FIX_MODULE_old_should_build?()
29
- end
30
- end
19
+ class Installer
20
+ class Xcode
21
+ class PodsProjectGenerator
22
+ class PodTargetInstaller
23
+
24
+
25
+ FIX_MODULE_OLD_install = instance_method(:install!)
26
+ define_method(:install!) do
27
+
28
+ if (not target.should_build?) && target.send(:uses_modular_headers?)
29
+ # special handling for pod with no source code
30
+
31
+ # Most code below are copied from original install! method
32
+ native_target = add_target
33
+ _, file_accessors = target.file_accessors.partition { |fa| fa.spec.test_specification? }
34
+ resource_bundle_targets = add_resources_bundle_targets(file_accessors).values.flatten
35
+ create_xcconfig_file(native_target, resource_bundle_targets)
36
+
37
+ if target.defines_module?
38
+ create_module_map(native_target) do |generator|
39
+ generator.headers.concat module_map_additional_headers
40
+ end
41
+ create_umbrella_header(native_target) do |generator|
42
+ generator.imports += file_accessors.flat_map do |file_accessor|
43
+ header_dir = if !target.requires_frameworks? && dir = file_accessor.spec_consumer.header_dir
44
+ Pathname.new(dir)
45
+ end
46
+
47
+ file_accessor.public_headers.map do |public_header|
48
+ public_header = if header_mappings_dir
49
+ public_header.relative_path_from(header_mappings_dir)
50
+ else
51
+ public_header.basename
52
+ end
53
+ if header_dir
54
+ public_header = header_dir.join(public_header)
55
+ end
56
+ public_header
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ if target.requires_frameworks?
63
+ unless skip_info_plist?(native_target)
64
+ create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
65
+ end
66
+ create_build_phase_to_symlink_header_folders(native_target)
67
+ elsif target.uses_swift?
68
+ add_swift_static_library_compatibility_header_phase(native_target)
69
+ end
70
+
71
+
72
+ clean_support_files_temp_dir
73
+ TargetInstallationResult.new(target, native_target, resource_bundle_targets)
74
+
75
+
76
+ else
77
+ # call original
78
+ FIX_MODULE_OLD_install.bind(self).()
79
+ end
31
80
 
81
+ end # patch ended
32
82
 
83
+ end
84
+ end
33
85
  end
86
+ end
34
87
  end
35
88
 
36
89
 
37
- # Vendored library whill usually have the same name with the pod name,
38
- # so the .a file may have a confict name, as the dummy source will create a .a file
39
- # We override the dummy .a file's name
40
- # NOTE: it will affect all the lib name generated by cocoapods
90
+
41
91
  module Pod
42
- class Target
43
- def static_library_name
44
- "lib#{label}_fixModule.a"
92
+ class Target
93
+ # @since 1.5.0
94
+ class BuildSettings
95
+
96
+ class PodTargetSettings
97
+
98
+ # Patch (because there is a shuld_build? check)
99
+ #
100
+ FIX_MODULE_OLD_module_map_file_to_import = instance_method(:module_map_file_to_import)
101
+ define_method(:module_map_file_to_import) do
102
+
103
+ if (not target.should_build?) && target.send(:uses_modular_headers?)
104
+ # ---- Code bellow is copied form the original method ----
105
+ #
106
+ # ---------------- this line is deleted ------------------
107
+ # return unless target.should_build?
108
+ # -------------------------------------------------------
109
+ #
110
+ return if target.requires_frameworks?
111
+ return unless target.defines_module?
112
+
113
+ if target.uses_swift?
114
+ # for swift, we have a custom build phase that copies in the module map, appending the .Swift module
115
+ "${PODS_CONFIGURATION_BUILD_DIR}/#{target.label}/#{target.product_module_name}.modulemap"
116
+ else
117
+ "${PODS_ROOT}/#{target.module_map_path.relative_path_from(target.sandbox.root)}"
118
+ end
119
+ # ---- Code above is copied form the original method ----
120
+ else
121
+ # call original
122
+ FIX_MODULE_OLD_module_map_file_to_import.bind(self).()
123
+ end
124
+
125
+ end # patch ended
126
+
45
127
  end
128
+
46
129
  end
130
+ end
47
131
  end
48
132
 
49
133
 
134
+
135
+
50
136
  # Depress the checking
51
- # Beacuse the target have no source to build even when should_build? == true,
137
+ # Because the target have no source to build even when should_build? == true,
52
138
  # which break the validation.
53
139
  module Pod
54
140
  class Installer
55
141
  class Xcode
56
142
  class PodsProjectGenerator
57
143
  class PodTargetInstaller
58
-
59
- def validate_targets_contain_sources(args)
60
- # do nothing
61
- end
144
+
145
+ def validate_targets_contain_sources(args)
146
+ # do nothing
147
+ end
62
148
 
63
149
  end
150
+ end
64
151
  end
65
152
  end
66
153
  end
67
- end
68
154
 
69
- # skip creating dummy source if no build files
70
- # FIX_MODULE_old_create_dummy_source = instance_method(:create_dummy_source)
71
- # define_method(:create_dummy_source) do |native_target|
72
-
73
- # if not target.FIX_MODULE_old_should_build?
74
- # # when nothing to build, don't create dummy source
75
- # else
76
- # FIX_MODULE_old_create_dummy_source.bind(self).(native_target)
77
- # end
78
- # end
79
-
155
+
156
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-fix-module
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-07 00:00:00.000000000 Z
11
+ date: 2019-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler