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
@@ -0,0 +1,101 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
class Xcode
|
4
|
+
class PodsProjectGenerator
|
5
|
+
# This class is responsible for integrating a pod target. This includes integrating
|
6
|
+
# the test targets included by each pod target.
|
7
|
+
#
|
8
|
+
class PodTargetIntegrator
|
9
|
+
# @return [PodTarget] the target that should be integrated.
|
10
|
+
#
|
11
|
+
attr_reader :target
|
12
|
+
|
13
|
+
# Init a new PodTargetIntegrator.
|
14
|
+
#
|
15
|
+
# @param [PodTarget] target @see #target
|
16
|
+
#
|
17
|
+
def initialize(target)
|
18
|
+
@target = target
|
19
|
+
end
|
20
|
+
|
21
|
+
# Integrates the pod target.
|
22
|
+
#
|
23
|
+
# @return [void]
|
24
|
+
#
|
25
|
+
def integrate!
|
26
|
+
UI.section(integration_message) do
|
27
|
+
target.test_specs_by_native_target.each do |native_target, test_specs|
|
28
|
+
add_embed_frameworks_script_phase(native_target)
|
29
|
+
add_copy_resources_script_phase(native_target)
|
30
|
+
UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(test_specs), native_target)
|
31
|
+
end
|
32
|
+
specs = target.specs.reject(&:test_specification?)
|
33
|
+
UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(specs), target.native_target)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String] a string representation suitable for debugging.
|
38
|
+
#
|
39
|
+
def inspect
|
40
|
+
"#<#{self.class} for target `#{target.label}'>"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# @!group Integration steps
|
46
|
+
#---------------------------------------------------------------------#
|
47
|
+
|
48
|
+
# Find or create a 'Copy Pods Resources' build phase
|
49
|
+
#
|
50
|
+
# @return [void]
|
51
|
+
#
|
52
|
+
def add_copy_resources_script_phase(native_target)
|
53
|
+
test_type = target.test_type_for_product_type(native_target.symbol_type)
|
54
|
+
script_path = "${PODS_ROOT}/#{target.copy_resources_script_path_for_test_type(test_type).relative_path_from(target.sandbox.root)}"
|
55
|
+
resource_paths = target.all_test_dependent_targets.flat_map(&:resource_paths)
|
56
|
+
input_paths = []
|
57
|
+
output_paths = []
|
58
|
+
unless resource_paths.empty?
|
59
|
+
input_paths = [script_path, *resource_paths.flatten.uniq]
|
60
|
+
output_paths = ['${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}']
|
61
|
+
end
|
62
|
+
UserProjectIntegrator::TargetIntegrator.add_copy_resources_script_phase_to_target(native_target, script_path, input_paths, output_paths)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Find or create a 'Embed Pods Frameworks' Copy Files Build Phase
|
66
|
+
#
|
67
|
+
# @return [void]
|
68
|
+
#
|
69
|
+
def add_embed_frameworks_script_phase(native_target)
|
70
|
+
test_type = target.test_type_for_product_type(native_target.symbol_type)
|
71
|
+
script_path = "${PODS_ROOT}/#{target.embed_frameworks_script_path_for_test_type(test_type).relative_path_from(target.sandbox.root)}"
|
72
|
+
framework_paths = target.all_test_dependent_targets.flat_map(&:framework_paths)
|
73
|
+
input_paths = []
|
74
|
+
output_paths = []
|
75
|
+
unless framework_paths.empty?
|
76
|
+
input_paths = [script_path, *framework_paths.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact]
|
77
|
+
output_paths = framework_paths.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact
|
78
|
+
end
|
79
|
+
UserProjectIntegrator::TargetIntegrator.add_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths)
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [String] the message that should be displayed for the target
|
83
|
+
# integration.
|
84
|
+
#
|
85
|
+
def integration_message
|
86
|
+
"Integrating target `#{target.name}`"
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param [Array<Specification] specs
|
90
|
+
# the specs to return script phrases from.
|
91
|
+
#
|
92
|
+
# @return [Array<Hash<Symbol=>String>] an array of all combined script phases from the specs.
|
93
|
+
#
|
94
|
+
def script_phases_for_specs(specs)
|
95
|
+
specs.map { |spec| spec.consumer(target.platform) }.map(&:script_phases).flatten
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -136,12 +136,26 @@ module Pod
|
|
136
136
|
|
137
137
|
# Creates the Info.plist file which sets public framework attributes
|
138
138
|
#
|
139
|
+
# @param [Pathname] path
|
140
|
+
# the path to save the generated Info.plist file.
|
141
|
+
#
|
142
|
+
# @param [PBXNativeTarget] native_target
|
143
|
+
# the native target to link the generated Info.plist file into.
|
144
|
+
#
|
145
|
+
# @param [Version] version
|
146
|
+
# the version to use for when generating this Info.plist file.
|
147
|
+
#
|
148
|
+
# @param [Platform] platform
|
149
|
+
# the platform to use for when generating this Info.plist file.
|
150
|
+
#
|
151
|
+
# @param [Symbol] bundle_package_type
|
152
|
+
# the CFBundlePackageType of the target this Info.plist file is for.
|
153
|
+
#
|
139
154
|
# @return [void]
|
140
155
|
#
|
141
|
-
def create_info_plist_file
|
142
|
-
path = target.info_plist_path
|
156
|
+
def create_info_plist_file(path, native_target, version, platform, bundle_package_type = :fmwk)
|
143
157
|
UI.message "- Generating Info.plist file at #{UI.path(path)}" do
|
144
|
-
generator = Generator::InfoPlistFile.new(
|
158
|
+
generator = Generator::InfoPlistFile.new(version, platform, bundle_package_type)
|
145
159
|
update_changed_file(generator, path)
|
146
160
|
add_file_to_support_group(path)
|
147
161
|
|
data/lib/cocoapods/target.rb
CHANGED
@@ -6,6 +6,8 @@ module Pod
|
|
6
6
|
# This class is used to represent both the targets and their libraries.
|
7
7
|
#
|
8
8
|
class Target
|
9
|
+
DEFAULT_VERSION = '1.0.0'.freeze
|
10
|
+
|
9
11
|
# @return [Sandbox] The sandbox where the Pods should be installed.
|
10
12
|
#
|
11
13
|
attr_reader :sandbox
|
@@ -93,7 +95,7 @@ module Pod
|
|
93
95
|
# @return [Boolean] Whether the target should build a static framework.
|
94
96
|
#
|
95
97
|
def static_framework?
|
96
|
-
!is_a?(Pod::AggregateTarget) && specs.any? && specs.all?(&:static_framework)
|
98
|
+
!is_a?(Pod::AggregateTarget) && specs.any? && specs.flat_map(&:root).all?(&:static_framework)
|
97
99
|
end
|
98
100
|
|
99
101
|
#-------------------------------------------------------------------------#
|
@@ -156,12 +158,6 @@ module Pod
|
|
156
158
|
support_files_dir + "#{label}.modulemap"
|
157
159
|
end
|
158
160
|
|
159
|
-
# @return [Pathname] the absolute path of the prefix header file.
|
160
|
-
#
|
161
|
-
def prefix_header_path
|
162
|
-
support_files_dir + "#{label}-prefix.pch"
|
163
|
-
end
|
164
|
-
|
165
161
|
# @return [Pathname] the absolute path of the bridge support file.
|
166
162
|
#
|
167
163
|
def bridge_support_path
|
@@ -180,6 +176,12 @@ module Pod
|
|
180
176
|
support_files_dir + "#{label}-dummy.m"
|
181
177
|
end
|
182
178
|
|
179
|
+
# @return [String] The version associated with this target
|
180
|
+
#
|
181
|
+
def version
|
182
|
+
DEFAULT_VERSION
|
183
|
+
end
|
184
|
+
|
183
185
|
#-------------------------------------------------------------------------#
|
184
186
|
|
185
187
|
private
|
@@ -205,7 +205,7 @@ module Pod
|
|
205
205
|
def resource_paths_by_config
|
206
206
|
@resource_paths_by_config ||= begin
|
207
207
|
relevant_pod_targets = pod_targets.reject do |pod_target|
|
208
|
-
pod_target.should_build? && pod_target.requires_frameworks?
|
208
|
+
pod_target.should_build? && pod_target.requires_frameworks? && !pod_target.static_framework?
|
209
209
|
end
|
210
210
|
user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
|
211
211
|
resources_by_config[config] = relevant_pod_targets.flat_map do |pod_target|
|
@@ -163,7 +163,7 @@ module Pod
|
|
163
163
|
@should_build = begin
|
164
164
|
source_files = file_accessors.flat_map(&:source_files)
|
165
165
|
source_files -= file_accessors.flat_map(&:headers)
|
166
|
-
!source_files.empty?
|
166
|
+
!source_files.empty? || contains_script_phases?
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -185,16 +185,47 @@ module Pod
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
# @return [Array<Hash{Symbol=>String}>] An array of hashes where each hash represents a single script phase.
|
189
|
+
#
|
190
|
+
def script_phases
|
191
|
+
spec_consumers.map(&:script_phases).flatten
|
192
|
+
end
|
193
|
+
|
194
|
+
# @return [Boolean] Whether the target contains any script phases.
|
195
|
+
#
|
196
|
+
def contains_script_phases?
|
197
|
+
!script_phases.empty?
|
198
|
+
end
|
199
|
+
|
200
|
+
# @return [Hash{Array => Specification}] a hash where the keys are the test native targets and the value
|
201
|
+
# an array of all the test specs associated with this native target.
|
202
|
+
#
|
203
|
+
def test_specs_by_native_target
|
204
|
+
test_specs.group_by { |test_spec| native_target_for_spec(test_spec) }
|
205
|
+
end
|
206
|
+
|
188
207
|
# @return [Boolean] Whether the target has any tests specifications.
|
189
208
|
#
|
190
209
|
def contains_test_specifications?
|
191
210
|
specs.any?(&:test_specification?)
|
192
211
|
end
|
193
212
|
|
213
|
+
# @return [Array<Specification>] All of the test specs within this target.
|
214
|
+
#
|
215
|
+
def test_specs
|
216
|
+
specs.select(&:test_specification?)
|
217
|
+
end
|
218
|
+
|
219
|
+
# @return [Array<Specification>] All of the non test specs within this target.
|
220
|
+
#
|
221
|
+
def non_test_specs
|
222
|
+
specs.reject(&:test_specification?)
|
223
|
+
end
|
224
|
+
|
194
225
|
# @return [Array<Symbol>] All of the test supported types within this target.
|
195
226
|
#
|
196
227
|
def supported_test_types
|
197
|
-
|
228
|
+
test_specs.map(&:test_type).uniq
|
198
229
|
end
|
199
230
|
|
200
231
|
# Returns the framework paths associated with this target. By default all paths include the framework paths
|
@@ -207,36 +238,35 @@ module Pod
|
|
207
238
|
# this target depends upon.
|
208
239
|
#
|
209
240
|
def framework_paths(include_test_spec_paths = true)
|
210
|
-
@framework_paths ||=
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
frameworks << framework
|
241
|
+
@framework_paths ||= {}
|
242
|
+
return @framework_paths[include_test_spec_paths] if @framework_paths.key?(include_test_spec_paths)
|
243
|
+
@framework_paths[include_test_spec_paths] = begin
|
244
|
+
accessors = file_accessors
|
245
|
+
accessors = accessors.reject { |a| a.spec.test_specification? } unless include_test_spec_paths
|
246
|
+
frameworks = []
|
247
|
+
accessors.flat_map(&:vendored_dynamic_artifacts).map do |framework_path|
|
248
|
+
relative_path_to_sandbox = framework_path.relative_path_from(sandbox.root)
|
249
|
+
framework = { :name => framework_path.basename.to_s,
|
250
|
+
:input_path => "${PODS_ROOT}/#{relative_path_to_sandbox}",
|
251
|
+
:output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{framework_path.basename}" }
|
252
|
+
# Until this can be configured, assume the dSYM file uses the file name as the framework.
|
253
|
+
# See https://github.com/CocoaPods/CocoaPods/issues/1698
|
254
|
+
dsym_name = "#{framework_path.basename}.dSYM"
|
255
|
+
dsym_path = Pathname.new("#{framework_path.dirname}/#{dsym_name}")
|
256
|
+
if dsym_path.exist?
|
257
|
+
framework[:dsym_name] = dsym_name
|
258
|
+
framework[:dsym_input_path] = "${PODS_ROOT}/#{relative_path_to_sandbox}.dSYM"
|
259
|
+
framework[:dsym_output_path] = "${DWARF_DSYM_FOLDER_PATH}/#{dsym_name}"
|
230
260
|
end
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
261
|
+
frameworks << framework
|
262
|
+
end
|
263
|
+
if should_build? && requires_frameworks? && !static_framework?
|
264
|
+
frameworks << { :name => product_name,
|
265
|
+
:input_path => build_product_path('${BUILT_PRODUCTS_DIR}'),
|
266
|
+
:output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{product_name}" }
|
237
267
|
end
|
268
|
+
frameworks
|
238
269
|
end
|
239
|
-
@framework_paths[include_test_spec_paths]
|
240
270
|
end
|
241
271
|
|
242
272
|
# Returns the resource paths associated with this target. By default all paths include the resource paths
|
@@ -248,22 +278,21 @@ module Pod
|
|
248
278
|
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
|
249
279
|
#
|
250
280
|
def resource_paths(include_test_spec_paths = true)
|
251
|
-
@resource_paths ||=
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
resource_bundles = accessors.flat_map do |accessor|
|
259
|
-
prefix = Generator::XCConfig::XCConfigHelper::CONFIGURATION_BUILD_DIR_VARIABLE
|
260
|
-
prefix = configuration_build_dir unless accessor.spec.test_specification?
|
261
|
-
accessor.resource_bundles.keys.map { |name| "#{prefix}/#{name.shellescape}.bundle" }
|
262
|
-
end
|
263
|
-
resource_paths + resource_bundles
|
281
|
+
@resource_paths ||= {}
|
282
|
+
return @resource_paths[include_test_spec_paths] if @resource_paths.key?(include_test_spec_paths)
|
283
|
+
@resource_paths[include_test_spec_paths] = begin
|
284
|
+
accessors = file_accessors
|
285
|
+
accessors = accessors.reject { |a| a.spec.test_specification? } unless include_test_spec_paths
|
286
|
+
resource_paths = accessors.flat_map do |accessor|
|
287
|
+
accessor.resources.flat_map { |res| "${PODS_ROOT}/#{res.relative_path_from(sandbox.project.path.dirname)}" }
|
264
288
|
end
|
289
|
+
resource_bundles = accessors.flat_map do |accessor|
|
290
|
+
prefix = Generator::XCConfig::XCConfigHelper::CONFIGURATION_BUILD_DIR_VARIABLE
|
291
|
+
prefix = configuration_build_dir unless accessor.spec.test_specification?
|
292
|
+
accessor.resource_bundles.keys.map { |name| "#{prefix}/#{name.shellescape}.bundle" }
|
293
|
+
end
|
294
|
+
resource_paths + resource_bundles
|
265
295
|
end
|
266
|
-
@resource_paths[include_test_spec_paths]
|
267
296
|
end
|
268
297
|
|
269
298
|
# Returns the corresponding native target to use based on the provided specification.
|
@@ -346,6 +375,15 @@ module Pod
|
|
346
375
|
"#{label}-#{test_type.capitalize}-Tests"
|
347
376
|
end
|
348
377
|
|
378
|
+
# @param [Symbol] test_type
|
379
|
+
# The test type to use for producing the test label.
|
380
|
+
#
|
381
|
+
# @return [String] The label of the app host label to use given the platform and test type.
|
382
|
+
#
|
383
|
+
def app_host_label(test_type)
|
384
|
+
"AppHost-#{Platform.string_name(platform.symbolic_name)}-#{test_type.capitalize}-Tests"
|
385
|
+
end
|
386
|
+
|
349
387
|
# @param [Symbol] test_type
|
350
388
|
# The test type this embed frameworks script path is for.
|
351
389
|
#
|
@@ -364,6 +402,21 @@ module Pod
|
|
364
402
|
support_files_dir + "#{test_target_label(test_type)}-frameworks.sh"
|
365
403
|
end
|
366
404
|
|
405
|
+
# @return [Pathname] the absolute path of the prefix header file.
|
406
|
+
#
|
407
|
+
def prefix_header_path
|
408
|
+
support_files_dir + "#{label}-prefix.pch"
|
409
|
+
end
|
410
|
+
|
411
|
+
# @param [Symbol] test_type
|
412
|
+
# The test type prefix header path is for.
|
413
|
+
#
|
414
|
+
# @return [Pathname] the absolute path of the prefix header file for the given test type.
|
415
|
+
#
|
416
|
+
def prefix_header_path_for_test_type(test_type)
|
417
|
+
support_files_dir + "#{test_target_label(test_type)}-prefix.pch"
|
418
|
+
end
|
419
|
+
|
367
420
|
# @return [Array<String>] The names of the Pods on which this target
|
368
421
|
# depends.
|
369
422
|
#
|
@@ -499,6 +552,13 @@ module Pod
|
|
499
552
|
"${PODS_ROOT}/#{sandbox.pod_dir(pod_name).relative_path_from(sandbox.root)}"
|
500
553
|
end
|
501
554
|
|
555
|
+
# @return [String] The version associated with this target
|
556
|
+
#
|
557
|
+
def version
|
558
|
+
version = root_spec.version
|
559
|
+
[version.major, version.minor, version.patch].join('.')
|
560
|
+
end
|
561
|
+
|
502
562
|
private
|
503
563
|
|
504
564
|
# @param [TargetDefinition] target_definition
|
data/lib/cocoapods/validator.rb
CHANGED
@@ -16,7 +16,7 @@ module Pod
|
|
16
16
|
|
17
17
|
# The default version of Swift to use when linting pods
|
18
18
|
#
|
19
|
-
DEFAULT_SWIFT_VERSION = '3.
|
19
|
+
DEFAULT_SWIFT_VERSION = '3.2'.freeze
|
20
20
|
|
21
21
|
# @return [Specification::Linter] the linter instance from CocoaPods
|
22
22
|
# Core.
|
@@ -256,7 +256,7 @@ module Pod
|
|
256
256
|
# @return [String] the SWIFT_VERSION to use for validation.
|
257
257
|
#
|
258
258
|
def swift_version
|
259
|
-
return @swift_version
|
259
|
+
return @swift_version unless @swift_version.nil?
|
260
260
|
if version = dot_swift_version
|
261
261
|
@swift_version = version
|
262
262
|
else
|
@@ -277,11 +277,10 @@ module Pod
|
|
277
277
|
swift_version_path.read.strip
|
278
278
|
end
|
279
279
|
|
280
|
-
# @return [
|
281
|
-
# or nil, if Swift was not used.
|
280
|
+
# @return [Boolean] Whether any of the pod targets part of this validator use Swift or not.
|
282
281
|
#
|
283
|
-
def
|
284
|
-
|
282
|
+
def uses_swift?
|
283
|
+
@installer.pod_targets.any?(&:uses_swift?)
|
285
284
|
end
|
286
285
|
|
287
286
|
#-------------------------------------------------------------------------#
|
@@ -318,7 +317,7 @@ module Pod
|
|
318
317
|
download_pod
|
319
318
|
check_file_patterns
|
320
319
|
install_pod
|
321
|
-
|
320
|
+
validate_swift_version
|
322
321
|
add_app_project_import
|
323
322
|
validate_vendored_dynamic_frameworks
|
324
323
|
build_pod
|
@@ -394,14 +393,21 @@ module Pod
|
|
394
393
|
validate_url(spec.documentation_url) if spec.documentation_url
|
395
394
|
end
|
396
395
|
|
397
|
-
|
398
|
-
|
396
|
+
# Performs validation for which version of Swift is used during validation.
|
397
|
+
#
|
398
|
+
# The user will be warned that the default version of Swift was used if the following things are true:
|
399
|
+
# - The project uses Swift at all
|
400
|
+
# - The user did not supply a Swift version via a parameter
|
401
|
+
# - There is no `.swift-version` file present either.
|
402
|
+
#
|
403
|
+
def validate_swift_version
|
404
|
+
if uses_swift? && @swift_version.nil? && dot_swift_version.nil?
|
399
405
|
warning(:swift_version,
|
400
|
-
'The validator
|
401
|
-
|
402
|
-
'
|
403
|
-
|
404
|
-
'
|
406
|
+
'The validator used ' \
|
407
|
+
"Swift #{DEFAULT_SWIFT_VERSION} by default because no Swift version was specified. " \
|
408
|
+
'If you want to use a different version of Swift during validation, then either use the `--swift-version` parameter ' \
|
409
|
+
'or use a `.swift-version` file to set the version of Swift to use for ' \
|
410
|
+
'your Pod. For example to use Swift 4.0, run: `echo "4.0" > .swift-version`.')
|
405
411
|
end
|
406
412
|
end
|
407
413
|
|
@@ -439,71 +445,24 @@ module Pod
|
|
439
445
|
|
440
446
|
def create_app_project
|
441
447
|
app_project = Xcodeproj::Project.new(validation_dir + 'App.xcodeproj')
|
442
|
-
|
448
|
+
Pod::Generator::AppTargetHelper.add_app_target(app_project, consumer.platform_name, deployment_target)
|
443
449
|
app_project.save
|
444
450
|
app_project.recreate_user_schemes
|
445
451
|
end
|
446
452
|
|
447
453
|
def add_app_project_import
|
448
454
|
app_project = Xcodeproj::Project.open(validation_dir + 'App.xcodeproj')
|
449
|
-
pod_target = @installer.pod_targets.find { |pt| pt.pod_name == spec.root.name }
|
450
|
-
|
451
|
-
source_file = write_app_import_source_file(pod_target)
|
452
|
-
source_file_ref = app_project.new_group('App', 'App').new_file(source_file)
|
453
455
|
app_target = app_project.targets.first
|
454
|
-
|
455
|
-
|
456
|
-
|
456
|
+
pod_target = @installer.pod_targets.find { |pt| pt.pod_name == spec.root.name }
|
457
|
+
Pod::Generator::AppTargetHelper.add_app_project_import(app_project, app_target, pod_target, consumer.platform_name, use_frameworks)
|
458
|
+
Pod::Generator::AppTargetHelper.add_swift_version(app_target, swift_version)
|
459
|
+
Pod::Generator::AppTargetHelper.add_xctest_search_paths(app_target) if @installer.pod_targets.any? { |pt| pt.spec_consumers.any? { |c| c.frameworks.include?('XCTest') } }
|
457
460
|
app_project.save
|
458
461
|
Xcodeproj::XCScheme.share_scheme(app_project.path, 'App')
|
459
462
|
# Share the pods xcscheme only if it exists. For pre-built vendored pods there is no xcscheme generated.
|
460
463
|
Xcodeproj::XCScheme.share_scheme(@installer.pods_project.path, pod_target.label) if shares_pod_target_xcscheme?(pod_target)
|
461
464
|
end
|
462
465
|
|
463
|
-
def add_swift_version(app_target)
|
464
|
-
app_target.build_configurations.each do |configuration|
|
465
|
-
configuration.build_settings['SWIFT_VERSION'] = swift_version
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
def add_xctest(app_target)
|
470
|
-
app_target.build_configurations.each do |configuration|
|
471
|
-
search_paths = configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= '$(inherited)'
|
472
|
-
search_paths << ' "$(PLATFORM_DIR)/Developer/Library/Frameworks"'
|
473
|
-
end
|
474
|
-
end
|
475
|
-
|
476
|
-
def write_app_import_source_file(pod_target)
|
477
|
-
language = pod_target.uses_swift? ? :swift : :objc
|
478
|
-
|
479
|
-
if language == :swift
|
480
|
-
source_file = validation_dir.+('App/main.swift')
|
481
|
-
source_file.parent.mkpath
|
482
|
-
import_statement = use_frameworks && pod_target.should_build? ? "import #{pod_target.product_module_name}\n" : ''
|
483
|
-
source_file.open('w') { |f| f << import_statement }
|
484
|
-
else
|
485
|
-
source_file = validation_dir.+('App/main.m')
|
486
|
-
source_file.parent.mkpath
|
487
|
-
import_statement = if use_frameworks && pod_target.should_build?
|
488
|
-
"@import #{pod_target.product_module_name};\n"
|
489
|
-
else
|
490
|
-
header_name = "#{pod_target.product_module_name}/#{pod_target.product_module_name}.h"
|
491
|
-
if pod_target.sandbox.public_headers.root.+(header_name).file?
|
492
|
-
"#import <#{header_name}>\n"
|
493
|
-
else
|
494
|
-
''
|
495
|
-
end
|
496
|
-
end
|
497
|
-
source_file.open('w') do |f|
|
498
|
-
f << "@import Foundation;\n"
|
499
|
-
f << "@import UIKit;\n" if consumer.platform_name == :ios || consumer.platform_name == :tvos
|
500
|
-
f << "@import Cocoa;\n" if consumer.platform_name == :osx
|
501
|
-
f << "#{import_statement}int main() {}\n"
|
502
|
-
end
|
503
|
-
end
|
504
|
-
source_file
|
505
|
-
end
|
506
|
-
|
507
466
|
# It creates a podfile in memory and builds a library containing the pod
|
508
467
|
# for all available platforms with xcodebuild.
|
509
468
|
#
|