cocoapods 1.4.0.beta.1 → 1.4.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +81 -2
- data/lib/cocoapods.rb +1 -0
- data/lib/cocoapods/gem_version.rb +1 -1
- data/lib/cocoapods/generator/app_target_helper.rb +227 -0
- data/lib/cocoapods/generator/embed_frameworks_script.rb +9 -0
- data/lib/cocoapods/generator/info_plist_file.rb +13 -22
- data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +1 -0
- data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +49 -32
- data/lib/cocoapods/installer.rb +20 -14
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +46 -32
- data/lib/cocoapods/installer/xcode/pods_project_generator.rb +20 -12
- data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +1 -1
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +88 -11
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +101 -0
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +17 -3
- data/lib/cocoapods/target.rb +9 -7
- data/lib/cocoapods/target/aggregate_target.rb +1 -1
- data/lib/cocoapods/target/pod_target.rb +103 -43
- data/lib/cocoapods/validator.rb +25 -66
- metadata +10 -9
- data/lib/cocoapods/installer/pods_project_integrator/pod_target_integrator.rb +0 -85
@@ -63,8 +63,8 @@ module Pod
|
|
63
63
|
|
64
64
|
# Configures the given Xcconfig
|
65
65
|
#
|
66
|
-
# @param [
|
67
|
-
# The
|
66
|
+
# @param [Target] target
|
67
|
+
# The root target, may be nil.
|
68
68
|
#
|
69
69
|
# @param [PodTarget] pod_target
|
70
70
|
# The pod target, which holds the list of +Spec::FileAccessor+.
|
@@ -72,27 +72,30 @@ module Pod
|
|
72
72
|
# @param [Xcodeproj::Config] xcconfig
|
73
73
|
# The xcconfig to edit.
|
74
74
|
#
|
75
|
+
# @param [Boolean] include_ld_flags
|
76
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
77
|
+
#
|
75
78
|
# @return [void]
|
76
79
|
#
|
77
|
-
def self.add_settings_for_file_accessors_of_target(
|
80
|
+
def self.add_settings_for_file_accessors_of_target(target, pod_target, xcconfig, include_ld_flags = true)
|
78
81
|
pod_target.file_accessors.each do |file_accessor|
|
79
|
-
if
|
80
|
-
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig)
|
81
|
-
XCConfigHelper.add_static_dependency_build_settings(
|
82
|
+
if target.nil? || !file_accessor.spec.test_specification?
|
83
|
+
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig) if include_ld_flags
|
84
|
+
XCConfigHelper.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags)
|
82
85
|
end
|
83
86
|
end
|
84
|
-
XCConfigHelper.add_dynamic_dependency_build_settings(
|
87
|
+
XCConfigHelper.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags)
|
85
88
|
if pod_target.requires_frameworks?
|
86
89
|
pod_target.dependent_targets.each do |dependent_target|
|
87
|
-
XCConfigHelper.add_dynamic_dependency_build_settings(
|
90
|
+
XCConfigHelper.add_dynamic_dependency_build_settings(target, dependent_target, xcconfig, include_ld_flags)
|
88
91
|
end
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
92
95
|
# Adds build settings for static vendored frameworks and libraries.
|
93
96
|
#
|
94
|
-
# @param [
|
95
|
-
# The
|
97
|
+
# @param [Target] target
|
98
|
+
# The root target, may be nil.
|
96
99
|
#
|
97
100
|
# @param [PodTarget] pod_target
|
98
101
|
# The pod target, which holds the list of +Spec::FileAccessor+.
|
@@ -103,16 +106,18 @@ module Pod
|
|
103
106
|
# @param [Spec::FileAccessor] file_accessor
|
104
107
|
# The file accessor, which holds the list of static frameworks.
|
105
108
|
#
|
109
|
+
# @param [Boolean] include_ld_flags
|
110
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
111
|
+
#
|
106
112
|
# @return [void]
|
107
113
|
#
|
108
|
-
def self.add_static_dependency_build_settings(
|
109
|
-
if
|
114
|
+
def self.add_static_dependency_build_settings(target, pod_target, xcconfig, file_accessor, include_ld_flags)
|
115
|
+
if target.nil? || !file_accessor.spec.test_specification?
|
116
|
+
adds_other_ldflags = include_ld_flags && XCConfigHelper.links_dependency?(target, pod_target)
|
110
117
|
file_accessor.vendored_static_frameworks.each do |vendored_static_framework|
|
111
|
-
adds_other_ldflags = XCConfigHelper.links_dependency?(aggregate_target, pod_target)
|
112
118
|
XCConfigHelper.add_framework_build_settings(vendored_static_framework, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
|
113
119
|
end
|
114
120
|
file_accessor.vendored_static_libraries.each do |vendored_static_library|
|
115
|
-
adds_other_ldflags = XCConfigHelper.links_dependency?(aggregate_target, pod_target)
|
116
121
|
XCConfigHelper.add_library_build_settings(vendored_static_library, xcconfig, pod_target.sandbox.root, adds_other_ldflags)
|
117
122
|
end
|
118
123
|
end
|
@@ -136,8 +141,8 @@ module Pod
|
|
136
141
|
|
137
142
|
# Adds build settings for dynamic vendored frameworks and libraries.
|
138
143
|
#
|
139
|
-
# @param [
|
140
|
-
# The
|
144
|
+
# @param [Target] target
|
145
|
+
# The root target, may be nil.
|
141
146
|
#
|
142
147
|
# @param [PodTarget] pod_target
|
143
148
|
# The pod target, which holds the list of +Spec::FileAccessor+.
|
@@ -145,16 +150,19 @@ module Pod
|
|
145
150
|
# @param [Xcodeproj::Config] xcconfig
|
146
151
|
# The xcconfig to edit.
|
147
152
|
#
|
153
|
+
# @param [Boolean] include_ld_flags
|
154
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
155
|
+
#
|
148
156
|
# @return [void]
|
149
157
|
#
|
150
|
-
def self.add_dynamic_dependency_build_settings(
|
158
|
+
def self.add_dynamic_dependency_build_settings(target, pod_target, xcconfig, include_ld_flags)
|
151
159
|
pod_target.file_accessors.each do |file_accessor|
|
152
|
-
if
|
160
|
+
if target.nil? || !file_accessor.spec.test_specification?
|
153
161
|
file_accessor.vendored_dynamic_frameworks.each do |vendored_dynamic_framework|
|
154
|
-
XCConfigHelper.add_framework_build_settings(vendored_dynamic_framework, xcconfig, pod_target.sandbox.root)
|
162
|
+
XCConfigHelper.add_framework_build_settings(vendored_dynamic_framework, xcconfig, pod_target.sandbox.root, include_ld_flags)
|
155
163
|
end
|
156
164
|
file_accessor.vendored_dynamic_libraries.each do |vendored_dynamic_library|
|
157
|
-
XCConfigHelper.add_library_build_settings(vendored_dynamic_library, xcconfig, pod_target.sandbox.root)
|
165
|
+
XCConfigHelper.add_library_build_settings(vendored_dynamic_library, xcconfig, pod_target.sandbox.root, include_ld_flags)
|
158
166
|
end
|
159
167
|
end
|
160
168
|
end
|
@@ -190,15 +198,18 @@ module Pod
|
|
190
198
|
# @param [Pathname] sandbox_root
|
191
199
|
# The path retrieved from Sandbox#root.
|
192
200
|
#
|
201
|
+
# @param [Boolean] include_ld_flags
|
202
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
203
|
+
#
|
193
204
|
# @return [void]
|
194
205
|
#
|
195
|
-
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root,
|
206
|
+
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root, include_ld_flags = true)
|
196
207
|
name = File.basename(framework_path, '.framework')
|
197
208
|
dirname = '${PODS_ROOT}/' + framework_path.dirname.relative_path_from(sandbox_root).to_s
|
198
209
|
build_settings = {
|
199
210
|
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
|
200
211
|
}
|
201
|
-
build_settings['OTHER_LDFLAGS'] = "-framework #{name}" if
|
212
|
+
build_settings['OTHER_LDFLAGS'] = "-framework #{name}" if include_ld_flags
|
202
213
|
xcconfig.merge!(build_settings)
|
203
214
|
end
|
204
215
|
|
@@ -214,16 +225,19 @@ module Pod
|
|
214
225
|
# @param [Pathname] sandbox_root
|
215
226
|
# The path retrieved from Sandbox#root.
|
216
227
|
#
|
228
|
+
# @param [Boolean] include_ld_flags
|
229
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
230
|
+
#
|
217
231
|
# @return [void]
|
218
232
|
#
|
219
|
-
def self.add_library_build_settings(library_path, xcconfig, sandbox_root,
|
233
|
+
def self.add_library_build_settings(library_path, xcconfig, sandbox_root, include_ld_flags = true)
|
220
234
|
extension = File.extname(library_path)
|
221
235
|
name = File.basename(library_path, extension).sub(/\Alib/, '')
|
222
236
|
dirname = '${PODS_ROOT}/' + library_path.dirname.relative_path_from(sandbox_root).to_s
|
223
237
|
build_settings = {
|
224
238
|
'LIBRARY_SEARCH_PATHS' => quote([dirname]),
|
225
239
|
}
|
226
|
-
build_settings['OTHER_LDFLAGS'] = "-l#{name}" if
|
240
|
+
build_settings['OTHER_LDFLAGS'] = "-l#{name}" if include_ld_flags
|
227
241
|
xcconfig.merge!(build_settings)
|
228
242
|
end
|
229
243
|
|
@@ -350,25 +364,28 @@ module Pod
|
|
350
364
|
# Add custom build settings and required build settings to link to
|
351
365
|
# vendored libraries and frameworks.
|
352
366
|
#
|
353
|
-
# @param [
|
354
|
-
# The
|
367
|
+
# @param [Target] target
|
368
|
+
# The root target, may be nil.
|
355
369
|
#
|
356
|
-
# @param [Array<PodTarget]
|
357
|
-
# The
|
370
|
+
# @param [Array<PodTarget] dep_targets
|
371
|
+
# The dependency targets to add the vendored build settings for.
|
358
372
|
#
|
359
373
|
# @param [Xcodeproj::Config] xcconfig
|
360
374
|
# The xcconfig to edit.
|
361
375
|
#
|
376
|
+
# @param [Boolean] include_ld_flags
|
377
|
+
# Indicates whether or not to generate ld flags in addition to compile flags
|
378
|
+
#
|
362
379
|
# @note
|
363
380
|
# In case of generated pod targets, which require frameworks, the
|
364
381
|
# vendored frameworks and libraries are already linked statically
|
365
382
|
# into the framework binary and must not be linked again to the
|
366
383
|
# user target.
|
367
384
|
#
|
368
|
-
def self.generate_vendored_build_settings(
|
369
|
-
|
370
|
-
unless
|
371
|
-
XCConfigHelper.add_settings_for_file_accessors_of_target(
|
385
|
+
def self.generate_vendored_build_settings(target, dep_targets, xcconfig, include_ld_flags = true)
|
386
|
+
dep_targets.each do |dep_target|
|
387
|
+
unless dep_target.should_build? && dep_target.requires_frameworks? && !dep_target.static_framework?
|
388
|
+
XCConfigHelper.add_settings_for_file_accessors_of_target(target, dep_target, xcconfig, include_ld_flags)
|
372
389
|
end
|
373
390
|
end
|
374
391
|
end
|
data/lib/cocoapods/installer.rb
CHANGED
@@ -355,7 +355,7 @@ module Pod
|
|
355
355
|
end
|
356
356
|
|
357
357
|
# Install the Pods. If the resolver indicated that a Pod should be
|
358
|
-
# installed and it exits, it is removed
|
358
|
+
# installed and it exits, it is removed and then reinstalled. In any case if
|
359
359
|
# the Pod doesn't exits it is installed.
|
360
360
|
#
|
361
361
|
# @return [void]
|
@@ -423,6 +423,7 @@ module Pod
|
|
423
423
|
unlock_pod_sources
|
424
424
|
run_plugins_post_install_hooks
|
425
425
|
warn_for_deprecations
|
426
|
+
warn_for_installed_script_phases
|
426
427
|
lock_pod_sources
|
427
428
|
print_post_install_message
|
428
429
|
end
|
@@ -523,6 +524,24 @@ module Pod
|
|
523
524
|
end
|
524
525
|
end
|
525
526
|
|
527
|
+
# Prints a warning for any pods that included script phases
|
528
|
+
#
|
529
|
+
# @return [void]
|
530
|
+
#
|
531
|
+
def warn_for_installed_script_phases
|
532
|
+
pods_to_install = sandbox_state.added | sandbox_state.changed
|
533
|
+
pod_targets.each do |pod_target|
|
534
|
+
spec = pod_target.root_spec
|
535
|
+
if pods_to_install.include?(spec.name)
|
536
|
+
script_phase_count = pod_target.script_phases.count
|
537
|
+
unless script_phase_count.zero?
|
538
|
+
UI.warn "#{spec.name} has added #{pod_target.script_phases.count} #{'script phase'.pluralize(script_phase_count)}. " \
|
539
|
+
'Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.'
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
526
545
|
# Writes the Podfile and the lock files.
|
527
546
|
#
|
528
547
|
# @todo Pass the checkout options to the Lockfile.
|
@@ -626,19 +645,6 @@ module Pod
|
|
626
645
|
|
627
646
|
#-------------------------------------------------------------------------#
|
628
647
|
|
629
|
-
public
|
630
|
-
|
631
|
-
# @return [Array<Library>] The targets of the development pods generated by
|
632
|
-
# the installation process.
|
633
|
-
#
|
634
|
-
def development_pod_targets
|
635
|
-
pod_targets.select do |pod_target|
|
636
|
-
sandbox.development_pods.keys.include?(pod_target.pod_name)
|
637
|
-
end
|
638
|
-
end
|
639
|
-
|
640
|
-
#-------------------------------------------------------------------------#
|
641
|
-
|
642
648
|
private
|
643
649
|
|
644
650
|
# @!group Private helpers
|
@@ -147,6 +147,49 @@ module Pod
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
|
+
|
151
|
+
# Updates all target script phases for the current target, including creating or updating, deleting
|
152
|
+
# and re-ordering.
|
153
|
+
#
|
154
|
+
# @return [void]
|
155
|
+
#
|
156
|
+
def create_or_update_user_script_phases(script_phases, native_target)
|
157
|
+
script_phase_names = script_phases.map { |k| k[:name] }
|
158
|
+
# Delete script phases no longer present in the target definition.
|
159
|
+
native_target_script_phases = native_target.shell_script_build_phases.select { |bp| !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX) }
|
160
|
+
native_target_script_phases.each do |script_phase|
|
161
|
+
script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '')
|
162
|
+
unless script_phase_names.include?(script_phase_name_without_prefix)
|
163
|
+
native_target.build_phases.delete(script_phase)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
# Create or update the ones that are expected to be.
|
167
|
+
script_phases.each do |td_script_phase|
|
168
|
+
name_with_prefix = USER_BUILD_PHASE_PREFIX + td_script_phase[:name]
|
169
|
+
phase = TargetIntegrator.create_or_update_build_phase(native_target, name_with_prefix)
|
170
|
+
phase.shell_script = td_script_phase[:script]
|
171
|
+
phase.shell_path = td_script_phase[:shell_path] if td_script_phase.key?(:shell_path)
|
172
|
+
phase.input_paths = td_script_phase[:input_files] if td_script_phase.key?(:input_files)
|
173
|
+
phase.output_paths = td_script_phase[:output_files] if td_script_phase.key?(:output_files)
|
174
|
+
phase.show_env_vars_in_log = td_script_phase[:show_env_vars_in_log] ? '1' : '0' if td_script_phase.key?(:show_env_vars_in_log)
|
175
|
+
|
176
|
+
execution_position = td_script_phase[:execution_position]
|
177
|
+
unless execution_position == :any
|
178
|
+
compile_build_phase_index = native_target.build_phases.index do |bp|
|
179
|
+
bp.is_a?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
|
180
|
+
end
|
181
|
+
unless compile_build_phase_index.nil?
|
182
|
+
script_phase_index = native_target.build_phases.index do |bp|
|
183
|
+
bp.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && !bp.name.nil? && bp.name == name_with_prefix
|
184
|
+
end
|
185
|
+
if (execution_position == :before_compile && script_phase_index > compile_build_phase_index) ||
|
186
|
+
(execution_position == :after_compile && script_phase_index < compile_build_phase_index)
|
187
|
+
native_target.build_phases.move_from(script_phase_index, compile_build_phase_index)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
150
193
|
end
|
151
194
|
|
152
195
|
# Integrates the user project targets. Only the targets that do **not**
|
@@ -164,7 +207,7 @@ module Pod
|
|
164
207
|
remove_embed_frameworks_script_phase_from_embedded_targets
|
165
208
|
add_copy_resources_script_phase
|
166
209
|
add_check_manifest_lock_script_phase
|
167
|
-
|
210
|
+
add_user_script_phases
|
168
211
|
end
|
169
212
|
end
|
170
213
|
|
@@ -265,38 +308,9 @@ module Pod
|
|
265
308
|
#
|
266
309
|
# @return [void]
|
267
310
|
#
|
268
|
-
def
|
269
|
-
target_definition_script_phases = target.target_definition.script_phases
|
270
|
-
target_definition_script_phase_names = target_definition_script_phases.map { |k| k[:name] }
|
311
|
+
def add_user_script_phases
|
271
312
|
native_targets.each do |native_target|
|
272
|
-
|
273
|
-
native_target_script_phases = native_target.shell_script_build_phases.select { |bp| !bp.name.nil? && bp.name.start_with?(USER_BUILD_PHASE_PREFIX) }
|
274
|
-
native_target_script_phases.each do |script_phase|
|
275
|
-
script_phase_name_without_prefix = script_phase.name.sub(USER_BUILD_PHASE_PREFIX, '')
|
276
|
-
unless target_definition_script_phase_names.include?(script_phase_name_without_prefix)
|
277
|
-
native_target.build_phases.delete(script_phase)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
# Create or update the ones that are expected to be.
|
282
|
-
target_definition_script_phases.each do |td_script_phase|
|
283
|
-
phase = TargetIntegrator.create_or_update_build_phase(native_target, USER_BUILD_PHASE_PREFIX + td_script_phase[:name])
|
284
|
-
phase.shell_script = td_script_phase[:script]
|
285
|
-
phase.shell_path = td_script_phase[:shell_path] if td_script_phase.key?(:shell_path)
|
286
|
-
phase.input_paths = td_script_phase[:input_files] if td_script_phase.key?(:input_files)
|
287
|
-
phase.output_paths = td_script_phase[:output_files] if td_script_phase.key?(:output_files)
|
288
|
-
phase.show_env_vars_in_log = td_script_phase[:show_env_vars_in_log] ? '1' : '0' if td_script_phase.key?(:show_env_vars_in_log)
|
289
|
-
end
|
290
|
-
|
291
|
-
# Move script phases to their correct index if the order has changed.
|
292
|
-
offset = native_target.build_phases.count - target_definition_script_phases.count
|
293
|
-
target_definition_script_phases.each_with_index do |td_script_phase, index|
|
294
|
-
current_index = native_target.build_phases.index do |bp|
|
295
|
-
bp.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && bp.name.sub(USER_BUILD_PHASE_PREFIX, '') == td_script_phase[:name]
|
296
|
-
end
|
297
|
-
expected_index = offset + index
|
298
|
-
native_target.build_phases.insert(expected_index, native_target.build_phases.delete_at(current_index)) if current_index != expected_index
|
299
|
-
end
|
313
|
+
TargetIntegrator.create_or_update_user_script_phases(target.target_definition.script_phases, native_target)
|
300
314
|
end
|
301
315
|
end
|
302
316
|
|
@@ -4,7 +4,7 @@ module Pod
|
|
4
4
|
# The {PodsProjectGenerator} handles generation of the 'Pods/Pods.xcodeproj'
|
5
5
|
#
|
6
6
|
class PodsProjectGenerator
|
7
|
-
require 'cocoapods/installer/
|
7
|
+
require 'cocoapods/installer/xcode/pods_project_generator/pod_target_integrator'
|
8
8
|
require 'cocoapods/installer/xcode/pods_project_generator/target_installer'
|
9
9
|
require 'cocoapods/installer/xcode/pods_project_generator/pod_target_installer'
|
10
10
|
require 'cocoapods/installer/xcode/pods_project_generator/file_references_installer'
|
@@ -63,7 +63,7 @@ module Pod
|
|
63
63
|
prepare
|
64
64
|
install_file_references
|
65
65
|
install_libraries
|
66
|
-
|
66
|
+
integrate_targets
|
67
67
|
set_target_dependencies
|
68
68
|
end
|
69
69
|
|
@@ -124,6 +124,8 @@ module Pod
|
|
124
124
|
analysis_result.all_user_build_configurations.each do |name, type|
|
125
125
|
@project.add_build_configuration(name, type)
|
126
126
|
end
|
127
|
+
# Reset symroot just in case the user has added a new build configuration other than 'Debug' or 'Release'.
|
128
|
+
@project.symroot = Pod::Project::LEGACY_BUILD_ROOT
|
127
129
|
|
128
130
|
pod_names = pod_targets.map(&:pod_name).uniq
|
129
131
|
pod_names.each do |pod_name|
|
@@ -177,12 +179,12 @@ module Pod
|
|
177
179
|
end
|
178
180
|
end
|
179
181
|
|
180
|
-
def
|
181
|
-
|
182
|
-
unless
|
183
|
-
UI.message '- Integrating
|
184
|
-
|
185
|
-
|
182
|
+
def integrate_targets
|
183
|
+
pod_targets_to_integrate = pod_targets.select { |pt| !pt.test_native_targets.empty? || pt.contains_script_phases? }
|
184
|
+
unless pod_targets_to_integrate.empty?
|
185
|
+
UI.message '- Integrating targets' do
|
186
|
+
pod_targets_to_integrate.each do |pod_target|
|
187
|
+
PodTargetIntegrator.new(pod_target).integrate!
|
186
188
|
end
|
187
189
|
end
|
188
190
|
end
|
@@ -227,10 +229,11 @@ module Pod
|
|
227
229
|
aggregate_target.native_target.add_dependency(pod_target.native_target)
|
228
230
|
configure_app_extension_api_only_for_target(pod_target) if is_app_extension
|
229
231
|
|
232
|
+
add_dependent_targets_to_native_target(pod_target.dependent_targets,
|
233
|
+
pod_target.native_target, is_app_extension,
|
234
|
+
pod_target.requires_frameworks? && !pod_target.static_framework?,
|
235
|
+
frameworks_group)
|
230
236
|
unless pod_target.static_framework?
|
231
|
-
add_dependent_targets_to_native_target(pod_target.dependent_targets,
|
232
|
-
pod_target.native_target, is_app_extension,
|
233
|
-
pod_target.requires_frameworks?, frameworks_group)
|
234
237
|
add_pod_target_test_dependencies(pod_target, frameworks_group)
|
235
238
|
end
|
236
239
|
end
|
@@ -285,11 +288,16 @@ module Pod
|
|
285
288
|
|
286
289
|
def add_pod_target_test_dependencies(pod_target, frameworks_group)
|
287
290
|
test_dependent_targets = pod_target.all_test_dependent_targets
|
288
|
-
pod_target.
|
291
|
+
pod_target.test_specs_by_native_target.each do |test_native_target, test_specs|
|
289
292
|
test_dependent_targets.reject(&:should_build?).each do |test_dependent_target|
|
290
293
|
add_resource_bundles_to_native_target(test_dependent_target, test_native_target)
|
291
294
|
end
|
292
295
|
add_dependent_targets_to_native_target(test_dependent_targets, test_native_target, false, pod_target.requires_frameworks?, frameworks_group)
|
296
|
+
test_spec_consumers = test_specs.map { |test_spec| test_spec.consumer(pod_target.platform) }
|
297
|
+
if test_spec_consumers.any?(&:requires_app_host?)
|
298
|
+
app_host_target = project.targets.find { |t| t.name == pod_target.app_host_label(test_specs.first.test_type) }
|
299
|
+
test_native_target.add_dependency(app_host_target)
|
300
|
+
end
|
293
301
|
end
|
294
302
|
end
|
295
303
|
|
@@ -17,7 +17,7 @@ module Pod
|
|
17
17
|
create_support_files_group
|
18
18
|
create_xcconfig_file
|
19
19
|
if target.requires_frameworks?
|
20
|
-
create_info_plist_file
|
20
|
+
create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
|
21
21
|
create_module_map
|
22
22
|
create_umbrella_header
|
23
23
|
end
|
@@ -19,14 +19,17 @@ module Pod
|
|
19
19
|
UI.message "- Installing target `#{target.name}` #{target.platform}" do
|
20
20
|
add_target
|
21
21
|
create_support_files_dir
|
22
|
-
|
22
|
+
if target.contains_test_specifications?
|
23
|
+
add_test_targets
|
24
|
+
add_test_app_host_targets
|
25
|
+
end
|
23
26
|
add_resources_bundle_targets
|
24
27
|
add_files_to_build_phases
|
25
28
|
create_xcconfig_file
|
26
29
|
create_test_xcconfig_files if target.contains_test_specifications?
|
27
30
|
if target.requires_frameworks?
|
28
31
|
unless target.static_framework?
|
29
|
-
create_info_plist_file
|
32
|
+
create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
|
30
33
|
end
|
31
34
|
create_module_map
|
32
35
|
create_umbrella_header do |generator|
|
@@ -45,13 +48,33 @@ module Pod
|
|
45
48
|
create_build_phase_to_move_static_framework_archive
|
46
49
|
end
|
47
50
|
end
|
48
|
-
|
51
|
+
unless skip_pch?(target.non_test_specs)
|
52
|
+
path = target.prefix_header_path
|
53
|
+
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? }
|
54
|
+
create_prefix_header(path, file_accessors, target.platform, [native_target])
|
55
|
+
end
|
56
|
+
unless skip_pch?(target.test_specs)
|
57
|
+
target.supported_test_types.each do |test_type|
|
58
|
+
path = target.prefix_header_path_for_test_type(test_type)
|
59
|
+
file_accessors = target.file_accessors.select { |f| f.spec.test_specification? }
|
60
|
+
create_prefix_header(path, file_accessors, target.platform, target.test_native_targets)
|
61
|
+
end
|
62
|
+
end
|
49
63
|
create_dummy_source
|
50
64
|
end
|
51
65
|
end
|
52
66
|
|
53
67
|
private
|
54
68
|
|
69
|
+
# @param [Array<Specification>] specs
|
70
|
+
# the specs to check against whether `.pch` generation should be skipped or not.
|
71
|
+
#
|
72
|
+
# @return [Boolean] Whether the target should build a pch file.
|
73
|
+
#
|
74
|
+
def skip_pch?(specs)
|
75
|
+
specs.any? { |spec| spec.prefix_header_file.is_a?(FalseClass) }
|
76
|
+
end
|
77
|
+
|
55
78
|
# Remove the default headers folder path settings for static library pod
|
56
79
|
# targets.
|
57
80
|
#
|
@@ -172,6 +195,43 @@ module Pod
|
|
172
195
|
end
|
173
196
|
end
|
174
197
|
|
198
|
+
# Adds the test app host targets for the library to the Pods project with the
|
199
|
+
# appropriate build configurations.
|
200
|
+
#
|
201
|
+
# @return [void]
|
202
|
+
#
|
203
|
+
def add_test_app_host_targets
|
204
|
+
target.test_specs.each do |test_spec|
|
205
|
+
next unless test_spec.consumer(target.platform).requires_app_host?
|
206
|
+
name = target.app_host_label(test_spec.test_type)
|
207
|
+
platform_name = target.platform.name
|
208
|
+
app_host_target = project.targets.find { |t| t.name == name }
|
209
|
+
if app_host_target.nil?
|
210
|
+
app_host_target = Pod::Generator::AppTargetHelper.add_app_target(project, platform_name, deployment_target, name)
|
211
|
+
app_host_target.build_configurations.each do |configuration|
|
212
|
+
configuration.build_settings.merge!(custom_build_settings)
|
213
|
+
configuration.build_settings['PRODUCT_NAME'] = name
|
214
|
+
configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
|
215
|
+
configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if target.platform == :osx
|
216
|
+
end
|
217
|
+
Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, name)
|
218
|
+
app_host_info_plist_path = project.path.dirname.+("#{name}/Info.plist")
|
219
|
+
create_info_plist_file(app_host_info_plist_path, app_host_target, '1.0.0', target.platform, :appl)
|
220
|
+
end
|
221
|
+
# Wire all test native targets with the app host.
|
222
|
+
native_test_target = target.native_target_for_spec(test_spec)
|
223
|
+
native_test_target.build_configurations.each do |configuration|
|
224
|
+
test_host = "$(BUILT_PRODUCTS_DIR)/#{name}.app/"
|
225
|
+
test_host << 'Contents/MacOS/' if target.platform == :osx
|
226
|
+
test_host << name.to_s
|
227
|
+
configuration.build_settings['TEST_HOST'] = test_host
|
228
|
+
end
|
229
|
+
target_attributes = project.root_object.attributes['TargetAttributes'] || {}
|
230
|
+
target_attributes[native_test_target.uuid.to_s] = { 'TestTargetID' => app_host_target.uuid.to_s }
|
231
|
+
project.root_object.attributes['TargetAttributes'] = target_attributes
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
175
235
|
# Adds the test targets for the library to the Pods project with the
|
176
236
|
# appropriate build configurations.
|
177
237
|
#
|
@@ -201,6 +261,8 @@ module Pod
|
|
201
261
|
configuration.build_settings['PRODUCT_NAME'] = name
|
202
262
|
# We must codesign iOS XCTest bundles that contain binary frameworks to allow them to be launchable in the simulator
|
203
263
|
configuration.build_settings['CODE_SIGNING_REQUIRED'] = 'YES' unless target.platform == :osx
|
264
|
+
# For macOS we do not code sign the XCTest bundle because we do not code sign the frameworks either.
|
265
|
+
configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if target.platform == :osx
|
204
266
|
end
|
205
267
|
|
206
268
|
# Test native targets also need frameworks and resources to be copied over to their xctest bundle.
|
@@ -259,7 +321,7 @@ module Pod
|
|
259
321
|
path = target.info_plist_path
|
260
322
|
path.dirname.mkdir unless path.dirname.exist?
|
261
323
|
info_plist_path = path.dirname + "ResourceBundle-#{bundle_name}-#{path.basename}"
|
262
|
-
generator = Generator::InfoPlistFile.new(target,
|
324
|
+
generator = Generator::InfoPlistFile.new(target.version, target.platform, :bndl)
|
263
325
|
update_changed_file(generator, info_plist_path)
|
264
326
|
add_file_to_support_group(info_plist_path)
|
265
327
|
|
@@ -407,6 +469,8 @@ module Pod
|
|
407
469
|
mkdir -p "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules"
|
408
470
|
cp "${BUILT_PRODUCTS_DIR}/lib${PRODUCT_NAME}.a" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/${PRODUCT_NAME}"
|
409
471
|
cp "${MODULEMAP_FILE}" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules/module.modulemap"
|
472
|
+
# If there's a .swiftmodule, copy it into the framework's Modules folder
|
473
|
+
cp -r "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}".swiftmodule "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules/" 2>/dev/null || :
|
410
474
|
eos
|
411
475
|
end
|
412
476
|
|
@@ -414,17 +478,30 @@ module Pod
|
|
414
478
|
# to the platform of the target. This file also include any prefix header
|
415
479
|
# content reported by the specification of the pods.
|
416
480
|
#
|
481
|
+
# @param [Pathname] path
|
482
|
+
# the path to generate the prefix header for.
|
483
|
+
#
|
484
|
+
# @param [Array<Sandbox::FileAccessor>] file_accessors
|
485
|
+
# the file accessors to use for this prefix header that point to a path of a prefix header.
|
486
|
+
#
|
487
|
+
# @param [Platform] platform
|
488
|
+
# the platform to use for this prefix header.
|
489
|
+
#
|
490
|
+
# @param [Array<PBXNativetarget>] native_targets
|
491
|
+
# the native targets on which the prefix header should be configured for.
|
492
|
+
#
|
417
493
|
# @return [void]
|
418
494
|
#
|
419
|
-
def create_prefix_header
|
420
|
-
|
421
|
-
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
|
495
|
+
def create_prefix_header(path, file_accessors, platform, native_targets)
|
496
|
+
generator = Generator::PrefixHeader.new(file_accessors, platform)
|
422
497
|
update_changed_file(generator, path)
|
423
498
|
add_file_to_support_group(path)
|
424
499
|
|
425
|
-
|
426
|
-
|
427
|
-
|
500
|
+
native_targets.each do |native_target|
|
501
|
+
native_target.build_configurations.each do |c|
|
502
|
+
relative_path = path.relative_path_from(project.path.dirname)
|
503
|
+
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
|
504
|
+
end
|
428
505
|
end
|
429
506
|
end
|
430
507
|
|
@@ -433,7 +510,7 @@ module Pod
|
|
433
510
|
:osx => Version.new('10.8'),
|
434
511
|
:watchos => Version.new('2.0'),
|
435
512
|
:tvos => Version.new('9.0'),
|
436
|
-
}
|
513
|
+
}.freeze
|
437
514
|
|
438
515
|
# Returns the compiler flags for the source files of the given specification.
|
439
516
|
#
|