cocoapods-packager-mls 1.5.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +5 -0
- data/.rubocop-cocoapods.yml +71 -0
- data/.rubocop.yml +38 -0
- data/.travis.yml +17 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +131 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +29 -0
- data/cocoapods-packager.gemspec +22 -0
- data/lib/cocoapods-packager/builder.rb +457 -0
- data/lib/cocoapods-packager/framework.rb +66 -0
- data/lib/cocoapods-packager/mangle.rb +32 -0
- data/lib/cocoapods-packager/pod_utils.rb +324 -0
- data/lib/cocoapods-packager/spec_builder.rb +171 -0
- data/lib/cocoapods-packager/symbols.rb +42 -0
- data/lib/cocoapods-packager/tal_installer.rb +33 -0
- data/lib/cocoapods-packager/tal_target_validator.rb +62 -0
- data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
- data/lib/cocoapods_packager.rb +5 -0
- data/lib/cocoapods_plugin.rb +16 -0
- data/lib/pod/command/package.rb +243 -0
- data/scripts/lstconst.sh +9 -0
- data/scripts/lstsym.sh +8 -0
- data/spec/command/error_spec.rb +81 -0
- data/spec/command/package_spec.rb +420 -0
- data/spec/command/subspecs_spec.rb +30 -0
- data/spec/fixtures/Archs.podspec +13 -0
- data/spec/fixtures/Builder.podspec +25 -0
- data/spec/fixtures/CPDColors.podspec +19 -0
- data/spec/fixtures/FH.podspec +18 -0
- data/spec/fixtures/KFData.podspec +73 -0
- data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
- data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
- data/spec/fixtures/LibraryDemo.podspec +14 -0
- data/spec/fixtures/LocalSources/LICENSE +0 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
- data/spec/fixtures/NikeKit.podspec +19 -0
- data/spec/fixtures/OpenSans.podspec +18 -0
- data/spec/fixtures/PackagerTest/.gitignore +21 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
- data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
- data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
- data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
- data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
- data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
- data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
- data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
- data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
- data/spec/fixtures/PackagerTest/Podfile +10 -0
- data/spec/fixtures/PackagerTest/Podfile.lock +36 -0
- data/spec/fixtures/Weakly.podspec +13 -0
- data/spec/fixtures/a.podspec +19 -0
- data/spec/fixtures/foo-bar.podspec +19 -0
- data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
- data/spec/integration/project_spec.rb +70 -0
- data/spec/spec_helper.rb +79 -0
- data/spec/unit/pod/utils_spec.rb +58 -0
- data/spec/unit/specification/builder_spec.rb +62 -0
- data/spec/unit/specification/spec_builder_spec.rb +61 -0
- data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
- metadata +223 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
module Framework
|
2
|
+
class Tree
|
3
|
+
attr_reader :headers_path
|
4
|
+
attr_reader :module_map_path
|
5
|
+
attr_reader :resources_path
|
6
|
+
attr_reader :root_path
|
7
|
+
attr_reader :versions_path
|
8
|
+
|
9
|
+
def delete_resources
|
10
|
+
Pathname.new(@resources_path).rmtree
|
11
|
+
(Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(name, platform, embedded)
|
15
|
+
@name = name
|
16
|
+
@platform = platform
|
17
|
+
@embedded = embedded
|
18
|
+
end
|
19
|
+
|
20
|
+
def make
|
21
|
+
make_root
|
22
|
+
make_framework
|
23
|
+
make_headers
|
24
|
+
make_resources
|
25
|
+
make_current_version
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def make_current_version
|
31
|
+
current_version_path = @versions_path + Pathname.new('../Current')
|
32
|
+
`ln -sf A #{current_version_path}`
|
33
|
+
`ln -sf Versions/Current/Headers #{@fwk_path}/`
|
34
|
+
`ln -sf Versions/Current/Resources #{@fwk_path}/`
|
35
|
+
`ln -sf Versions/Current/#{@name} #{@fwk_path}/`
|
36
|
+
end
|
37
|
+
|
38
|
+
def make_framework
|
39
|
+
@fwk_path = @root_path + Pathname.new(@name + '.framework')
|
40
|
+
@fwk_path.mkdir unless @fwk_path.exist?
|
41
|
+
|
42
|
+
@module_map_path = @fwk_path + Pathname.new('Modules')
|
43
|
+
@versions_path = @fwk_path + Pathname.new('Versions/A')
|
44
|
+
end
|
45
|
+
|
46
|
+
def make_headers
|
47
|
+
@headers_path = @versions_path + Pathname.new('Headers')
|
48
|
+
@headers_path.mkpath unless @headers_path.exist?
|
49
|
+
end
|
50
|
+
|
51
|
+
def make_resources
|
52
|
+
@resources_path = @versions_path + Pathname.new('Resources')
|
53
|
+
@resources_path.mkpath unless @resources_path.exist?
|
54
|
+
end
|
55
|
+
|
56
|
+
def make_root
|
57
|
+
@root_path = Pathname.new(@platform)
|
58
|
+
|
59
|
+
if @embedded
|
60
|
+
@root_path += Pathname.new('embedded')
|
61
|
+
end
|
62
|
+
|
63
|
+
@root_path.mkpath unless @root_path.exist?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Symbols
|
2
|
+
#
|
3
|
+
# performs symbol aliasing
|
4
|
+
#
|
5
|
+
# for each dependency:
|
6
|
+
# - determine symbols for classes and global constants
|
7
|
+
# - alias each symbol to Pod#{pod_name}_#{symbol}
|
8
|
+
# - put defines into `GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode
|
9
|
+
#
|
10
|
+
def mangle_for_pod_dependencies(pod_name, sandbox_root)
|
11
|
+
pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do |file|
|
12
|
+
file !~ /lib#{pod_name}.a$/
|
13
|
+
end
|
14
|
+
|
15
|
+
dummy_alias = alias_symbol "PodsDummy_#{pod_name}", pod_name
|
16
|
+
all_syms = [dummy_alias]
|
17
|
+
|
18
|
+
pod_libs.each do |pod_lib|
|
19
|
+
syms = Symbols.symbols_from_library(pod_lib)
|
20
|
+
all_syms += syms.map! { |sym| alias_symbol sym, pod_name }
|
21
|
+
end
|
22
|
+
|
23
|
+
"GCC_PREPROCESSOR_DEFINITIONS='$(inherited) #{all_syms.uniq.join(' ')}'"
|
24
|
+
end
|
25
|
+
|
26
|
+
def alias_symbol(sym, pod_name)
|
27
|
+
pod_name = pod_name.tr('-', '_')
|
28
|
+
sym + "=Pod#{pod_name}_" + sym
|
29
|
+
end
|
30
|
+
|
31
|
+
module_function :mangle_for_pod_dependencies, :alias_symbol
|
32
|
+
end
|
@@ -0,0 +1,324 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Package < Command
|
4
|
+
private
|
5
|
+
|
6
|
+
def build_static_sandbox(dynamic)
|
7
|
+
static_sandbox_root = if dynamic
|
8
|
+
Pathname.new(config.sandbox_root + '/Static')
|
9
|
+
else
|
10
|
+
Pathname.new(config.sandbox_root)
|
11
|
+
end
|
12
|
+
Sandbox.new(static_sandbox_root)
|
13
|
+
end
|
14
|
+
|
15
|
+
def install_pod(platform_name, sandbox)
|
16
|
+
podfile = podfile_from_spec(
|
17
|
+
@path,
|
18
|
+
@spec.name,
|
19
|
+
platform_name,
|
20
|
+
@spec.deployment_target(platform_name),
|
21
|
+
@subspecs,
|
22
|
+
@spec_sources,
|
23
|
+
@local_sources
|
24
|
+
)
|
25
|
+
|
26
|
+
static_installer = TalInstaller.new(sandbox, podfile, @auto_fix_conflict)
|
27
|
+
static_installer.install!
|
28
|
+
|
29
|
+
unless static_installer.nil?
|
30
|
+
static_installer.pods_project.targets.each do |target|
|
31
|
+
target.build_configurations.each do |config|
|
32
|
+
config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
|
33
|
+
config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
static_installer.pods_project.save
|
37
|
+
end
|
38
|
+
|
39
|
+
static_installer
|
40
|
+
end
|
41
|
+
|
42
|
+
def podfile_from_spec(path, spec_name, platform_name, deployment_target, subspecs, sources, local_sources)
|
43
|
+
options = {}
|
44
|
+
if path
|
45
|
+
if @local
|
46
|
+
options[:path] = path
|
47
|
+
else
|
48
|
+
options[:podspec] = path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
options[:subspecs] = subspecs if subspecs
|
52
|
+
generator = self
|
53
|
+
spec_file = @spec
|
54
|
+
source_dir = @source_dir
|
55
|
+
|
56
|
+
Pod::Podfile.new do
|
57
|
+
sources.each { |s| source s }
|
58
|
+
platform(platform_name, deployment_target)
|
59
|
+
# 此处会自动增加非本地依赖项
|
60
|
+
pod(spec_name, options)
|
61
|
+
# plugin('cocoapods-packager', {})
|
62
|
+
# plugin 查看 cocoapods_plugin.rb 文件内定义
|
63
|
+
|
64
|
+
# 增加本地 local source
|
65
|
+
generator.transitive_local_dependencies(spec_file, local_sources).each do |dependency, podspec_file|
|
66
|
+
pod_options = {}
|
67
|
+
pod_options[:path] = if podspec_file[0] == '/' # absolute path
|
68
|
+
Pathname.new(podspec_file)
|
69
|
+
else
|
70
|
+
expand_path = File.expand_path(podspec_file,source_dir)
|
71
|
+
Pathname.new(expand_path)
|
72
|
+
end
|
73
|
+
pod dependency.name, **pod_options
|
74
|
+
end
|
75
|
+
|
76
|
+
install!('cocoapods',
|
77
|
+
:integrate_targets => false,
|
78
|
+
:deterministic_uuids => false)
|
79
|
+
|
80
|
+
target('packager') do
|
81
|
+
inherit! :complete
|
82
|
+
end
|
83
|
+
|
84
|
+
post_install do |installer|
|
85
|
+
#设置build setting
|
86
|
+
installer.pods_project.targets.each do |target|
|
87
|
+
target.build_configurations.each do |config|
|
88
|
+
config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
|
89
|
+
config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
public
|
98
|
+
|
99
|
+
def recursive_subspecs_dependencies(spec)
|
100
|
+
|
101
|
+
dependencies = [@spec, *@spec.recursive_subspecs].flat_map do |all_spec|
|
102
|
+
all_spec.dependencies.flat_map do |depency|
|
103
|
+
depency if ! "#{depency}".include? "#{spec.name}"
|
104
|
+
end
|
105
|
+
end.compact.uniq
|
106
|
+
# puts dependencies
|
107
|
+
|
108
|
+
# dependencies = spec.dependencies || []
|
109
|
+
# spec.recursive_subspecs.each do |subspec|
|
110
|
+
# subspec.dependencies.each do |depency|
|
111
|
+
# if ! "#{depency}".include? "#{spec.name}"
|
112
|
+
# dependencies << depency
|
113
|
+
# end
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
dependencies
|
117
|
+
end
|
118
|
+
|
119
|
+
def transitive_local_dependencies(spec, paths)
|
120
|
+
dependencies = recursive_subspecs_dependencies(spec)
|
121
|
+
return_list = []
|
122
|
+
dependencies.each do |dependency|
|
123
|
+
found_podspec_file = nil
|
124
|
+
name = dependency.name.split('/')[0]
|
125
|
+
paths.each do |path|
|
126
|
+
# 展开目录
|
127
|
+
if path[0] != '/'
|
128
|
+
path = File.expand_path(path, @source_dir)
|
129
|
+
end
|
130
|
+
podspec_file = path + '/' + name + '.podspec'
|
131
|
+
next unless File.file?(podspec_file)
|
132
|
+
found_podspec_file = podspec_file
|
133
|
+
break
|
134
|
+
end
|
135
|
+
next unless found_podspec_file
|
136
|
+
return_list << [dependency, found_podspec_file]
|
137
|
+
dep_spec = Pod::Specification.from_file(found_podspec_file)
|
138
|
+
dep_spec.dependencies.each do |d_dep|
|
139
|
+
dependencies << d_dep unless dependencies.include? d_dep
|
140
|
+
end
|
141
|
+
end
|
142
|
+
return_list
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
def binary_only?(spec)
|
147
|
+
deps = spec.dependencies.map { |dep| spec_with_name(dep.name) }
|
148
|
+
[spec, *deps].each do |specification|
|
149
|
+
%w(vendored_frameworks vendored_libraries).each do |attrib|
|
150
|
+
if !specification.nil? && specification.attributes_hash[attrib]
|
151
|
+
return true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
false
|
157
|
+
end
|
158
|
+
|
159
|
+
def spec_with_name(name)
|
160
|
+
return if name.nil?
|
161
|
+
|
162
|
+
set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
|
163
|
+
return nil if set.nil?
|
164
|
+
|
165
|
+
set.specification.root
|
166
|
+
end
|
167
|
+
|
168
|
+
def spec_with_path(path)
|
169
|
+
return if path.nil?
|
170
|
+
path = Pathname.new(path)
|
171
|
+
path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
|
172
|
+
return unless path.exist?
|
173
|
+
|
174
|
+
@path = path.expand_path
|
175
|
+
|
176
|
+
if @path.directory?
|
177
|
+
help! @path + ': is a directory.'
|
178
|
+
return
|
179
|
+
end
|
180
|
+
|
181
|
+
unless ['.podspec', '.json'].include? @path.extname
|
182
|
+
help! @path + ': is not a podspec.'
|
183
|
+
return
|
184
|
+
end
|
185
|
+
|
186
|
+
Specification.from_file(@path)
|
187
|
+
end
|
188
|
+
|
189
|
+
#----------------------
|
190
|
+
# Dynamic Project Setup
|
191
|
+
#----------------------
|
192
|
+
|
193
|
+
def build_dynamic_sandbox(_static_sandbox, _static_installer)
|
194
|
+
dynamic_sandbox_root = Pathname.new(config.sandbox_root + '/Dynamic')
|
195
|
+
dynamic_sandbox = Sandbox.new(dynamic_sandbox_root)
|
196
|
+
|
197
|
+
dynamic_sandbox
|
198
|
+
end
|
199
|
+
|
200
|
+
# @param [Pod::Sandbox] dynamic_sandbox
|
201
|
+
#
|
202
|
+
# @param [Pod::Sandbox] static_sandbox
|
203
|
+
#
|
204
|
+
# @param [Pod::Installer] static_installer
|
205
|
+
#
|
206
|
+
# @param [Pod::Platform] platform
|
207
|
+
#
|
208
|
+
def install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
|
209
|
+
# 1 Create a dynamic target for only the spec pod.
|
210
|
+
dynamic_target = build_dynamic_target(dynamic_sandbox, static_installer, platform)
|
211
|
+
|
212
|
+
# 2. Build a new xcodeproj in the dynamic_sandbox with only the spec pod as a target.
|
213
|
+
project = prepare_pods_project(dynamic_sandbox, dynamic_target.name, static_installer)
|
214
|
+
|
215
|
+
# 3. Copy the source directory for the dynamic framework from the static sandbox.
|
216
|
+
copy_dynamic_target(static_sandbox, dynamic_target, dynamic_sandbox)
|
217
|
+
|
218
|
+
# 4. Create the file references.
|
219
|
+
install_file_references(dynamic_sandbox, [dynamic_target], project)
|
220
|
+
|
221
|
+
# 5. Install the target.
|
222
|
+
install_library(dynamic_sandbox, dynamic_target, project)
|
223
|
+
|
224
|
+
# 6. Write the actual .xcodeproj to the dynamic sandbox.
|
225
|
+
write_pod_project(project, dynamic_sandbox)
|
226
|
+
end
|
227
|
+
|
228
|
+
# @param [Pod::Installer] static_installer
|
229
|
+
#
|
230
|
+
# @return [Pod::PodTarget]
|
231
|
+
#
|
232
|
+
def build_dynamic_target(dynamic_sandbox, static_installer, platform)
|
233
|
+
spec_targets = static_installer.pod_targets.select do |target|
|
234
|
+
target.name == @spec.name
|
235
|
+
end
|
236
|
+
static_target = spec_targets[0]
|
237
|
+
|
238
|
+
file_accessors = create_file_accessors(static_target, dynamic_sandbox)
|
239
|
+
|
240
|
+
archs = []
|
241
|
+
dynamic_target = Pod::PodTarget.new(dynamic_sandbox, true, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)
|
242
|
+
dynamic_target
|
243
|
+
end
|
244
|
+
|
245
|
+
# @param [Pod::Sandbox] dynamic_sandbox
|
246
|
+
#
|
247
|
+
# @param [String] spec_name
|
248
|
+
#
|
249
|
+
# @param [Pod::Installer] installer
|
250
|
+
#
|
251
|
+
def prepare_pods_project(dynamic_sandbox, spec_name, installer)
|
252
|
+
# Create a new pods project
|
253
|
+
pods_project = Pod::Project.new(dynamic_sandbox.project_path)
|
254
|
+
|
255
|
+
# Update build configurations
|
256
|
+
installer.analysis_result.all_user_build_configurations.each do |name, type|
|
257
|
+
pods_project.add_build_configuration(name, type)
|
258
|
+
end
|
259
|
+
|
260
|
+
# Add the pod group for only the dynamic framework
|
261
|
+
local = dynamic_sandbox.local?(spec_name)
|
262
|
+
path = dynamic_sandbox.pod_dir(spec_name)
|
263
|
+
was_absolute = dynamic_sandbox.local_path_was_absolute?(spec_name)
|
264
|
+
pods_project.add_pod_group(spec_name, path, local, was_absolute)
|
265
|
+
pods_project
|
266
|
+
end
|
267
|
+
|
268
|
+
def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
|
269
|
+
command = "cp -a #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
|
270
|
+
`#{command}`
|
271
|
+
end
|
272
|
+
|
273
|
+
def create_file_accessors(target, dynamic_sandbox)
|
274
|
+
pod_root = dynamic_sandbox.pod_dir(target.root_spec.name)
|
275
|
+
|
276
|
+
path_list = Sandbox::PathList.new(pod_root)
|
277
|
+
target.specs.map do |spec|
|
278
|
+
Sandbox::FileAccessor.new(path_list, spec.consumer(target.platform))
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def install_file_references(dynamic_sandbox, pod_targets, pods_project)
|
283
|
+
installer = Pod::Installer::Xcode::PodsProjectGenerator::FileReferencesInstaller.new(dynamic_sandbox, pod_targets, pods_project)
|
284
|
+
installer.install!
|
285
|
+
end
|
286
|
+
|
287
|
+
def install_library(dynamic_sandbox, dynamic_target, project)
|
288
|
+
return if dynamic_target.target_definitions.flat_map(&:dependencies).empty?
|
289
|
+
target_installer = Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.new(dynamic_sandbox, project, dynamic_target)
|
290
|
+
result = target_installer.install!
|
291
|
+
native_target = result.native_target
|
292
|
+
|
293
|
+
# Installs System Frameworks
|
294
|
+
if dynamic_target.should_build?
|
295
|
+
dynamic_target.file_accessors.each do |file_accessor|
|
296
|
+
file_accessor.spec_consumer.frameworks.each do |framework|
|
297
|
+
native_target.add_system_framework(framework)
|
298
|
+
end
|
299
|
+
file_accessor.spec_consumer.libraries.each do |library|
|
300
|
+
native_target.add_system_library(library)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def write_pod_project(dynamic_project, dynamic_sandbox)
|
307
|
+
UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
|
308
|
+
dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
|
309
|
+
dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
|
310
|
+
dynamic_project.sort(:groups_position => :below)
|
311
|
+
dynamic_project.recreate_user_schemes(false)
|
312
|
+
|
313
|
+
# Edit search paths so that we can find our dependency headers
|
314
|
+
dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
|
315
|
+
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
|
316
|
+
config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
|
317
|
+
config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
|
318
|
+
end
|
319
|
+
dynamic_project.save
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module Pod
|
2
|
+
class SpecBuilder
|
3
|
+
def initialize(spec, source, embedded, dynamic, force_load = false)
|
4
|
+
@spec = spec
|
5
|
+
#https://git.100tal.com/peiyou_xueersiapp_xesappmoduleiosframework/CloudLearning_English.git
|
6
|
+
git_source_name = spec.name.gsub("_HD","")
|
7
|
+
@source = source.nil? ? "{ :git => \"https://git.100tal.com/peiyou_xueersiapp_xesappmoduleiosframework/#{git_source_name}.git\", :tag => s.version.to_s }" : source
|
8
|
+
@embedded = embedded
|
9
|
+
@dynamic = dynamic
|
10
|
+
@force_load = force_load
|
11
|
+
end
|
12
|
+
|
13
|
+
def framework_path
|
14
|
+
if @embedded
|
15
|
+
'embedded' + '/' + @spec.name + '.framework'
|
16
|
+
else
|
17
|
+
@spec.name + '.framework'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def spec_platform(platform)
|
22
|
+
fwk_base = platform.name.to_s + '/' + framework_path
|
23
|
+
if @dynamic
|
24
|
+
spec = <<RB
|
25
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
26
|
+
RB
|
27
|
+
else
|
28
|
+
spec = <<RB
|
29
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
30
|
+
s.#{platform.name}.source_files = '#{fwk_base}/Versions/A/Headers/**/*.h'
|
31
|
+
s.#{platform.name}.public_header_files = '#{fwk_base}/Versions/A/Headers/**/*.h'
|
32
|
+
RB
|
33
|
+
end
|
34
|
+
|
35
|
+
# resources
|
36
|
+
spec_resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
37
|
+
consumer = spec.consumer(platform)
|
38
|
+
tmp_resources = consumer.resources || []
|
39
|
+
tmp_resources
|
40
|
+
end.compact.uniq
|
41
|
+
|
42
|
+
if spec_resources.count > 0
|
43
|
+
spec += " s.#{platform.name}.resources = '#{fwk_base}/Versions/A/Resources/*.*'\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# vendored_frameworks
|
48
|
+
vendored_frameworks = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
49
|
+
consumer = spec.consumer(platform)
|
50
|
+
tmp_vendored_frameworks = consumer.vendored_frameworks || []
|
51
|
+
tmp_vendored_frameworks
|
52
|
+
end.compact.uniq.flat_map do |framework|
|
53
|
+
"ios/#{File.basename(framework)}"
|
54
|
+
end
|
55
|
+
vendored_frameworks << fwk_base
|
56
|
+
|
57
|
+
spec += " s.#{platform.name}.vendored_frameworks = #{vendored_frameworks} \n"
|
58
|
+
|
59
|
+
# vendored_libraries
|
60
|
+
vendored_libraries = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
61
|
+
consumer = spec.consumer(platform)
|
62
|
+
tmp_vendored_libraries = consumer.vendored_libraries || []
|
63
|
+
tmp_vendored_libraries
|
64
|
+
end.compact.uniq
|
65
|
+
spec += " s.#{platform.name}.vendored_libraries = #{vendored_libraries}" if vendored_libraries.count > 0
|
66
|
+
|
67
|
+
# frameworks
|
68
|
+
frameworks = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
69
|
+
consumer = spec.consumer(platform)
|
70
|
+
tmp_frameworks = consumer.frameworks || []
|
71
|
+
tmp_frameworks
|
72
|
+
end.compact.uniq
|
73
|
+
spec += " s.#{platform.name}.frameworks = #{frameworks} \n" if frameworks.count > 0
|
74
|
+
|
75
|
+
libraries = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
76
|
+
consumer = spec.consumer(platform)
|
77
|
+
tmp_libraries = consumer.libraries || []
|
78
|
+
tmp_libraries
|
79
|
+
end.compact.uniq
|
80
|
+
spec += " s.#{platform.name}.libraries = #{libraries} \n" if libraries.count > 0
|
81
|
+
|
82
|
+
weak_frameworks = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
83
|
+
consumer = spec.consumer(platform)
|
84
|
+
tmp_libraries = consumer.weak_frameworks || []
|
85
|
+
tmp_libraries
|
86
|
+
end.compact.uniq
|
87
|
+
spec += " s.#{platform.name}.weak_frameworks = #{weak_frameworks} \n" if weak_frameworks.count > 0
|
88
|
+
|
89
|
+
[@spec, *@spec.recursive_subspecs].flat_map do |spec|
|
90
|
+
spec.all_dependencies(platform)
|
91
|
+
end.compact.uniq.each do |d|
|
92
|
+
if d.requirement == Pod::Requirement.default
|
93
|
+
spec += " s.dependency '#{d.name}'\n" unless d.root_name == @spec.name
|
94
|
+
else
|
95
|
+
spec += " s.dependency '#{d.name}', '#{d.requirement.to_s}'\n" unless d.root_name == @spec.name
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
platform_framework_path = platform.name.to_s
|
100
|
+
if @embedded
|
101
|
+
platform_framework_path += '/embedded'
|
102
|
+
end
|
103
|
+
|
104
|
+
if @force_load
|
105
|
+
# xcconfig
|
106
|
+
xcconfig = <<RB
|
107
|
+
path = File.dirname(Pathname.new(__FILE__)).to_s
|
108
|
+
relative_path = path
|
109
|
+
config = Pod::Config.instance
|
110
|
+
if path.include?(config.home_dir.to_s)
|
111
|
+
relative_path = "${PODS_ROOT}/#{@spec.name}"
|
112
|
+
end
|
113
|
+
s.xcconfig = {
|
114
|
+
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
115
|
+
'OTHER_LDFLAGS' => ["$(inherited)","-force_load","\#{relative_path}/#{fwk_base}/#{@spec.name}","'-L \#{relative_path}/#{fwk_base}'"],
|
116
|
+
'FRAMEWORK_SEARCH_PATHS' => ["$(inherited)","\#{relative_path}/#{platform_framework_path}"],
|
117
|
+
'HEADER_SEARCH_PATHS' => ["$(inherited)","\#{relative_path}/#{fwk_base}/Versions/A/Headers/**"]
|
118
|
+
}
|
119
|
+
RB
|
120
|
+
else
|
121
|
+
# xcconfig
|
122
|
+
xcconfig = <<RB
|
123
|
+
path = File.dirname(Pathname.new(__FILE__)).to_s
|
124
|
+
relative_path = path
|
125
|
+
config = Pod::Config.instance
|
126
|
+
if path.include?(config.home_dir.to_s)
|
127
|
+
relative_path = "${PODS_ROOT}/#{@spec.name}"
|
128
|
+
end
|
129
|
+
s.xcconfig = {
|
130
|
+
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
131
|
+
'FRAMEWORK_SEARCH_PATHS' => ["$(inherited)","\#{relative_path}/#{platform_framework_path}"],
|
132
|
+
'HEADER_SEARCH_PATHS' => ["$(inherited)","\#{relative_path}/#{fwk_base}/Versions/A/Headers/**"]
|
133
|
+
}
|
134
|
+
RB
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
spec += xcconfig
|
139
|
+
|
140
|
+
spec
|
141
|
+
end
|
142
|
+
|
143
|
+
def spec_metadata
|
144
|
+
spec = spec_header
|
145
|
+
spec
|
146
|
+
end
|
147
|
+
|
148
|
+
def spec_close
|
149
|
+
"end\n"
|
150
|
+
end
|
151
|
+
|
152
|
+
private
|
153
|
+
|
154
|
+
def spec_header
|
155
|
+
spec = "Pod::Spec.new do |s|\n"
|
156
|
+
attribute_list = %w(name version summary license authors homepage description social_media_url
|
157
|
+
docset_url documentation_url screenshots requires_arc
|
158
|
+
deployment_target xcconfig)
|
159
|
+
|
160
|
+
attribute_list.each do |attribute|
|
161
|
+
value = @spec.attributes_hash[attribute]
|
162
|
+
next if value.nil?
|
163
|
+
value = value.dump if value.class == String
|
164
|
+
spec += " s.#{attribute} = #{value}\n"
|
165
|
+
end
|
166
|
+
spec += " s.source = #{@source}\n"
|
167
|
+
|
168
|
+
spec
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|