cocoapods-generator-minlison 0.1.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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +98 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +13 -0
- data/Resoures/After.png +0 -0
- data/Resoures/Before.png +0 -0
- data/cocoapods-generator-minlison.gemspec +25 -0
- data/lib/cocoapods-generator-minlison/command/generator.rb +367 -0
- data/lib/cocoapods-generator-minlison/command.rb +1 -0
- data/lib/cocoapods-generator-minlison/gem_version.rb +3 -0
- data/lib/cocoapods-generator-minlison.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/generator_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 844dd20d928ff4efe80869d5a692b3da5b63acefbcccf24757f86d2bb7558259
|
4
|
+
data.tar.gz: d441dcbaecb5ab74eea97c5ba74395e7428f290c8f92fd2aa48e6e0358a64e08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3df3dc90537c713fcf823da8c94e5b4a322e1431977faf7f6fef8a91e6ec90bf59252901803c17226d4c5592b43cb6374bfe562c2d8d574ac8bf82d35b0e666c
|
7
|
+
data.tar.gz: 43b0e2a62d789e91627d7b85e57ea4d1650c8285ce936d9747f09ab88e560c754d1cae1c723f50cf49bdb0b7d7552076f49d4916300ee4bea2955c8d374f30d1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-generator-minlison (0.0.1)
|
5
|
+
cocoapods
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
CFPropertyList (3.0.0)
|
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
|
+
atomos (0.1.3)
|
17
|
+
bacon (1.2.0)
|
18
|
+
claide (1.0.2)
|
19
|
+
cocoapods (1.7.4)
|
20
|
+
activesupport (>= 4.0.2, < 5)
|
21
|
+
claide (>= 1.0.2, < 2.0)
|
22
|
+
cocoapods-core (= 1.7.4)
|
23
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
24
|
+
cocoapods-downloader (>= 1.2.2, < 2.0)
|
25
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
26
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
27
|
+
cocoapods-stats (>= 1.0.0, < 2.0)
|
28
|
+
cocoapods-trunk (>= 1.3.1, < 2.0)
|
29
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
30
|
+
colored2 (~> 3.1)
|
31
|
+
escape (~> 0.0.4)
|
32
|
+
fourflusher (>= 2.3.0, < 3.0)
|
33
|
+
gh_inspector (~> 1.0)
|
34
|
+
molinillo (~> 0.6.6)
|
35
|
+
nap (~> 1.0)
|
36
|
+
ruby-macho (~> 1.4)
|
37
|
+
xcodeproj (>= 1.10.0, < 2.0)
|
38
|
+
cocoapods-core (1.7.4)
|
39
|
+
activesupport (>= 4.0.2, < 6)
|
40
|
+
fuzzy_match (~> 2.0.4)
|
41
|
+
nap (~> 1.0)
|
42
|
+
cocoapods-deintegrate (1.0.4)
|
43
|
+
cocoapods-downloader (1.2.2)
|
44
|
+
cocoapods-plugins (1.0.0)
|
45
|
+
nap
|
46
|
+
cocoapods-search (1.0.0)
|
47
|
+
cocoapods-stats (1.1.0)
|
48
|
+
cocoapods-trunk (1.3.1)
|
49
|
+
nap (>= 0.8, < 2.0)
|
50
|
+
netrc (~> 0.11)
|
51
|
+
cocoapods-try (1.1.0)
|
52
|
+
colored2 (3.1.2)
|
53
|
+
concurrent-ruby (1.1.5)
|
54
|
+
escape (0.0.4)
|
55
|
+
fourflusher (2.3.1)
|
56
|
+
fuzzy_match (2.0.4)
|
57
|
+
gh_inspector (1.1.3)
|
58
|
+
i18n (0.9.5)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
metaclass (0.0.4)
|
61
|
+
minitest (5.11.3)
|
62
|
+
mocha (1.9.0)
|
63
|
+
metaclass (~> 0.0.1)
|
64
|
+
mocha-on-bacon (0.2.3)
|
65
|
+
mocha (>= 0.13.0)
|
66
|
+
molinillo (0.6.6)
|
67
|
+
nanaimo (0.2.6)
|
68
|
+
nap (1.1.0)
|
69
|
+
netrc (0.11.0)
|
70
|
+
prettybacon (0.0.2)
|
71
|
+
bacon (~> 1.2)
|
72
|
+
rake (12.3.2)
|
73
|
+
ruby-macho (1.4.0)
|
74
|
+
thread_safe (0.3.6)
|
75
|
+
tzinfo (1.2.5)
|
76
|
+
thread_safe (~> 0.1)
|
77
|
+
xcodeproj (1.11.0)
|
78
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
79
|
+
atomos (~> 0.1.3)
|
80
|
+
claide (>= 1.0.2, < 2.0)
|
81
|
+
colored2 (~> 3.1)
|
82
|
+
nanaimo (~> 0.2.6)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
ruby
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
bacon
|
89
|
+
bundler
|
90
|
+
cocoapods
|
91
|
+
cocoapods-generator-minlison!
|
92
|
+
mocha
|
93
|
+
mocha-on-bacon
|
94
|
+
prettybacon
|
95
|
+
rake
|
96
|
+
|
97
|
+
BUNDLED WITH
|
98
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 从权 <chaoyang.zcy@alibaba-inc.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# cocoapods-generator
|
2
|
+
|
3
|
+
Now, you can add files to empty target with *.podspec, while config it, such as souce files, libraries, frameworks, resources and so on.
|
4
|
+
|
5
|
+
**Before use this command:**
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
**After use this command:**
|
10
|
+
|
11
|
+

|
12
|
+
Then you can see source files, vendored framework, resouce files which at current directory will be added to the target.
|
13
|
+
|
14
|
+
In the future, the future when no target name same as project will generate a target will be developed, then config it with *.podspec at current directory.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
$ gem install cocoapods-generator
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
$ pod generator spec_name
|
23
|
+
|
24
|
+
Add source files to existed project, which from podspec at current directory.
|
25
|
+
Please Be Careful:
|
26
|
+
* Please make sure the **target** to be added equal to **spec_name**, else a target with spec_name will be created.
|
27
|
+
* Please make sure project name same to spec_name, else can't find *.xcodeproj file.
|
data/Rakefile
ADDED
data/Resoures/After.png
ADDED
Binary file
|
data/Resoures/Before.png
ADDED
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-generator-minlison/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-generator-minlison'
|
8
|
+
spec.version = CocoapodsGenerator::VERSION
|
9
|
+
spec.authors = ['从权','yuanhang']
|
10
|
+
spec.email = ['chaoyang.zcy@alibaba-inc.com', 'yuanhang.1991@icloud.com']
|
11
|
+
spec.description = %q{Config empty target with configuration from *.podspec.}
|
12
|
+
spec.summary = %q{add files to empty target from *.podspec, such as souce files, libraries, frameworks, resources and so on.}
|
13
|
+
spec.homepage = 'https://github.com/Minlison/cocoapods-generator.git'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency "cocoapods"
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
@@ -0,0 +1,367 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
4
|
+
# to the 'pod' command.
|
5
|
+
#
|
6
|
+
# You can also create subcommands of existing or new commands. Say you
|
7
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
8
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
9
|
+
# to change.
|
10
|
+
#
|
11
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
12
|
+
# the class to exist in the the Pod::Command::List namespace
|
13
|
+
# - change this class to extend from `List` instead of `Command`. This
|
14
|
+
# tells the plugin system that it is a subcommand of `list`.
|
15
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
16
|
+
#
|
17
|
+
|
18
|
+
class GeneratorProj < Command
|
19
|
+
self.summary = 'add source files to project from podspec.'
|
20
|
+
|
21
|
+
self.description = <<-DESC
|
22
|
+
Add source files to existed project, which from podspec at current directory.
|
23
|
+
Please Be Careful:
|
24
|
+
1. Please make sure the **target** to be added equal to spec_name, else
|
25
|
+
a target with spec_name will be created.
|
26
|
+
2. Please make sure project name same to spec_name, else can't find *.xcodeproj file.
|
27
|
+
DESC
|
28
|
+
|
29
|
+
self.arguments = [CLAide::Argument.new('spec_name', true)]
|
30
|
+
|
31
|
+
|
32
|
+
SPEC_SUBGROUPS = {
|
33
|
+
:resources => 'Resources',
|
34
|
+
:frameworks => 'Frameworks',
|
35
|
+
}
|
36
|
+
|
37
|
+
ENABLE_OBJECT_USE_OBJC_FROM = {
|
38
|
+
:ios => Version.new('6'),
|
39
|
+
:osx => Version.new('10.8'),
|
40
|
+
:watchos => Version.new('2.0'),
|
41
|
+
:tvos => Version.new('9.0'),
|
42
|
+
}
|
43
|
+
|
44
|
+
SOURCE_FILE_EXTENSIONS = Sandbox::FileAccessor::SOURCE_FILE_EXTENSIONS
|
45
|
+
|
46
|
+
def initialize(argv)
|
47
|
+
@spec_name = argv.shift_argument
|
48
|
+
@current_path = Dir.pwd
|
49
|
+
@spec_path = @current_path + '/' + @spec_name if @current_path && @spec_name
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
def validate!
|
54
|
+
super
|
55
|
+
|
56
|
+
if @spec_name.nil? || File.extname(@spec_name) != ".podspec"
|
57
|
+
help! 'A *.podspec file is required.'
|
58
|
+
Process.exit! false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
create_spec_content
|
64
|
+
validatePodspec
|
65
|
+
install
|
66
|
+
end
|
67
|
+
|
68
|
+
def validatePodspec
|
69
|
+
linter = Specification::Linter.new(@spec_path)
|
70
|
+
linter.lint
|
71
|
+
results = []
|
72
|
+
results.concat(linter.results.to_a)
|
73
|
+
puts results_message results
|
74
|
+
end
|
75
|
+
|
76
|
+
def results_message(results)
|
77
|
+
message = ''
|
78
|
+
results.each do |result|
|
79
|
+
if result.platforms == [:ios]
|
80
|
+
platform_message = '[iOS] '
|
81
|
+
elsif result.platforms == [:osx]
|
82
|
+
platform_message = '[OSX] '
|
83
|
+
elsif result.platforms == [:watchos]
|
84
|
+
platform_message = '[watchOS] '
|
85
|
+
elsif result.platforms == [:tvos]
|
86
|
+
platform_message = '[tvOS] '
|
87
|
+
end
|
88
|
+
|
89
|
+
subspecs_message = ''
|
90
|
+
if result.is_a?(Result)
|
91
|
+
subspecs = result.subspecs.uniq
|
92
|
+
if subspecs.count > 2
|
93
|
+
subspecs_message = '[' + subspecs[0..2].join(', ') + ', and more...] '
|
94
|
+
elsif subspecs.count > 0
|
95
|
+
subspecs_message = '[' + subspecs.join(',') + '] '
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
case result.type
|
100
|
+
when :error then type = 'ERROR'
|
101
|
+
when :warning then type = 'WARN'
|
102
|
+
when :note then type = 'NOTE'
|
103
|
+
else raise "#{result.type}" end
|
104
|
+
message << " - #{type.ljust(5)} | #{platform_message}#{subspecs_message}#{result.attribute_name}: #{result.message}\n"
|
105
|
+
end
|
106
|
+
message << "\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
def create_spec_content
|
110
|
+
@spec_content = Specification::from_file @spec_path
|
111
|
+
end
|
112
|
+
|
113
|
+
def xcodeproj_path
|
114
|
+
project_path = File.expand_path File.basename(@spec_name, ".podspec") + '.xcodeproj', @current_path
|
115
|
+
if !File.exists? project_path
|
116
|
+
help! "Please make sure has #{File.basename project_path} in current directory."
|
117
|
+
Process.exit! false
|
118
|
+
end
|
119
|
+
project_path
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_framework_target_to_Xcodeproject
|
123
|
+
project_path = xcodeproj_path
|
124
|
+
podspec_consumer = consumer
|
125
|
+
platform_name = consumer.platform_name
|
126
|
+
deployment_target = podspec_consumer.spec.deployment platform_name
|
127
|
+
target_name = @spec_name
|
128
|
+
app_project = xcodeproj::Project.open project_path
|
129
|
+
app_project.new_target('static_framework', target_name, platform_name, deployment_target)
|
130
|
+
app_project.save
|
131
|
+
app_project.recreate_user_schemes
|
132
|
+
Xcodeproj::XCScheme.share_scheme(app_project.path, target_name)
|
133
|
+
end
|
134
|
+
|
135
|
+
def install
|
136
|
+
project_path = xcodeproj_path
|
137
|
+
@app_project = Xcodeproj::Project.open(project_path)
|
138
|
+
@framework_target = @app_project.targets.find { |target| target.name == @spec_content.name }
|
139
|
+
|
140
|
+
create_file_accessors
|
141
|
+
add_source_files_references
|
142
|
+
add_frameworks_bundles
|
143
|
+
add_vendored_libraries
|
144
|
+
add_resources
|
145
|
+
|
146
|
+
add_files_to_build_phases
|
147
|
+
add_libraries_to_build_phases
|
148
|
+
|
149
|
+
@app_project.save
|
150
|
+
end
|
151
|
+
|
152
|
+
def create_file_accessors
|
153
|
+
[@framework_target].each do |target|
|
154
|
+
|
155
|
+
path_list = Sandbox::PathList.new(Pathname.new(Dir.new(@current_path)))
|
156
|
+
specs = [@spec_content]
|
157
|
+
specs.concat @spec_content.subspecs
|
158
|
+
platform = Platform.new(target.platform_name, target.deployment_target)
|
159
|
+
@file_accessors = specs.map do |spec|
|
160
|
+
file_accessor = Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
|
161
|
+
file_accessor
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def add_source_files_references
|
167
|
+
add_file_accessors_paths_to_group(:source_files)
|
168
|
+
end
|
169
|
+
|
170
|
+
def add_frameworks_bundles
|
171
|
+
add_file_accessors_paths_to_group(:vendored_frameworks, :frameworks)
|
172
|
+
end
|
173
|
+
|
174
|
+
def add_vendored_libraries
|
175
|
+
add_file_accessors_paths_to_group(:vendored_libraries, :frameworks)
|
176
|
+
end
|
177
|
+
|
178
|
+
def add_resources
|
179
|
+
add_file_accessors_paths_to_group(:resources, :resources)
|
180
|
+
add_file_accessors_paths_to_group(:resource_bundle_files, :resources)
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_file_accessors_paths_to_group(file_accessor_key, group_key = nil)
|
184
|
+
@file_accessors.each do |file_accessor|
|
185
|
+
pod_name = file_accessor.spec.name
|
186
|
+
paths = file_accessor.send(file_accessor_key)
|
187
|
+
paths = allowable_project_paths(paths)
|
188
|
+
paths.each do |path|
|
189
|
+
if !@app_project.reference_for_path(path)
|
190
|
+
relative_pathname = path.relative_path_from(Pathname.new(@current_path))
|
191
|
+
relative_dir = relative_pathname.dirname
|
192
|
+
lproj_regex = /\.lproj/i
|
193
|
+
group = group_for_spec(file_accessor.spec.name, group_key)
|
194
|
+
relative_dir.each_filename do|name|
|
195
|
+
break if name.to_s =~ lproj_regex
|
196
|
+
next if name == '.'
|
197
|
+
group = group[name] || group.new_group(name)
|
198
|
+
end
|
199
|
+
|
200
|
+
file_path_name = path.is_a?(Pathname) ? path : Pathname.new(path)
|
201
|
+
ref = group.new_file(file_path_name.realpath)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def group_for_spec(spec_name, subgroup_key = nil)
|
208
|
+
if subgroup_key
|
209
|
+
group_name = SPEC_SUBGROUPS[subgroup_key]
|
210
|
+
else
|
211
|
+
group_name = spec_name
|
212
|
+
end
|
213
|
+
|
214
|
+
@app_project[group_name] || @app_project.new_group(group_name)
|
215
|
+
end
|
216
|
+
|
217
|
+
def allowable_project_paths(paths)
|
218
|
+
lproj_paths = Set.new
|
219
|
+
lproj_paths_with_files = Set.new
|
220
|
+
allowable_paths = paths.select do |path|
|
221
|
+
path_str = path.to_s
|
222
|
+
|
223
|
+
# We add the directory for a Core Data model, but not the items in it.
|
224
|
+
next if path_str =~ /.*\.xcdatamodeld\/.+/i
|
225
|
+
|
226
|
+
# We add the directory for a Core Data migration mapping, but not the items in it.
|
227
|
+
next if path_str =~ /.*\.xcmappingmodel\/.+/i
|
228
|
+
|
229
|
+
# We add the directory for an asset catalog, but not the items in it.
|
230
|
+
next if path_str =~ /.*\.xcassets\/.+/i
|
231
|
+
|
232
|
+
if path_str =~ /\.lproj(\/|$)/i
|
233
|
+
# If the element is an .lproj directory then save it and potentially
|
234
|
+
# add it later if we don't find any contained items.
|
235
|
+
if path_str =~ /\.lproj$/i && path.directory?
|
236
|
+
lproj_paths << path
|
237
|
+
next
|
238
|
+
end
|
239
|
+
|
240
|
+
# Collect the paths for the .lproj directories that contain files.
|
241
|
+
lproj_path = /(^.*\.lproj)\/.*/i.match(path_str)[1]
|
242
|
+
lproj_paths_with_files << Pathname(lproj_path)
|
243
|
+
|
244
|
+
# Directories nested within an .lproj directory are added as file
|
245
|
+
# system references so their contained items are not added directly.
|
246
|
+
next if path.dirname.dirname == lproj_path
|
247
|
+
end
|
248
|
+
|
249
|
+
true
|
250
|
+
end
|
251
|
+
|
252
|
+
# Only add the path for the .lproj directories that do not have anything
|
253
|
+
# within them added as well. This generally happens if the glob within the
|
254
|
+
# resources directory was not a recursive glob.
|
255
|
+
allowable_paths + lproj_paths.subtract(lproj_paths_with_files).to_a
|
256
|
+
end
|
257
|
+
|
258
|
+
def add_files_to_build_phases
|
259
|
+
@file_accessors.each do |file_accessor|
|
260
|
+
consumer = file_accessor.spec_consumer
|
261
|
+
|
262
|
+
headers = file_accessor.headers
|
263
|
+
public_headers = file_accessor.public_headers
|
264
|
+
private_headers = file_accessor.private_headers
|
265
|
+
other_source_files = file_accessor.source_files.reject { |sf| SOURCE_FILE_EXTENSIONS.include?(sf.extname) }
|
266
|
+
|
267
|
+
{
|
268
|
+
true => file_accessor.arc_source_files,
|
269
|
+
false => file_accessor.non_arc_source_files,
|
270
|
+
}.each do |arc, files|
|
271
|
+
files = files - headers - other_source_files
|
272
|
+
flags = compiler_flags_for_consumer(consumer, arc)
|
273
|
+
regular_file_refs = files.map { |sf| @app_project.reference_for_path(sf) }
|
274
|
+
@framework_target.add_file_references(regular_file_refs, flags)
|
275
|
+
end
|
276
|
+
|
277
|
+
header_file_refs = headers.map { |sf| @app_project.reference_for_path(sf) }
|
278
|
+
@framework_target.add_file_references(header_file_refs) do |build_file|
|
279
|
+
add_header(build_file, public_headers, private_headers)
|
280
|
+
end
|
281
|
+
|
282
|
+
other_file_refs = other_source_files.map { |sf| @app_project.reference_for_path(sf) }
|
283
|
+
@framework_target.add_file_references(other_file_refs, nil)
|
284
|
+
|
285
|
+
resource_refs = file_accessor.resources.flatten.map do |res|
|
286
|
+
@app_project.reference_for_path(res)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Some nested files are not directly present in the Xcode project, such as the contents
|
290
|
+
# of an .xcdatamodeld directory. These files will return nil file references.
|
291
|
+
resource_refs.compact!
|
292
|
+
|
293
|
+
@framework_target.add_resources(resource_refs)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def add_libraries_to_build_phases
|
298
|
+
file_accessor = @file_accessors.first
|
299
|
+
@framework_target.add_system_framework(file_accessor.spec_consumer.frameworks)
|
300
|
+
@framework_target.add_system_library(file_accessor.spec_consumer.libraries)
|
301
|
+
|
302
|
+
add_vendored_library_to_build_phases(:vendored_frameworks)
|
303
|
+
add_vendored_library_to_build_phases(:vendored_libraries)
|
304
|
+
end
|
305
|
+
|
306
|
+
def add_vendored_library_to_build_phases(sourcekey)
|
307
|
+
file_accessor = @file_accessors.first
|
308
|
+
file_accessor.send(sourcekey).each do |path|
|
309
|
+
ref = @app_project.reference_for_path(path)
|
310
|
+
if ref
|
311
|
+
@framework_target.frameworks_build_phase.add_file_reference(ref)
|
312
|
+
else
|
313
|
+
help! "#{path.basename} no added to project!!"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def add_header(build_file, public_headers, private_headers)
|
319
|
+
file_ref = build_file.file_ref
|
320
|
+
acl = if public_headers.include?(file_ref.real_path)
|
321
|
+
'Public'
|
322
|
+
elsif private_headers.include?(file_ref.real_path)
|
323
|
+
'Private'
|
324
|
+
else
|
325
|
+
'Project'
|
326
|
+
end
|
327
|
+
|
328
|
+
if header_mappings_dir && acl != 'Project'
|
329
|
+
relative_path = file_ref.real_path.relative_path_from(header_mappings_dir)
|
330
|
+
sub_dir = relative_path.dirname
|
331
|
+
copy_phase_name = "Copy #{sub_dir} #{acl} Headers"
|
332
|
+
copy_phase = native_target.copy_files_build_phases.find { |bp| bp.name == copy_phase_name } ||
|
333
|
+
native_target.new_copy_files_build_phase(copy_phase_name)
|
334
|
+
copy_phase.symbol_dst_subfolder_spec = :products_directory
|
335
|
+
copy_phase.dst_path = "$(#{acl.upcase}_HEADERS_FOLDER_PATH)/#{sub_dir}"
|
336
|
+
copy_phase.add_file_reference(file_ref, true)
|
337
|
+
else
|
338
|
+
build_file.settings ||= {}
|
339
|
+
build_file.settings['ATTRIBUTES'] = [acl]
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
def compiler_flags_for_consumer(consumer, arc)
|
344
|
+
flags = consumer.compiler_flags.dup
|
345
|
+
if !arc
|
346
|
+
flags << '-fno-objc-arc'
|
347
|
+
else
|
348
|
+
platform_name = consumer.platform_name
|
349
|
+
spec_deployment_target = consumer.spec.deployment_target(platform_name)
|
350
|
+
if spec_deployment_target.nil? || Version.new(spec_deployment_target) < ENABLE_OBJECT_USE_OBJC_FROM[platform_name]
|
351
|
+
flags << '-DOS_OBJECT_USE_OBJC=0'
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
flags * ' '
|
356
|
+
end
|
357
|
+
|
358
|
+
def header_mappings_dir
|
359
|
+
file_accessor = @file_accessors.first
|
360
|
+
header_mappings_dir = if dir = file_accessor.spec_consumer.header_mappings_dir
|
361
|
+
file_accessor.path_list.root + dir
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-generator-minlison/command/generator'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-generator-minlison/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-generator-minlison/command'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe Command::Generator do
|
5
|
+
describe 'CLAide' do
|
6
|
+
it 'registers it self' do
|
7
|
+
Command.parse(%w{ generator }).should.be.instance_of Command::Generator
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-generator-minlison
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 从权
|
8
|
+
- yuanhang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cocoapods
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: Config empty target with configuration from *.podspec.
|
57
|
+
email:
|
58
|
+
- chaoyang.zcy@alibaba-inc.com
|
59
|
+
- yuanhang.1991@icloud.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- Resoures/After.png
|
71
|
+
- Resoures/Before.png
|
72
|
+
- cocoapods-generator-minlison.gemspec
|
73
|
+
- lib/cocoapods-generator-minlison.rb
|
74
|
+
- lib/cocoapods-generator-minlison/command.rb
|
75
|
+
- lib/cocoapods-generator-minlison/command/generator.rb
|
76
|
+
- lib/cocoapods-generator-minlison/gem_version.rb
|
77
|
+
- lib/cocoapods_plugin.rb
|
78
|
+
- spec/command/generator_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: https://github.com/Minlison/cocoapods-generator.git
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.0.4
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: add files to empty target from *.podspec, such as souce files, libraries,
|
103
|
+
frameworks, resources and so on.
|
104
|
+
test_files:
|
105
|
+
- spec/command/generator_spec.rb
|
106
|
+
- spec/spec_helper.rb
|