cocoapods-no-autoimports 0.1.0 → 0.2.0
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 +4 -4
- data/.gitignore +1 -1
- data/README.md +11 -1
- data/lib/cocoapods-no-autoimports/plugin/version.rb +1 -1
- data/lib/cocoapods-no-autoimports/plugin.rb +145 -33
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 007f7c44899093750c77a74c4165d9f944a4026cbfb0c0c119f43f6853d66da4
|
4
|
+
data.tar.gz: 68c5404f1830ad99234c93384817ea00e7b598cb9f098722839a29b1ea4bfab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550272b7381631f0480bb63f8a13181a4757ce0db3862320e1b30eb68c23776a73f0b76d9b463596fe456873f150b70b77f03b30aa60d080f34ca909a8a52fb5
|
7
|
+
data.tar.gz: f3e1ec72e3aa7e30148a75805a63acda3b49c2ae6453ad45b22129833be1f197c6b7dea774a8c3429585d5fb2dc0c4b2a045f9c7b6fd56ac515ecd6369e0c2b8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Cocoapods no autoimports
|
1
|
+
# 🙅♂️ Cocoapods no autoimports
|
2
2
|
|
3
3
|
A cocoapods plugin that let's you hook in generating umbrella and prefix headers for pods. And remove autoimports of
|
4
4
|
1. `UIKit`.h
|
@@ -16,8 +16,12 @@ gem 'cocoapods-no-autoimports'
|
|
16
16
|
Add this line to your Podfile:
|
17
17
|
```ruby
|
18
18
|
plugin 'cocoapods-no-autoimports'
|
19
|
+
# cocoapods-no-autoimports__pods = ['YourPod__Core', 'YourPod__UI']
|
19
20
|
```
|
20
21
|
|
22
|
+
The plugin will parse the Podfile and look for `cocoapods-no-autoimports__pods` key.
|
23
|
+
Make sure to list your pods to which you want to apply plugin to in `cocoapods-no-autoimports__pods` array. It got to be comment in 1 line.
|
24
|
+
|
21
25
|
Execute:
|
22
26
|
|
23
27
|
$ bundle install
|
@@ -32,3 +36,9 @@ Done! Now go and check your Xcode build erros 😁
|
|
32
36
|
## License
|
33
37
|
|
34
38
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
39
|
+
|
40
|
+
## Additional Info
|
41
|
+
|
42
|
+
* This gem is distributed via [RubyGems.org](https://rubygems.org/gems/cocoapods-no-autoimports)
|
43
|
+
* Special thanks to [Keith's](https://github.com/keith/cocoapods-foundation-headers/tree/master) repo got me started
|
44
|
+
* This [ticket](https://github.com/CocoaPods/CocoaPods/issues/6815) was the problem for us as well so I decided to built a plugin
|
@@ -1,37 +1,149 @@
|
|
1
1
|
module Pod
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
result
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
2
|
+
module Generator
|
3
|
+
class Header
|
4
|
+
|
5
|
+
# Make array of pods from Podfile to which a plugin should be applied to
|
6
|
+
def makePodsArrayToApplyPlugin
|
7
|
+
result = []
|
8
|
+
# open file and read contents
|
9
|
+
podfile = File.read(Config.instance.podfile_path).lines
|
10
|
+
key = "cocoapods-no-autoimports__pods"
|
11
|
+
|
12
|
+
podfile.each do |line|
|
13
|
+
if line.include?(key)
|
14
|
+
array_content = line.match(/\[(.*)\]/)[1]
|
15
|
+
array_content = array_content.gsub("'", "").split(",").map(&:strip)
|
16
|
+
result = array_content
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
# Removed the following lines:
|
24
|
+
# result << "#ifdef __OBJC__\n"
|
25
|
+
# result << generate_platform_import_header
|
26
|
+
# result << "#else\n"
|
27
|
+
# result << "#endif\n"
|
28
|
+
def generate_without_platform_imports
|
29
|
+
result = ""
|
30
|
+
result << "#ifndef FOUNDATION_EXPORT\n"
|
31
|
+
result << "#if defined(__cplusplus)\n"
|
32
|
+
result << "#define FOUNDATION_EXPORT extern \"C\"\n"
|
33
|
+
result << "#else\n"
|
34
|
+
result << "#define FOUNDATION_EXPORT extern\n"
|
35
|
+
result << "#endif\n"
|
36
|
+
result << "#endif\n"
|
37
|
+
result << "\n"
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
def generate_platform_imports
|
42
|
+
result = ""
|
43
|
+
result << "#ifdef __OBJC__\n"
|
44
|
+
result << generate_platform_import_header
|
45
|
+
result << "#else\n"
|
46
|
+
result << "#ifndef FOUNDATION_EXPORT\n"
|
47
|
+
result << "#if defined(__cplusplus)\n"
|
48
|
+
result << "#define FOUNDATION_EXPORT extern \"C\"\n"
|
49
|
+
result << "#else\n"
|
50
|
+
result << "#define FOUNDATION_EXPORT extern\n"
|
51
|
+
result << "#endif\n"
|
52
|
+
result << "#endif\n"
|
53
|
+
result << "#endif\n"
|
54
|
+
result << "\n"
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate(should_import_platforms: true)
|
59
|
+
result = ""
|
60
|
+
if should_import_platforms
|
61
|
+
result = generate_platform_imports
|
62
|
+
else
|
63
|
+
result = generate_without_platform_imports
|
64
|
+
end
|
65
|
+
|
66
|
+
imports.each do |import|
|
67
|
+
result << %(#import "#{import}"\n)
|
68
|
+
end
|
69
|
+
|
70
|
+
unless module_imports.empty?
|
71
|
+
module_imports.each do |import|
|
72
|
+
result << %(\n@import #{import})
|
34
73
|
end
|
74
|
+
result << "\n"
|
75
|
+
end
|
76
|
+
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class UmbrellaHeader < Header
|
82
|
+
|
83
|
+
# Generates the contents of the umbrella header according to the included
|
84
|
+
# pods.
|
85
|
+
#
|
86
|
+
# @return [String]
|
87
|
+
#
|
88
|
+
def generate
|
89
|
+
pods_to_apply_plugin = makePodsArrayToApplyPlugin
|
90
|
+
matched_target = pods_to_apply_plugin.include?(target.name)
|
91
|
+
if matched_target
|
92
|
+
result = super(should_import_platforms: false)
|
93
|
+
else
|
94
|
+
result = super
|
95
|
+
end
|
96
|
+
|
97
|
+
if matched_target
|
98
|
+
puts "✍️ Applying cocoapods-no-autoimports plugin to #{target.name}"
|
99
|
+
end
|
100
|
+
|
101
|
+
result << "\n"
|
102
|
+
|
103
|
+
result << <<-eos.strip_heredoc
|
104
|
+
FOUNDATION_EXPORT double #{target.product_module_name}VersionNumber;
|
105
|
+
FOUNDATION_EXPORT const unsigned char #{target.product_module_name}VersionString[];
|
106
|
+
eos
|
107
|
+
|
108
|
+
result << "\n"
|
109
|
+
|
110
|
+
result
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class PrefixHeader < Header
|
115
|
+
def generate
|
116
|
+
spec_names = file_accessors.map { |accessor| accessor.spec.name }
|
117
|
+
pods_to_apply_plugin = makePodsArrayToApplyPlugin
|
118
|
+
matched_target = false
|
119
|
+
|
120
|
+
spec_names.each do |spec_name|
|
121
|
+
if pods_to_apply_plugin.include?(spec_name)
|
122
|
+
matched_target = true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if matched_target
|
127
|
+
result = super(should_import_platforms: false)
|
128
|
+
else
|
129
|
+
result = super
|
130
|
+
end
|
131
|
+
|
132
|
+
unique_prefix_header_contents = file_accessors.map do |file_accessor|
|
133
|
+
file_accessor.spec_consumer.prefix_header_contents
|
134
|
+
end.compact.uniq
|
135
|
+
|
136
|
+
unique_prefix_header_contents.each do |prefix_header_contents|
|
137
|
+
result << prefix_header_contents
|
138
|
+
result << "\n"
|
139
|
+
end
|
140
|
+
|
141
|
+
file_accessors.map(&:prefix_header).compact.uniq.each do |prefix_header|
|
142
|
+
result << Pathname(prefix_header).read
|
143
|
+
end
|
144
|
+
|
145
|
+
result
|
35
146
|
end
|
36
147
|
end
|
37
|
-
end
|
148
|
+
end
|
149
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-no-autoimports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Glushko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.4.10
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: A CocoaPods plugin for removing autoimported [UIKit/Cocoa/Foundation] headers.
|