cocoapods-square-stable 0.19.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1296 -0
- data/LICENSE +20 -0
- data/README.md +94 -0
- data/bin/pod +16 -0
- data/bin/sandbox-pod +120 -0
- data/lib/cocoapods.rb +77 -0
- data/lib/cocoapods/command.rb +116 -0
- data/lib/cocoapods/command/help.rb +23 -0
- data/lib/cocoapods/command/inter_process_communication.rb +178 -0
- data/lib/cocoapods/command/list.rb +77 -0
- data/lib/cocoapods/command/outdated.rb +56 -0
- data/lib/cocoapods/command/podfile_info.rb +91 -0
- data/lib/cocoapods/command/project.rb +88 -0
- data/lib/cocoapods/command/push.rb +172 -0
- data/lib/cocoapods/command/repo.rb +145 -0
- data/lib/cocoapods/command/search.rb +61 -0
- data/lib/cocoapods/command/setup.rb +134 -0
- data/lib/cocoapods/command/spec.rb +590 -0
- data/lib/cocoapods/config.rb +231 -0
- data/lib/cocoapods/downloader.rb +59 -0
- data/lib/cocoapods/executable.rb +118 -0
- data/lib/cocoapods/external_sources.rb +363 -0
- data/lib/cocoapods/file_list.rb +36 -0
- data/lib/cocoapods/gem_version.rb +7 -0
- data/lib/cocoapods/generator/acknowledgements.rb +107 -0
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +40 -0
- data/lib/cocoapods/generator/acknowledgements/plist.rb +64 -0
- data/lib/cocoapods/generator/bridge_support.rb +22 -0
- data/lib/cocoapods/generator/copy_resources_script.rb +54 -0
- data/lib/cocoapods/generator/dummy_source.rb +22 -0
- data/lib/cocoapods/generator/prefix_header.rb +82 -0
- data/lib/cocoapods/generator/target_environment_header.rb +86 -0
- data/lib/cocoapods/generator/xcconfig.rb +185 -0
- data/lib/cocoapods/hooks/installer_representation.rb +134 -0
- data/lib/cocoapods/hooks/library_representation.rb +94 -0
- data/lib/cocoapods/hooks/pod_representation.rb +74 -0
- data/lib/cocoapods/installer.rb +571 -0
- data/lib/cocoapods/installer/analyzer.rb +559 -0
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +253 -0
- data/lib/cocoapods/installer/file_references_installer.rb +179 -0
- data/lib/cocoapods/installer/pod_source_installer.rb +248 -0
- data/lib/cocoapods/installer/target_installer.rb +379 -0
- data/lib/cocoapods/installer/user_project_integrator.rb +180 -0
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +224 -0
- data/lib/cocoapods/library.rb +202 -0
- data/lib/cocoapods/open_uri.rb +24 -0
- data/lib/cocoapods/project.rb +209 -0
- data/lib/cocoapods/resolver.rb +212 -0
- data/lib/cocoapods/sandbox.rb +343 -0
- data/lib/cocoapods/sandbox/file_accessor.rb +217 -0
- data/lib/cocoapods/sandbox/headers_store.rb +96 -0
- data/lib/cocoapods/sandbox/path_list.rb +208 -0
- data/lib/cocoapods/sources_manager.rb +276 -0
- data/lib/cocoapods/user_interface.rb +304 -0
- data/lib/cocoapods/user_interface/error_report.rb +101 -0
- data/lib/cocoapods/validator.rb +350 -0
- metadata +238 -0
@@ -0,0 +1,379 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
|
4
|
+
# Controller class responsible of creating and configuring the static
|
5
|
+
# library target in Pods project. It also creates the support file needed
|
6
|
+
# by the target.
|
7
|
+
#
|
8
|
+
class TargetInstaller
|
9
|
+
|
10
|
+
# @return [Sandbox] sandbox the sandbox where the support files should
|
11
|
+
# be generated.
|
12
|
+
#
|
13
|
+
attr_reader :sandbox
|
14
|
+
|
15
|
+
# @return [Library] The library whose target needs to be generated.
|
16
|
+
#
|
17
|
+
attr_reader :library
|
18
|
+
|
19
|
+
# @param [Project] project @see project
|
20
|
+
# @param [Library] library @see library
|
21
|
+
#
|
22
|
+
def initialize(sandbox, library)
|
23
|
+
@sandbox = sandbox
|
24
|
+
@library = library
|
25
|
+
end
|
26
|
+
|
27
|
+
# Creates the target in the Pods project and the relative support files.
|
28
|
+
#
|
29
|
+
# @return [void]
|
30
|
+
#
|
31
|
+
def install!
|
32
|
+
UI.message "- Installing target `#{library.name}` #{library.platform}" do
|
33
|
+
add_target
|
34
|
+
add_files_to_build_phases
|
35
|
+
create_suport_files_group
|
36
|
+
|
37
|
+
create_xcconfig_file
|
38
|
+
create_target_environment_header
|
39
|
+
create_prefix_header
|
40
|
+
create_bridge_support_file
|
41
|
+
create_copy_resources_script
|
42
|
+
create_acknowledgements
|
43
|
+
create_dummy_source
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
#-----------------------------------------------------------------------#
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# @!group Installation steps
|
52
|
+
|
53
|
+
# Adds the target for the library to the Pods project with the
|
54
|
+
# appropriate build configurations.
|
55
|
+
#
|
56
|
+
# @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
|
57
|
+
#
|
58
|
+
# @todo CocoaPods 0.16 used to add the build configurations to the build
|
59
|
+
# configuration list of the project (`root object`) as well with
|
60
|
+
# an empty build settings. This behaviour was changed in 0.17.
|
61
|
+
# Restore if needed.
|
62
|
+
#
|
63
|
+
# @return [void]
|
64
|
+
#
|
65
|
+
def add_target
|
66
|
+
name = library.label
|
67
|
+
platform = library.platform.name
|
68
|
+
deployment_target = library.platform.deployment_target.to_s
|
69
|
+
@target = project.new_target(:static_library, name, platform, deployment_target)
|
70
|
+
|
71
|
+
settings = {}
|
72
|
+
if library.platform.requires_legacy_ios_archs?
|
73
|
+
settings['ARCHS'] = "armv6 armv7"
|
74
|
+
end
|
75
|
+
|
76
|
+
@target.build_settings('Debug').merge!(settings)
|
77
|
+
@target.build_settings('Release').merge!(settings)
|
78
|
+
|
79
|
+
library.user_build_configurations.each do |bc_name, type|
|
80
|
+
unless @target.build_configurations.map(&:name).include?(bc_name)
|
81
|
+
build_config = project.new(Xcodeproj::Project::XCBuildConfiguration)
|
82
|
+
build_config.name = bc_name
|
83
|
+
settings = @target.build_settings(type.to_s.capitalize).dup
|
84
|
+
build_config.build_settings = settings
|
85
|
+
target.build_configurations << build_config
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
library.target = @target
|
90
|
+
end
|
91
|
+
|
92
|
+
# Adds the build files of the pods to the target and adds a reference to
|
93
|
+
# the frameworks of the Pods.
|
94
|
+
#
|
95
|
+
# @note The Frameworks are used only for presentation purposes as the
|
96
|
+
# xcconfig is the authoritative source about their information.
|
97
|
+
#
|
98
|
+
# @return [void]
|
99
|
+
#
|
100
|
+
def add_files_to_build_phases
|
101
|
+
UI.message "- Adding Build files" do
|
102
|
+
library.file_accessors.each do |file_accessor|
|
103
|
+
consumer = file_accessor.spec_consumer
|
104
|
+
flags = compiler_flags_for_consumer(consumer)
|
105
|
+
source_files = file_accessor.source_files
|
106
|
+
file_refs = source_files.map { |sf| project.file_reference(sf) }
|
107
|
+
target.add_file_references(file_refs, flags)
|
108
|
+
|
109
|
+
file_accessor.spec_consumer.frameworks.each do |framework|
|
110
|
+
project.add_system_framework(framework, target)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Creates the group that holds the references to the support files
|
117
|
+
# generated by this installer.
|
118
|
+
#
|
119
|
+
# @return [void]
|
120
|
+
#
|
121
|
+
def create_suport_files_group
|
122
|
+
name = target_definition.label
|
123
|
+
@support_files_group = project.support_files_group.new_group(name)
|
124
|
+
end
|
125
|
+
|
126
|
+
#--------------------------------------#
|
127
|
+
|
128
|
+
# Generates the contents of the xcconfig file and saves it to disk.
|
129
|
+
#
|
130
|
+
# @note The `ALWAYS_SEARCH_USER_PATHS` flag is enabled to support
|
131
|
+
# libraries like `EmbedReader`.
|
132
|
+
#
|
133
|
+
# @return [void]
|
134
|
+
#
|
135
|
+
def create_xcconfig_file
|
136
|
+
path = library.xcconfig_path
|
137
|
+
UI.message "- Generating xcconfig file at #{UI.path(path)}" do
|
138
|
+
gen = Generator::XCConfig.new(sandbox, spec_consumers, library.relative_pods_root)
|
139
|
+
gen.set_arc_compatibility_flag = target_definition.podfile.set_arc_compatibility_flag?
|
140
|
+
gen.save_as(path)
|
141
|
+
library.xcconfig = gen.xcconfig
|
142
|
+
xcconfig_file_ref = add_file_to_support_group(path)
|
143
|
+
|
144
|
+
target.build_configurations.each do |c|
|
145
|
+
c.base_configuration_reference = xcconfig_file_ref
|
146
|
+
Generator::XCConfig.pods_project_settings.each do |key, value|
|
147
|
+
c.build_settings[key] = value
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Generates a header which allows to inspect at compile time the installed
|
154
|
+
# pods and the installed specifications of a pod.
|
155
|
+
#
|
156
|
+
def create_target_environment_header
|
157
|
+
path = library.target_environment_header_path
|
158
|
+
UI.message "- Generating target environment header at #{UI.path(path)}" do
|
159
|
+
generator = Generator::TargetEnvironmentHeader.new(library.specs)
|
160
|
+
generator.save_as(path)
|
161
|
+
add_file_to_support_group(path)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
|
166
|
+
# to the platform of the target. This file also include any prefix header
|
167
|
+
# content reported by the specification of the pods.
|
168
|
+
#
|
169
|
+
# @return [void]
|
170
|
+
#
|
171
|
+
def create_prefix_header
|
172
|
+
path = library.prefix_header_path
|
173
|
+
UI.message "- Generating prefix header at #{UI.path(path)}" do
|
174
|
+
generator = Generator::PrefixHeader.new(library.file_accessors, library.platform)
|
175
|
+
generator.imports << library.target_environment_header_path.basename
|
176
|
+
generator.save_as(path)
|
177
|
+
add_file_to_support_group(path)
|
178
|
+
|
179
|
+
target.build_configurations.each do |c|
|
180
|
+
relative_path = path.relative_path_from(sandbox.root)
|
181
|
+
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Generates the bridge support metadata if requested by the {Podfile}.
|
187
|
+
#
|
188
|
+
# @note The bridge support metadata is added to the resources of the
|
189
|
+
# library because it is needed for environments interpreted at
|
190
|
+
# runtime.
|
191
|
+
#
|
192
|
+
# @return [void]
|
193
|
+
#
|
194
|
+
def create_bridge_support_file
|
195
|
+
if target_definition.podfile.generate_bridge_support?
|
196
|
+
path = library.bridge_support_path
|
197
|
+
UI.message "- Generating BridgeSupport metadata at #{UI.path(path)}" do
|
198
|
+
headers = target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
|
199
|
+
generator = Generator::BridgeSupport.new(headers)
|
200
|
+
generator.save_as(path)
|
201
|
+
add_file_to_support_group(path)
|
202
|
+
@bridge_support_file = path.relative_path_from(sandbox.root)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
ENABLE_EXTERNAL_STRINGS_FILE_FLAG = {
|
208
|
+
:ios => Version.new('6'),
|
209
|
+
:osx => Version.new('10.8')
|
210
|
+
}
|
211
|
+
# Creates a script that copies the resources to the bundle of the client
|
212
|
+
# target.
|
213
|
+
#
|
214
|
+
# @note The bridge support file needs to be created before the prefix
|
215
|
+
# header, otherwise it will not be added to the resources script.
|
216
|
+
#
|
217
|
+
# @return [void]
|
218
|
+
#
|
219
|
+
def create_copy_resources_script
|
220
|
+
path = library.copy_resources_script_path
|
221
|
+
UI.message "- Generating copy resources script at #{UI.path(path)}" do
|
222
|
+
resources = library.file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
|
223
|
+
resources << bridge_support_file if bridge_support_file
|
224
|
+
platform_name = library.platform.name
|
225
|
+
reference_external_strings_file = library.platform.deployment_target >= ENABLE_EXTERNAL_STRINGS_FILE_FLAG[platform_name]
|
226
|
+
generator = Generator::CopyResourcesScript.new(resources, reference_external_strings_file)
|
227
|
+
generator.save_as(path)
|
228
|
+
add_file_to_support_group(path)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Generates the acknowledgement files (markdown and plist) for the target.
|
233
|
+
#
|
234
|
+
# @return [void]
|
235
|
+
#
|
236
|
+
def create_acknowledgements
|
237
|
+
basepath = library.acknowledgements_basepath
|
238
|
+
Generator::Acknowledgements.generators.each do |generator_class|
|
239
|
+
path = generator_class.path_from_basepath(basepath)
|
240
|
+
UI.message "- Generating acknowledgements at #{UI.path(path)}" do
|
241
|
+
generator = generator_class.new(library.file_accessors)
|
242
|
+
generator.save_as(path)
|
243
|
+
add_file_to_support_group(path)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# Generates a dummy source file for each target so libraries that contain
|
249
|
+
# only categories build.
|
250
|
+
#
|
251
|
+
# @return [void]
|
252
|
+
#
|
253
|
+
def create_dummy_source
|
254
|
+
path = library.dummy_source_path
|
255
|
+
UI.message "- Generating dummy source file at #{UI.path(path)}" do
|
256
|
+
generator = Generator::DummySource.new(library.label)
|
257
|
+
generator.save_as(path)
|
258
|
+
file_reference = add_file_to_support_group(path)
|
259
|
+
target.source_build_phase.add_file_reference(file_reference)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
#-----------------------------------------------------------------------#
|
264
|
+
|
265
|
+
private
|
266
|
+
|
267
|
+
# @return [PBXNativeTarget] the target generated by the installation
|
268
|
+
# process.
|
269
|
+
#
|
270
|
+
# @note Generated by the {#add_target} step.
|
271
|
+
#
|
272
|
+
attr_reader :target
|
273
|
+
|
274
|
+
# @!group Private helpers.
|
275
|
+
|
276
|
+
# @return [Project] the Pods project of the sandbox.
|
277
|
+
#
|
278
|
+
def project
|
279
|
+
sandbox.project
|
280
|
+
end
|
281
|
+
|
282
|
+
# @return [TargetDefinition] the target definition of the library.
|
283
|
+
#
|
284
|
+
def target_definition
|
285
|
+
library.target_definition
|
286
|
+
end
|
287
|
+
|
288
|
+
# @return [Specification::Consumer] the consumer for the specifications.
|
289
|
+
#
|
290
|
+
def spec_consumers
|
291
|
+
@spec_consumers ||= library.file_accessors.map(&:spec_consumer)
|
292
|
+
end
|
293
|
+
|
294
|
+
# @return [PBXGroup] the group where the file references to the support
|
295
|
+
# files should be stored.
|
296
|
+
#
|
297
|
+
attr_reader :support_files_group
|
298
|
+
|
299
|
+
# @return [Pathname] the path of the bridge support file relative to the
|
300
|
+
# sandbox.
|
301
|
+
#
|
302
|
+
# @return [Nil] if no bridge support file was generated.
|
303
|
+
#
|
304
|
+
attr_reader :bridge_support_file
|
305
|
+
|
306
|
+
# Adds a reference to the given file in the support group of this target.
|
307
|
+
#
|
308
|
+
# @param [Pathname] path
|
309
|
+
# The path of the file to which the reference should be added.
|
310
|
+
#
|
311
|
+
# @return [PBXFileReference] the file reference of the added file.
|
312
|
+
#
|
313
|
+
def add_file_to_support_group(path)
|
314
|
+
relative_path = path.relative_path_from(sandbox.root)
|
315
|
+
support_files_group.new_file(relative_path)
|
316
|
+
end
|
317
|
+
|
318
|
+
ENABLE_OBJECT_USE_OBJC_FROM = {
|
319
|
+
:ios => Version.new('6'),
|
320
|
+
:osx => Version.new('10.8')
|
321
|
+
}
|
322
|
+
|
323
|
+
# Returns the compiler flags for the source files of the given specification.
|
324
|
+
#
|
325
|
+
# The following behavior is regarding the `OS_OBJECT_USE_OBJC` flag. When
|
326
|
+
# set to `0`, it will allow code to use `dispatch_release()` on >= iOS 6.0
|
327
|
+
# and OS X 10.8.
|
328
|
+
#
|
329
|
+
# * New libraries that do *not* require ARC don’t need to care about this
|
330
|
+
# issue at all.
|
331
|
+
#
|
332
|
+
# * New libraries that *do* require ARC _and_ have a deployment target of
|
333
|
+
# >= iOS 6.0 or OS X 10.8:
|
334
|
+
#
|
335
|
+
# These no longer use `dispatch_release()` and should *not* have the
|
336
|
+
# `OS_OBJECT_USE_OBJC` flag set to `0`.
|
337
|
+
#
|
338
|
+
# **Note:** this means that these libraries *have* to specify the
|
339
|
+
# deployment target in order to function well.
|
340
|
+
#
|
341
|
+
# * New libraries that *do* require ARC, but have a deployment target of
|
342
|
+
# < iOS 6.0 or OS X 10.8:
|
343
|
+
#
|
344
|
+
# These contain `dispatch_release()` calls and as such need the
|
345
|
+
# `OS_OBJECT_USE_OBJC` flag set to `1`.
|
346
|
+
#
|
347
|
+
# **Note:** libraries that do *not* specify a platform version are
|
348
|
+
# assumed to have a deployment target of < iOS 6.0 or OS X 10.8.
|
349
|
+
#
|
350
|
+
# For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
|
351
|
+
#
|
352
|
+
# @param [Specification::Consumer] consumer
|
353
|
+
# The consumer for the specification for which the compiler flags
|
354
|
+
# are needed.
|
355
|
+
#
|
356
|
+
# @return [String] The compiler flags.
|
357
|
+
#
|
358
|
+
def compiler_flags_for_consumer(consumer)
|
359
|
+
flags = consumer.compiler_flags.dup
|
360
|
+
if consumer.requires_arc
|
361
|
+
flags << '-fobjc-arc'
|
362
|
+
platform_name = consumer.platform_name
|
363
|
+
spec_deployment_target = consumer.spec.deployment_target(platform_name)
|
364
|
+
if spec_deployment_target.nil? || Version.new(spec_deployment_target) < ENABLE_OBJECT_USE_OBJC_FROM[platform_name]
|
365
|
+
flags << '-DOS_OBJECT_USE_OBJC=0'
|
366
|
+
end
|
367
|
+
end
|
368
|
+
if target_definition.inhibits_warnings_for_pod?(consumer.spec.root.name)
|
369
|
+
flags << '-w -Xanalyzer -analyzer-disable-checker'
|
370
|
+
end
|
371
|
+
flags * " "
|
372
|
+
end
|
373
|
+
|
374
|
+
#-----------------------------------------------------------------------#
|
375
|
+
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'xcodeproj/workspace'
|
2
|
+
require 'xcodeproj/project'
|
3
|
+
|
4
|
+
require 'active_support/core_ext/string/inflections'
|
5
|
+
require 'active_support/core_ext/array/conversions'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
class Installer
|
9
|
+
|
10
|
+
# The {UserProjectIntegrator} integrates the libraries generated by
|
11
|
+
# TargetDefinitions of the {Podfile} with their correspondent user
|
12
|
+
# projects.
|
13
|
+
#
|
14
|
+
class UserProjectIntegrator
|
15
|
+
|
16
|
+
autoload :TargetIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator'
|
17
|
+
|
18
|
+
# @return [Podfile] the podfile that should be integrated with the user
|
19
|
+
# projects.
|
20
|
+
#
|
21
|
+
attr_reader :podfile
|
22
|
+
|
23
|
+
# @return [Project] the pods project which contains the libraries to
|
24
|
+
# integrate.
|
25
|
+
#
|
26
|
+
# attr_reader :pods_project
|
27
|
+
|
28
|
+
attr_reader :sandbox
|
29
|
+
|
30
|
+
# @return [Pathname] the path of the installation.
|
31
|
+
#
|
32
|
+
# @todo This is only used to compute the workspace path in case that it
|
33
|
+
# should be inferred by the project. If the workspace should be in
|
34
|
+
# the same dir of the project, this could be removed.
|
35
|
+
#
|
36
|
+
attr_reader :installation_root
|
37
|
+
|
38
|
+
# @return [Library] the libraries generated by the installer.
|
39
|
+
#
|
40
|
+
attr_reader :libraries
|
41
|
+
|
42
|
+
# @param [Podfile] podfile @see #podfile
|
43
|
+
# @param [Sandbox] sandbox @see #sandbox
|
44
|
+
# @param [Pathname] installation_root @see #installation_root
|
45
|
+
# @param [Library] libraries @see #libraries
|
46
|
+
#
|
47
|
+
# @todo Too many initialization arguments
|
48
|
+
#
|
49
|
+
def initialize(podfile, sandbox, installation_root, libraries)
|
50
|
+
@podfile = podfile
|
51
|
+
@sandbox = sandbox
|
52
|
+
@installation_root = installation_root
|
53
|
+
@libraries = libraries
|
54
|
+
end
|
55
|
+
|
56
|
+
# Integrates the user projects associated with the {TargetDefinitions}
|
57
|
+
# with the Pods project and its products.
|
58
|
+
#
|
59
|
+
# @return [void]
|
60
|
+
#
|
61
|
+
def integrate!
|
62
|
+
create_workspace
|
63
|
+
integrate_user_targets
|
64
|
+
warn_about_empty_podfile
|
65
|
+
end
|
66
|
+
|
67
|
+
#-----------------------------------------------------------------------#
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# @!group Integration steps
|
72
|
+
|
73
|
+
# Creates and saved the workspace containing the Pods project and the
|
74
|
+
# user projects, if needed.
|
75
|
+
#
|
76
|
+
# @note If the workspace already contains the projects it is not saved
|
77
|
+
# to avoid Xcode from displaying the revert dialog: `Do you want to
|
78
|
+
# keep the Xcode version or revert to the version on disk?`
|
79
|
+
#
|
80
|
+
# @return [void]
|
81
|
+
#
|
82
|
+
def create_workspace
|
83
|
+
all_projects = user_project_paths.sort.push(sandbox.project_path).uniq
|
84
|
+
projpaths = all_projects.map do |path|
|
85
|
+
path.relative_path_from(workspace_path.dirname).to_s
|
86
|
+
end
|
87
|
+
|
88
|
+
if workspace_path.exist?
|
89
|
+
workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
|
90
|
+
new_projpaths = projpaths - workspace.projpaths
|
91
|
+
unless new_projpaths.empty?
|
92
|
+
workspace.projpaths.concat(new_projpaths)
|
93
|
+
workspace.save_as(workspace_path)
|
94
|
+
end
|
95
|
+
|
96
|
+
else
|
97
|
+
UI.notice "From now on use `#{workspace_path.basename}`."
|
98
|
+
workspace = Xcodeproj::Workspace.new(*projpaths)
|
99
|
+
workspace.save_as(workspace_path)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Integrates the targets of the user projects with the libraries
|
104
|
+
# generated from the {Podfile}.
|
105
|
+
#
|
106
|
+
# @note {TargetDefinition} without dependencies are skipped prevent
|
107
|
+
# creating empty libraries for targets definitions which are only
|
108
|
+
# wrappers for others.
|
109
|
+
#
|
110
|
+
# @return [void]
|
111
|
+
#
|
112
|
+
def integrate_user_targets
|
113
|
+
libraries_to_integrate.sort_by(&:name).each do |lib|
|
114
|
+
TargetIntegrator.new(lib).integrate!
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Warns the user if the podfile is empty.
|
119
|
+
#
|
120
|
+
# @note The workspace is created in any case and all the user projects
|
121
|
+
# are added to it, however the projects are not integrated as
|
122
|
+
# there is no way to discern between target definitions which are
|
123
|
+
# empty and target definitions which just serve the purpose to
|
124
|
+
# wrap other ones. This is not an issue because empty target
|
125
|
+
# definitions generate empty libraries.
|
126
|
+
#
|
127
|
+
# @return [void]
|
128
|
+
#
|
129
|
+
def warn_about_empty_podfile
|
130
|
+
if podfile.target_definitions.values.all?{ |td| td.empty? }
|
131
|
+
UI.warn "[!] The Podfile does not contain any dependency."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
# @!group Private Helpers
|
138
|
+
#-----------------------------------------------------------------------#
|
139
|
+
|
140
|
+
# @return [Pathname] the path where the workspace containing the Pods
|
141
|
+
# project and the user projects should be saved.
|
142
|
+
#
|
143
|
+
def workspace_path
|
144
|
+
if podfile.workspace_path
|
145
|
+
declared_path = podfile.workspace_path
|
146
|
+
path_with_ext = File.extname(declared_path) == '.xcworkspace' ? declared_path : "#{declared_path}.xcworkspace"
|
147
|
+
podfile_dir = File.dirname(podfile.defined_in_file || '')
|
148
|
+
absolute_path = File.expand_path(path_with_ext, podfile_dir)
|
149
|
+
Pathname.new(absolute_path)
|
150
|
+
elsif user_project_paths.count == 1
|
151
|
+
project = user_project_paths.first.basename('.xcodeproj')
|
152
|
+
installation_root + "#{project}.xcworkspace"
|
153
|
+
else
|
154
|
+
raise Informative, "Could not automatically select an Xcode " \
|
155
|
+
"workspace. Specify one in your Podfile like so:\n\n" \
|
156
|
+
" workspace 'path/to/Workspace.xcworkspace'\n"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# @return [Array<Pathname>] the paths of all the user projects referenced
|
161
|
+
# by the target definitions.
|
162
|
+
#
|
163
|
+
# @note Empty target definitions are ignored.
|
164
|
+
#
|
165
|
+
def user_project_paths
|
166
|
+
libraries.map do |lib|
|
167
|
+
lib.user_project_path
|
168
|
+
end.compact.uniq
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
def libraries_to_integrate
|
173
|
+
libraries.reject { |lib| lib.target_definition.empty? }
|
174
|
+
end
|
175
|
+
|
176
|
+
#-----------------------------------------------------------------------#
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|