cocoapods 0.39.0.beta.1 → 0.39.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/cocoapods/gem_version.rb +1 -1
- metadata +35 -63
- data/lib/cocoapods/command/cache/clean.rb +0 -90
- data/lib/cocoapods/command/cache/list.rb +0 -69
- data/lib/cocoapods/command/repo/add.rb +0 -53
- data/lib/cocoapods/command/repo/lint.rb +0 -77
- data/lib/cocoapods/command/repo/list.rb +0 -93
- data/lib/cocoapods/command/repo/push.rb +0 -223
- data/lib/cocoapods/command/repo/remove.rb +0 -36
- data/lib/cocoapods/command/repo/update.rb +0 -27
- data/lib/cocoapods/command/spec/cat.rb +0 -51
- data/lib/cocoapods/command/spec/create.rb +0 -279
- data/lib/cocoapods/command/spec/edit.rb +0 -94
- data/lib/cocoapods/command/spec/lint.rb +0 -119
- data/lib/cocoapods/command/spec/which.rb +0 -43
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +0 -38
- data/lib/cocoapods/generator/acknowledgements/plist.rb +0 -80
- data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +0 -260
- data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +0 -83
- data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +0 -213
- data/lib/cocoapods/installer/analyzer/analysis_result.rb +0 -46
- data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +0 -79
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +0 -262
- data/lib/cocoapods/installer/analyzer/specs_state.rb +0 -76
- data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +0 -41
- data/lib/cocoapods/installer/analyzer/target_inspector.rb +0 -203
- data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +0 -186
- data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +0 -297
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +0 -318
- data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +0 -173
@@ -1,297 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
class Installer
|
3
|
-
# Creates the target for the Pods libraries in the Pods project and the
|
4
|
-
# relative support files.
|
5
|
-
#
|
6
|
-
class PodTargetInstaller < TargetInstaller
|
7
|
-
# Creates the target in the Pods project and the relative support files.
|
8
|
-
#
|
9
|
-
# @return [void]
|
10
|
-
#
|
11
|
-
def install!
|
12
|
-
unless target.should_build?
|
13
|
-
add_resources_bundle_targets
|
14
|
-
return
|
15
|
-
end
|
16
|
-
|
17
|
-
UI.message "- Installing target `#{target.name}` #{target.platform}" do
|
18
|
-
add_target
|
19
|
-
create_support_files_dir
|
20
|
-
add_resources_bundle_targets
|
21
|
-
add_files_to_build_phases
|
22
|
-
create_xcconfig_file
|
23
|
-
if target.requires_frameworks?
|
24
|
-
create_info_plist_file
|
25
|
-
create_module_map do |generator|
|
26
|
-
generator.private_headers += target.file_accessors.flat_map(&:private_headers).map(&:basename)
|
27
|
-
end
|
28
|
-
create_umbrella_header do |generator|
|
29
|
-
generator.imports += target.file_accessors.flat_map(&:public_headers).map(&:basename)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
create_prefix_header
|
33
|
-
create_dummy_source
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# Adds the project/library and compatibility versions, which are only
|
40
|
-
# applicable to dynamic libraries.
|
41
|
-
#
|
42
|
-
# @return [Hash{String => String}]
|
43
|
-
#
|
44
|
-
def custom_build_settings
|
45
|
-
settings = super
|
46
|
-
if target.requires_frameworks?
|
47
|
-
version = target.root_spec.version
|
48
|
-
project_version = [version.major, version.minor, version.patch].join('.')
|
49
|
-
compatibility_version = version.major
|
50
|
-
compatibility_version = project_version if compatibility_version < 1
|
51
|
-
settings['CURRENT_PROJECT_VERSION'] = project_version
|
52
|
-
settings['DYLIB_COMPATIBILITY_VERSION'] = compatibility_version.to_s
|
53
|
-
settings['DYLIB_CURRENT_VERSION'] = '$(CURRENT_PROJECT_VERSION)'
|
54
|
-
end
|
55
|
-
settings
|
56
|
-
end
|
57
|
-
|
58
|
-
#-----------------------------------------------------------------------#
|
59
|
-
|
60
|
-
SOURCE_FILE_EXTENSIONS = Sandbox::FileAccessor::SOURCE_FILE_EXTENSIONS
|
61
|
-
|
62
|
-
# Adds the build files of the pods to the target and adds a reference to
|
63
|
-
# the frameworks of the Pods.
|
64
|
-
#
|
65
|
-
# @note The Frameworks are used only for presentation purposes as the
|
66
|
-
# xcconfig is the authoritative source about their information.
|
67
|
-
#
|
68
|
-
# @return [void]
|
69
|
-
#
|
70
|
-
def add_files_to_build_phases
|
71
|
-
target.file_accessors.each do |file_accessor|
|
72
|
-
consumer = file_accessor.spec_consumer
|
73
|
-
|
74
|
-
headers = file_accessor.headers
|
75
|
-
public_headers = file_accessor.public_headers
|
76
|
-
private_headers = file_accessor.private_headers
|
77
|
-
other_source_files = file_accessor.source_files.reject { |sf| SOURCE_FILE_EXTENSIONS.include?(sf.extname) }
|
78
|
-
|
79
|
-
{
|
80
|
-
true => file_accessor.arc_source_files,
|
81
|
-
false => file_accessor.non_arc_source_files,
|
82
|
-
}.each do |arc, files|
|
83
|
-
files = files - headers - other_source_files
|
84
|
-
flags = compiler_flags_for_consumer(consumer, arc)
|
85
|
-
regular_file_refs = files.map { |sf| project.reference_for_path(sf) }
|
86
|
-
native_target.add_file_references(regular_file_refs, flags)
|
87
|
-
end
|
88
|
-
|
89
|
-
header_file_refs = headers.map { |sf| project.reference_for_path(sf) }
|
90
|
-
native_target.add_file_references(header_file_refs) do |build_file|
|
91
|
-
# Set added headers as public if needed
|
92
|
-
if target.requires_frameworks?
|
93
|
-
build_file.settings ||= {}
|
94
|
-
if public_headers.include?(build_file.file_ref.real_path)
|
95
|
-
build_file.settings['ATTRIBUTES'] = ['Public']
|
96
|
-
elsif private_headers.include?(build_file.file_ref.real_path)
|
97
|
-
build_file.settings['ATTRIBUTES'] = ['Private']
|
98
|
-
else
|
99
|
-
build_file.settings['ATTRIBUTES'] = ['Project']
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
other_file_refs = other_source_files.map { |sf| project.reference_for_path(sf) }
|
105
|
-
native_target.add_file_references(other_file_refs, nil)
|
106
|
-
|
107
|
-
next unless target.requires_frameworks?
|
108
|
-
|
109
|
-
resource_refs = file_accessor.resources.flatten.map do |res|
|
110
|
-
project.reference_for_path(res)
|
111
|
-
end
|
112
|
-
|
113
|
-
native_target.add_resources(resource_refs)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# Adds the resources of the Pods to the Pods project.
|
118
|
-
#
|
119
|
-
# @note The source files are grouped by Pod and in turn by subspec
|
120
|
-
# (recursively) in the resources group.
|
121
|
-
#
|
122
|
-
# @return [void]
|
123
|
-
#
|
124
|
-
def add_resources_bundle_targets
|
125
|
-
target.file_accessors.each do |file_accessor|
|
126
|
-
file_accessor.resource_bundles.each do |bundle_name, paths|
|
127
|
-
file_references = paths.map { |sf| project.reference_for_path(sf) }
|
128
|
-
label = target.resources_bundle_target_label(bundle_name)
|
129
|
-
bundle_target = project.new_resources_bundle(label, file_accessor.spec_consumer.platform_name)
|
130
|
-
bundle_target.product_reference.tap do |bundle_product|
|
131
|
-
bundle_file_name = "#{bundle_name}.bundle"
|
132
|
-
bundle_product.name = bundle_file_name
|
133
|
-
bundle_product.path = bundle_file_name
|
134
|
-
end
|
135
|
-
bundle_target.add_resources(file_references)
|
136
|
-
|
137
|
-
target.user_build_configurations.each do |bc_name, type|
|
138
|
-
bundle_target.add_build_configuration(bc_name, type)
|
139
|
-
end
|
140
|
-
|
141
|
-
target.resource_bundle_targets << bundle_target
|
142
|
-
|
143
|
-
if target.should_build?
|
144
|
-
native_target.add_dependency(bundle_target)
|
145
|
-
if target.requires_frameworks?
|
146
|
-
native_target.add_resources([bundle_target.product_reference])
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
bundle_target.build_configurations.each do |c|
|
151
|
-
c.build_settings['PRODUCT_NAME'] = bundle_name
|
152
|
-
if target.requires_frameworks? && target.scoped?
|
153
|
-
c.build_settings['CONFIGURATION_BUILD_DIR'] = target.configuration_build_dir
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# Generates the contents of the xcconfig file and saves it to disk.
|
161
|
-
#
|
162
|
-
# @return [void]
|
163
|
-
#
|
164
|
-
def create_xcconfig_file
|
165
|
-
path = target.xcconfig_path
|
166
|
-
xcconfig_gen = Generator::XCConfig::PodXCConfig.new(target)
|
167
|
-
xcconfig_gen.save_as(path)
|
168
|
-
xcconfig_file_ref = add_file_to_support_group(path)
|
169
|
-
|
170
|
-
native_target.build_configurations.each do |c|
|
171
|
-
c.base_configuration_reference = xcconfig_file_ref
|
172
|
-
end
|
173
|
-
|
174
|
-
# also apply the private config to resource targets
|
175
|
-
target.resource_bundle_targets.each do |rsrc_target|
|
176
|
-
rsrc_target.build_configurations.each do |rsrc_bc|
|
177
|
-
rsrc_bc.base_configuration_reference = xcconfig_file_ref
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
|
183
|
-
# to the platform of the target. This file also include any prefix header
|
184
|
-
# content reported by the specification of the pods.
|
185
|
-
#
|
186
|
-
# @return [void]
|
187
|
-
#
|
188
|
-
def create_prefix_header
|
189
|
-
path = target.prefix_header_path
|
190
|
-
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
|
191
|
-
generator.save_as(path)
|
192
|
-
add_file_to_support_group(path)
|
193
|
-
|
194
|
-
native_target.build_configurations.each do |c|
|
195
|
-
relative_path = path.relative_path_from(project.path.dirname)
|
196
|
-
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
ENABLE_OBJECT_USE_OBJC_FROM = {
|
201
|
-
:ios => Version.new('6'),
|
202
|
-
:osx => Version.new('10.8'),
|
203
|
-
:watchos => Version.new('2.0'),
|
204
|
-
}
|
205
|
-
|
206
|
-
# Returns the compiler flags for the source files of the given specification.
|
207
|
-
#
|
208
|
-
# The following behavior is regarding the `OS_OBJECT_USE_OBJC` flag. When
|
209
|
-
# set to `0`, it will allow code to use `dispatch_release()` on >= iOS 6.0
|
210
|
-
# and OS X 10.8.
|
211
|
-
#
|
212
|
-
# * New libraries that do *not* require ARC don’t need to care about this
|
213
|
-
# issue at all.
|
214
|
-
#
|
215
|
-
# * New libraries that *do* require ARC _and_ have a deployment target of
|
216
|
-
# >= iOS 6.0 or OS X 10.8:
|
217
|
-
#
|
218
|
-
# These no longer use `dispatch_release()` and should *not* have the
|
219
|
-
# `OS_OBJECT_USE_OBJC` flag set to `0`.
|
220
|
-
#
|
221
|
-
# **Note:** this means that these libraries *have* to specify the
|
222
|
-
# deployment target in order to function well.
|
223
|
-
#
|
224
|
-
# * New libraries that *do* require ARC, but have a deployment target of
|
225
|
-
# < iOS 6.0 or OS X 10.8:
|
226
|
-
#
|
227
|
-
# These contain `dispatch_release()` calls and as such need the
|
228
|
-
# `OS_OBJECT_USE_OBJC` flag set to `1`.
|
229
|
-
#
|
230
|
-
# **Note:** libraries that do *not* specify a platform version are
|
231
|
-
# assumed to have a deployment target of < iOS 6.0 or OS X 10.8.
|
232
|
-
#
|
233
|
-
# For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
|
234
|
-
#
|
235
|
-
# @param [Specification::Consumer] consumer
|
236
|
-
# The consumer for the specification for which the compiler flags
|
237
|
-
# are needed.
|
238
|
-
#
|
239
|
-
# @return [String] The compiler flags.
|
240
|
-
#
|
241
|
-
def compiler_flags_for_consumer(consumer, arc)
|
242
|
-
flags = consumer.compiler_flags.dup
|
243
|
-
if !arc
|
244
|
-
flags << '-fno-objc-arc'
|
245
|
-
else
|
246
|
-
platform_name = consumer.platform_name
|
247
|
-
spec_deployment_target = consumer.spec.deployment_target(platform_name)
|
248
|
-
if spec_deployment_target.nil? || Version.new(spec_deployment_target) < ENABLE_OBJECT_USE_OBJC_FROM[platform_name]
|
249
|
-
flags << '-DOS_OBJECT_USE_OBJC=0'
|
250
|
-
end
|
251
|
-
end
|
252
|
-
if target.inhibit_warnings?
|
253
|
-
flags << '-w -Xanalyzer -analyzer-disable-all-checks'
|
254
|
-
end
|
255
|
-
flags * ' '
|
256
|
-
end
|
257
|
-
|
258
|
-
# Adds a reference to the given file in the support group of this target.
|
259
|
-
#
|
260
|
-
# @param [Pathname] path
|
261
|
-
# The path of the file to which the reference should be added.
|
262
|
-
#
|
263
|
-
# @return [PBXFileReference] the file reference of the added file.
|
264
|
-
#
|
265
|
-
def add_file_to_support_group(path)
|
266
|
-
pod_name = target.pod_name
|
267
|
-
dir = target.support_files_dir
|
268
|
-
group = project.pod_support_files_group(pod_name, dir)
|
269
|
-
group.new_file(path)
|
270
|
-
end
|
271
|
-
|
272
|
-
def create_module_map
|
273
|
-
return super unless custom_module_map
|
274
|
-
path = target.module_map_path
|
275
|
-
UI.message "- Copying module map file to #{UI.path(path)}" do
|
276
|
-
FileUtils.cp(custom_module_map, path)
|
277
|
-
add_file_to_support_group(path)
|
278
|
-
|
279
|
-
native_target.build_configurations.each do |c|
|
280
|
-
relative_path = path.relative_path_from(sandbox.root)
|
281
|
-
c.build_settings['MODULEMAP_FILE'] = relative_path.to_s
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def create_umbrella_header
|
287
|
-
return super unless custom_module_map
|
288
|
-
end
|
289
|
-
|
290
|
-
def custom_module_map
|
291
|
-
@custom_module_map ||= target.file_accessors.first.module_map
|
292
|
-
end
|
293
|
-
|
294
|
-
#-----------------------------------------------------------------------#
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
@@ -1,318 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections'
|
2
|
-
|
3
|
-
module Pod
|
4
|
-
class Installer
|
5
|
-
class UserProjectIntegrator
|
6
|
-
# This class is responsible for integrating the library generated by a
|
7
|
-
# {TargetDefinition} with its destination project.
|
8
|
-
#
|
9
|
-
class TargetIntegrator
|
10
|
-
autoload :XCConfigIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator'
|
11
|
-
|
12
|
-
# @return [Array<Symbol>] the symbol types, which require that the pod
|
13
|
-
# frameworks are embedded in the output directory / product bundle.
|
14
|
-
#
|
15
|
-
EMBED_FRAMEWORK_TARGET_TYPES = [:application, :unit_test_bundle, :app_extension, :watch_extension, :watch2_extension].freeze
|
16
|
-
|
17
|
-
# @return [String] the name of the embed frameworks phase
|
18
|
-
#
|
19
|
-
EMBED_FRAMEWORK_PHASE_NAME = 'Embed Pods Frameworks'.freeze
|
20
|
-
|
21
|
-
# @return [AggregateTarget] the target that should be integrated.
|
22
|
-
#
|
23
|
-
attr_reader :target
|
24
|
-
|
25
|
-
# Init a new TargetIntegrator
|
26
|
-
#
|
27
|
-
# @param [AggregateTarget] target @see #target
|
28
|
-
#
|
29
|
-
def initialize(target)
|
30
|
-
@target = target
|
31
|
-
end
|
32
|
-
|
33
|
-
# Integrates the user project targets. Only the targets that do **not**
|
34
|
-
# already have the Pods library in their frameworks build phase are
|
35
|
-
# processed.
|
36
|
-
#
|
37
|
-
# @return [void]
|
38
|
-
#
|
39
|
-
def integrate!
|
40
|
-
UI.section(integration_message) do
|
41
|
-
# TODO: refactor into Xcodeproj https://github.com/CocoaPods/Xcodeproj/issues/202
|
42
|
-
project_is_dirty = [
|
43
|
-
XCConfigIntegrator.integrate(target, native_targets),
|
44
|
-
update_to_cocoapods_0_34,
|
45
|
-
update_to_cocoapods_0_37_1,
|
46
|
-
update_to_cocoapods_0_39,
|
47
|
-
unless native_targets_to_integrate.empty?
|
48
|
-
add_pods_library
|
49
|
-
add_embed_frameworks_script_phase
|
50
|
-
add_copy_resources_script_phase
|
51
|
-
add_check_manifest_lock_script_phase
|
52
|
-
true
|
53
|
-
end,
|
54
|
-
].any?
|
55
|
-
|
56
|
-
if project_is_dirty
|
57
|
-
user_project.save
|
58
|
-
else
|
59
|
-
# There is a bug in Xcode where the process of deleting and
|
60
|
-
# re-creating the xcconfig files used in the build
|
61
|
-
# configuration cause building the user project to fail until
|
62
|
-
# Xcode is relaunched.
|
63
|
-
#
|
64
|
-
# Touching/saving the project causes Xcode to reload these.
|
65
|
-
#
|
66
|
-
# https://github.com/CocoaPods/CocoaPods/issues/2665
|
67
|
-
FileUtils.touch(user_project.path + 'project.pbxproj')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [String] a string representation suitable for debugging.
|
73
|
-
#
|
74
|
-
def inspect
|
75
|
-
"#<#{self.class} for target `#{target.label}'>"
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
# @!group Integration steps
|
81
|
-
#---------------------------------------------------------------------#
|
82
|
-
|
83
|
-
# Fixes the paths of the copy resource scripts.
|
84
|
-
#
|
85
|
-
# @return [Bool] whether any changes to the project were made.
|
86
|
-
#
|
87
|
-
# @todo This can be removed for CocoaPods 1.0
|
88
|
-
#
|
89
|
-
def update_to_cocoapods_0_34
|
90
|
-
phases = native_targets.map do |target|
|
91
|
-
target.shell_script_build_phases.select do |bp|
|
92
|
-
bp.name == 'Copy Pods Resources'
|
93
|
-
end
|
94
|
-
end.flatten
|
95
|
-
|
96
|
-
script_path = target.copy_resources_script_relative_path
|
97
|
-
shell_script = %("#{script_path}"\n)
|
98
|
-
changes = false
|
99
|
-
phases.each do |phase|
|
100
|
-
unless phase.shell_script == shell_script
|
101
|
-
phase.shell_script = shell_script
|
102
|
-
changes = true
|
103
|
-
end
|
104
|
-
end
|
105
|
-
changes
|
106
|
-
end
|
107
|
-
|
108
|
-
# Removes the embed frameworks phase for target types.
|
109
|
-
#
|
110
|
-
# @return [Bool] whether any changes to the project were made.
|
111
|
-
#
|
112
|
-
# @todo This can be removed for CocoaPods 1.0
|
113
|
-
#
|
114
|
-
def update_to_cocoapods_0_37_1
|
115
|
-
targets_to_embed = native_targets.select do |target|
|
116
|
-
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
|
117
|
-
end
|
118
|
-
(native_targets - targets_to_embed).any? do |native_target|
|
119
|
-
remove_embed_frameworks_script_phase(native_target)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# Adds the embed frameworks script when integrating as a static library.
|
124
|
-
#
|
125
|
-
# @return [Bool] whether any changes to the project were made.
|
126
|
-
#
|
127
|
-
# @todo This can be removed for CocoaPods 1.0
|
128
|
-
#
|
129
|
-
def update_to_cocoapods_0_39
|
130
|
-
requires_update = native_targets_to_embed_in.any? do |target|
|
131
|
-
!target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
|
132
|
-
end
|
133
|
-
if requires_update
|
134
|
-
add_embed_frameworks_script_phase
|
135
|
-
true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
# Adds spec product reference to the frameworks build phase of the
|
140
|
-
# {TargetDefinition} integration libraries. Adds a file reference to
|
141
|
-
# the frameworks group of the project and adds it to the frameworks
|
142
|
-
# build phase of the targets.
|
143
|
-
#
|
144
|
-
# @return [void]
|
145
|
-
#
|
146
|
-
def add_pods_library
|
147
|
-
frameworks = user_project.frameworks_group
|
148
|
-
native_targets_to_integrate.each do |native_target|
|
149
|
-
build_phase = native_target.frameworks_build_phase
|
150
|
-
|
151
|
-
# Find and delete possible reference for the other product type
|
152
|
-
old_product_name = target.requires_frameworks? ? target.static_library_name : target.framework_name
|
153
|
-
old_product_ref = frameworks.files.find { |f| f.path == old_product_name }
|
154
|
-
if old_product_ref.present?
|
155
|
-
UI.message("Removing old Pod product reference #{old_product_name} from project.")
|
156
|
-
build_phase.remove_file_reference(old_product_ref)
|
157
|
-
frameworks.remove_reference(old_product_ref)
|
158
|
-
end
|
159
|
-
|
160
|
-
# Find or create and add a reference for the current product type
|
161
|
-
target_basename = target.product_basename
|
162
|
-
new_product_ref = frameworks.files.find { |f| f.path == target.product_name } ||
|
163
|
-
frameworks.new_product_ref_for_target(target_basename, target.product_type)
|
164
|
-
build_file = build_phase.build_file(new_product_ref) ||
|
165
|
-
build_phase.add_file_reference(new_product_ref, true)
|
166
|
-
if target.requires_frameworks?
|
167
|
-
# Weak link the aggregate target's product, because as it contains
|
168
|
-
# no symbols, it isn't copied into the app bundle. dyld will so
|
169
|
-
# never try to find the missing executable at runtime.
|
170
|
-
build_file.settings ||= {}
|
171
|
-
build_file.settings['ATTRIBUTES'] = ['Weak']
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# Find or create a 'Embed Pods Frameworks' Copy Files Build Phase
|
177
|
-
#
|
178
|
-
# @return [void]
|
179
|
-
#
|
180
|
-
def add_embed_frameworks_script_phase
|
181
|
-
native_targets_to_embed_in.each do |native_target|
|
182
|
-
phase = create_or_update_build_phase(native_target, EMBED_FRAMEWORK_PHASE_NAME)
|
183
|
-
script_path = target.embed_frameworks_script_relative_path
|
184
|
-
phase.shell_script = %("#{script_path}"\n)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# Delete a 'Embed Pods Frameworks' Copy Files Build Phase if present
|
189
|
-
#
|
190
|
-
# @param [PBXNativeTarget] native_target
|
191
|
-
#
|
192
|
-
# @return [Bool] whether any changes to the project were made.
|
193
|
-
#
|
194
|
-
def remove_embed_frameworks_script_phase(native_target)
|
195
|
-
embed_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
|
196
|
-
return false unless embed_build_phase.present?
|
197
|
-
native_target.build_phases.delete(embed_build_phase)
|
198
|
-
true
|
199
|
-
end
|
200
|
-
|
201
|
-
# Adds a shell script build phase responsible to copy the resources
|
202
|
-
# generated by the TargetDefinition to the bundle of the product of the
|
203
|
-
# targets.
|
204
|
-
#
|
205
|
-
# @return [void]
|
206
|
-
#
|
207
|
-
def add_copy_resources_script_phase
|
208
|
-
phase_name = 'Copy Pods Resources'
|
209
|
-
native_targets_to_integrate.each do |native_target|
|
210
|
-
phase = create_or_update_build_phase(native_target, phase_name)
|
211
|
-
script_path = target.copy_resources_script_relative_path
|
212
|
-
phase.shell_script = %("#{script_path}"\n)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Adds a shell script build phase responsible for checking if the Pods
|
217
|
-
# locked in the Pods/Manifest.lock file are in sync with the Pods defined
|
218
|
-
# in the Podfile.lock.
|
219
|
-
#
|
220
|
-
# @note The build phase is appended to the front because to fail
|
221
|
-
# fast.
|
222
|
-
#
|
223
|
-
# @return [void]
|
224
|
-
#
|
225
|
-
def add_check_manifest_lock_script_phase
|
226
|
-
phase_name = 'Check Pods Manifest.lock'
|
227
|
-
native_targets_to_integrate.each do |native_target|
|
228
|
-
phase = create_or_update_build_phase(native_target, phase_name)
|
229
|
-
native_target.build_phases.unshift(phase).uniq!
|
230
|
-
phase.shell_script = <<-EOS.strip_heredoc
|
231
|
-
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
|
232
|
-
if [[ $? != 0 ]] ; then
|
233
|
-
cat << EOM
|
234
|
-
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
|
235
|
-
EOM
|
236
|
-
exit 1
|
237
|
-
fi
|
238
|
-
EOS
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
private
|
243
|
-
|
244
|
-
# @!group Private helpers
|
245
|
-
#---------------------------------------------------------------------#
|
246
|
-
|
247
|
-
# @return [Array<PBXNativeTarget>] The list of all the targets that
|
248
|
-
# match the given target.
|
249
|
-
#
|
250
|
-
def native_targets
|
251
|
-
@native_targets ||= target.user_targets(user_project)
|
252
|
-
end
|
253
|
-
|
254
|
-
# @return [Array<PBXNativeTarget>] The list of all the targets that
|
255
|
-
# require that the pod frameworks are embedded in the output
|
256
|
-
# directory / product bundle.
|
257
|
-
#
|
258
|
-
def native_targets_to_embed_in
|
259
|
-
native_targets_to_integrate.select do |target|
|
260
|
-
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
# @return [Array<PBXNativeTarget>] The list of the targets
|
265
|
-
# that have not been integrated by past installations
|
266
|
-
# of
|
267
|
-
#
|
268
|
-
def native_targets_to_integrate
|
269
|
-
unless @native_targets_to_integrate
|
270
|
-
@native_targets_to_integrate = native_targets.reject do |native_target|
|
271
|
-
native_target.frameworks_build_phase.files.any? do |build_file|
|
272
|
-
file_ref = build_file.file_ref
|
273
|
-
file_ref &&
|
274
|
-
file_ref.isa == 'PBXFileReference' &&
|
275
|
-
file_ref.display_name == target.product_name
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|
279
|
-
@native_targets_to_integrate
|
280
|
-
end
|
281
|
-
|
282
|
-
# Read the project from the disk to ensure that it is up to date as
|
283
|
-
# other TargetIntegrators might have modified it.
|
284
|
-
#
|
285
|
-
# @return [Project]
|
286
|
-
#
|
287
|
-
def user_project
|
288
|
-
@user_project ||= Xcodeproj::Project.open(target.user_project_path)
|
289
|
-
end
|
290
|
-
|
291
|
-
# @return [Specification::Consumer] the consumer for the specifications.
|
292
|
-
#
|
293
|
-
def spec_consumers
|
294
|
-
@spec_consumers ||= target.pod_targets.map(&:file_accessors).flatten.map(&:spec_consumer)
|
295
|
-
end
|
296
|
-
|
297
|
-
# @return [String] the message that should be displayed for the target
|
298
|
-
# integration.
|
299
|
-
#
|
300
|
-
def integration_message
|
301
|
-
"Integrating target `#{target.name}` " \
|
302
|
-
"(#{UI.path target.user_project_path} project)"
|
303
|
-
end
|
304
|
-
|
305
|
-
def create_or_update_build_phase(target, phase_name, phase_class = Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
|
306
|
-
target.build_phases.grep(phase_class).find { |phase| phase.name == phase_name } ||
|
307
|
-
target.project.new(phase_class).tap do |phase|
|
308
|
-
UI.message("Adding Build Phase '#{phase_name}' to project.") do
|
309
|
-
phase.name = phase_name
|
310
|
-
phase.show_env_vars_in_log = '0'
|
311
|
-
target.build_phases << phase
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|