cocoapods-generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +85 -0
- data/LICENSE.txt +22 -0
- data/README.md +17 -0
- data/Rakefile +13 -0
- data/Resoures/After.png +0 -0
- data/Resoures/Before.png +0 -0
- data/cocoapods-generator.gemspec +25 -0
- data/lib/cocoapods-generator.rb +1 -0
- data/lib/cocoapods-generator/command.rb +1 -0
- data/lib/cocoapods-generator/command/generator.rb +367 -0
- data/lib/cocoapods-generator/gem_version.rb +3 -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
|
+
SHA1:
|
3
|
+
metadata.gz: eb6cc23bacbcf5a6d8054480dff783d77251b2e9
|
4
|
+
data.tar.gz: a88014fd0723addf11de5ff5269f7c8b92b14423
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33f9331a744d4b81c4d85e501a0ca4d3bc10e78c3cfa1577e84d763dd6c56d9fecfa4ce349a822cabfba0e4bca80b639f99a0d93af5822f86ac766ecd88c119e
|
7
|
+
data.tar.gz: cbedd4f39a4f31064978b2293b2e87b3f9b2ed3a9f6a48e14f9296a75f7760e7d6f29a97cfd180f6b634d8cfb3604a07f7e837d98d8d2e807352e8d67122c042
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-generator (0.0.1)
|
5
|
+
cocoapods (>= 0.38.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (4.2.5.1)
|
11
|
+
i18n (~> 0.7)
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
bacon (1.2.0)
|
17
|
+
claide (0.9.1)
|
18
|
+
cocoapods (0.39.0)
|
19
|
+
activesupport (>= 4.0.2)
|
20
|
+
claide (~> 0.9.1)
|
21
|
+
cocoapods-core (= 0.39.0)
|
22
|
+
cocoapods-downloader (~> 0.9.3)
|
23
|
+
cocoapods-plugins (~> 0.4.2)
|
24
|
+
cocoapods-search (~> 0.1.0)
|
25
|
+
cocoapods-stats (~> 0.6.2)
|
26
|
+
cocoapods-trunk (~> 0.6.4)
|
27
|
+
cocoapods-try (~> 0.5.1)
|
28
|
+
colored (~> 1.2)
|
29
|
+
escape (~> 0.0.4)
|
30
|
+
molinillo (~> 0.4.0)
|
31
|
+
nap (~> 1.0)
|
32
|
+
xcodeproj (~> 0.28.2)
|
33
|
+
cocoapods-core (0.39.0)
|
34
|
+
activesupport (>= 4.0.2)
|
35
|
+
fuzzy_match (~> 2.0.4)
|
36
|
+
nap (~> 1.0)
|
37
|
+
cocoapods-downloader (0.9.3)
|
38
|
+
cocoapods-plugins (0.4.2)
|
39
|
+
nap
|
40
|
+
cocoapods-search (0.1.0)
|
41
|
+
cocoapods-stats (0.6.2)
|
42
|
+
cocoapods-trunk (0.6.4)
|
43
|
+
nap (>= 0.8, < 2.0)
|
44
|
+
netrc (= 0.7.8)
|
45
|
+
cocoapods-try (0.5.1)
|
46
|
+
colored (1.2)
|
47
|
+
escape (0.0.4)
|
48
|
+
fuzzy_match (2.0.4)
|
49
|
+
i18n (0.7.0)
|
50
|
+
json (1.8.3)
|
51
|
+
metaclass (0.0.4)
|
52
|
+
minitest (5.8.4)
|
53
|
+
mocha (1.1.0)
|
54
|
+
metaclass (~> 0.0.1)
|
55
|
+
mocha-on-bacon (0.2.2)
|
56
|
+
mocha (>= 0.13.0)
|
57
|
+
molinillo (0.4.3)
|
58
|
+
nap (1.1.0)
|
59
|
+
netrc (0.7.8)
|
60
|
+
prettybacon (0.0.2)
|
61
|
+
bacon (~> 1.2)
|
62
|
+
rake (10.5.0)
|
63
|
+
thread_safe (0.3.5)
|
64
|
+
tzinfo (1.2.2)
|
65
|
+
thread_safe (~> 0.1)
|
66
|
+
xcodeproj (0.28.2)
|
67
|
+
activesupport (>= 3)
|
68
|
+
claide (~> 0.9.1)
|
69
|
+
colored (~> 1.2)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
bacon
|
76
|
+
bundler (~> 1.3)
|
77
|
+
cocoapods
|
78
|
+
cocoapods-generator!
|
79
|
+
mocha
|
80
|
+
mocha-on-bacon
|
81
|
+
prettybacon
|
82
|
+
rake
|
83
|
+
|
84
|
+
BUNDLED WITH
|
85
|
+
1.11.2
|
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,17 @@
|
|
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
|
+
![Before use this command](./Resoures/Before)
|
5
|
+
![After use this command](./Resoures/After)
|
6
|
+
|
7
|
+
Next, when no target name same as project will generate a target, then config it with *.podspec at current directory.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install cocoapods-generator
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
$ pod spec generator *.podspec
|
16
|
+
Please run this command at project root directory, then a target will be configed,
|
17
|
+
which name same as project name.
|
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/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-generator'
|
8
|
+
spec.version = CocoapodsGenerator::VERSION
|
9
|
+
spec.authors = ['从权']
|
10
|
+
spec.email = ['chaoyang.zcy@alibaba-inc.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/zhzhy/cocoapods-generator'
|
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", "~> 0.39"
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-generator/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-generator/command/generator'
|
@@ -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 Generator < 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/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
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 从权
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.39'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.39'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Config empty target with configuration from *.podspec.
|
56
|
+
email:
|
57
|
+
- chaoyang.zcy@alibaba-inc.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- Resoures/After.png
|
69
|
+
- Resoures/Before.png
|
70
|
+
- cocoapods-generator.gemspec
|
71
|
+
- lib/cocoapods-generator.rb
|
72
|
+
- lib/cocoapods-generator/command.rb
|
73
|
+
- lib/cocoapods-generator/command/generator.rb
|
74
|
+
- lib/cocoapods-generator/gem_version.rb
|
75
|
+
- lib/cocoapods_plugin.rb
|
76
|
+
- spec/command/generator_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/zhzhy/cocoapods-generator
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.5.1
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: add files to empty target from *.podspec, such as souce files, libraries,
|
102
|
+
frameworks, resources and so on.
|
103
|
+
test_files:
|
104
|
+
- spec/command/generator_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
has_rdoc:
|