cocoapods 1.10.0 → 1.16.0
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 +571 -7
- data/README.md +10 -11
- data/bin/sandbox-pod +1 -1
- data/lib/cocoapods/command/lib/lint.rb +4 -1
- data/lib/cocoapods/command/outdated.rb +12 -1
- data/lib/cocoapods/command/repo/push.rb +20 -0
- data/lib/cocoapods/command/setup.rb +2 -2
- data/lib/cocoapods/command/spec/cat.rb +3 -1
- data/lib/cocoapods/command/spec/create.rb +1 -0
- data/lib/cocoapods/command/spec/lint.rb +4 -1
- data/lib/cocoapods/command/spec/which.rb +3 -1
- data/lib/cocoapods/command/spec.rb +18 -9
- data/lib/cocoapods/config.rb +8 -7
- data/lib/cocoapods/downloader/cache.rb +98 -6
- data/lib/cocoapods/downloader.rb +4 -2
- data/lib/cocoapods/executable.rb +1 -1
- data/lib/cocoapods/external_sources/abstract_external_source.rb +1 -1
- data/lib/cocoapods/external_sources/path_source.rb +1 -1
- data/lib/cocoapods/external_sources/podspec_source.rb +1 -1
- data/lib/cocoapods/gem_version.rb +1 -1
- data/lib/cocoapods/generator/acknowledgements.rb +13 -1
- data/lib/cocoapods/generator/app_target_helper.rb +8 -4
- data/lib/cocoapods/generator/copy_dsyms_script.rb +4 -4
- data/lib/cocoapods/generator/copy_resources_script.rb +2 -1
- data/lib/cocoapods/generator/copy_xcframework_script.rb +52 -70
- data/lib/cocoapods/generator/embed_frameworks_script.rb +4 -3
- data/lib/cocoapods/generator/info_plist_file.rb +1 -1
- data/lib/cocoapods/generator/script_phase_constants.rb +1 -0
- data/lib/cocoapods/installer/analyzer/analysis_result.rb +3 -3
- data/lib/cocoapods/installer/analyzer/pod_variant.rb +1 -1
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +38 -10
- data/lib/cocoapods/installer/analyzer.rb +21 -13
- data/lib/cocoapods/installer/base_install_hooks_context.rb +19 -4
- data/lib/cocoapods/installer/installation_options.rb +11 -0
- data/lib/cocoapods/installer/pod_source_downloader.rb +159 -0
- data/lib/cocoapods/installer/pod_source_installer.rb +10 -36
- data/lib/cocoapods/installer/podfile_validator.rb +2 -2
- data/lib/cocoapods/installer/pre_integrate_hooks_context.rb +9 -0
- data/lib/cocoapods/installer/project_cache/project_cache_analyzer.rb +14 -7
- data/lib/cocoapods/installer/project_cache/project_installation_cache.rb +15 -2
- data/lib/cocoapods/installer/project_cache/target_cache_key.rb +48 -7
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +150 -9
- data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +11 -3
- data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +62 -9
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +6 -19
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +86 -59
- data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +48 -6
- data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +3 -1
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +2 -2
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +8 -5
- data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +9 -3
- data/lib/cocoapods/installer/xcode/pods_project_generator.rb +37 -2
- data/lib/cocoapods/installer/xcode/target_validator.rb +1 -1
- data/lib/cocoapods/installer.rb +150 -34
- data/lib/cocoapods/native_target_extension.rb +1 -1
- data/lib/cocoapods/open-uri.rb +1 -1
- data/lib/cocoapods/project.rb +8 -8
- data/lib/cocoapods/resolver/resolver_specification.rb +1 -1
- data/lib/cocoapods/resolver.rb +7 -7
- data/lib/cocoapods/sandbox/file_accessor.rb +67 -11
- data/lib/cocoapods/sandbox/headers_store.rb +3 -1
- data/lib/cocoapods/sandbox/path_list.rb +2 -2
- data/lib/cocoapods/sandbox/pod_dir_cleaner.rb +1 -1
- data/lib/cocoapods/sandbox.rb +48 -12
- data/lib/cocoapods/sources_manager.rb +18 -9
- data/lib/cocoapods/target/aggregate_target.rb +23 -1
- data/lib/cocoapods/target/build_settings.rb +67 -22
- data/lib/cocoapods/target/pod_target.rb +49 -24
- data/lib/cocoapods/target.rb +1 -1
- data/lib/cocoapods/user_interface.rb +6 -2
- data/lib/cocoapods/validator.rb +58 -22
- data/lib/cocoapods/version_metadata.rb +1 -1
- data/lib/cocoapods/xcode/xcframework/xcframework_slice.rb +22 -7
- data/lib/cocoapods/xcode/xcframework.rb +9 -4
- data/lib/cocoapods.rb +2 -0
- metadata +35 -27
|
@@ -32,7 +32,8 @@ module Pod
|
|
|
32
32
|
# For messages extensions, this only applies if it's embedded in a messages
|
|
33
33
|
# application.
|
|
34
34
|
#
|
|
35
|
-
EMBED_FRAMEWORK_TARGET_TYPES = [:application, :application_on_demand_install_capable, :unit_test_bundle,
|
|
35
|
+
EMBED_FRAMEWORK_TARGET_TYPES = [:application, :application_on_demand_install_capable, :unit_test_bundle,
|
|
36
|
+
:ui_test_bundle, :watch2_extension, :messages_application].freeze
|
|
36
37
|
|
|
37
38
|
# @return [String] the name of the embed frameworks phase
|
|
38
39
|
#
|
|
@@ -313,6 +314,7 @@ module Pod
|
|
|
313
314
|
phase.input_file_list_paths = script_phase[:input_file_lists]
|
|
314
315
|
phase.output_file_list_paths = script_phase[:output_file_lists]
|
|
315
316
|
phase.dependency_file = script_phase[:dependency_file]
|
|
317
|
+
phase.always_out_of_date = script_phase[:always_out_of_date]
|
|
316
318
|
# At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only
|
|
317
319
|
# gets set to '0' if the user has explicitly disabled this.
|
|
318
320
|
if (show_env_vars_in_log = script_phase.fetch(:show_env_vars_in_log, '1')) == '0'
|
|
@@ -326,11 +328,18 @@ module Pod
|
|
|
326
328
|
|
|
327
329
|
def reorder_script_phase(native_target, script_phase, execution_position)
|
|
328
330
|
return if execution_position == :any || execution_position.to_s.empty?
|
|
329
|
-
target_phase_type =
|
|
331
|
+
target_phase_type = case execution_position
|
|
332
|
+
when :before_compile, :after_compile
|
|
333
|
+
Xcodeproj::Project::Object::PBXSourcesBuildPhase
|
|
334
|
+
when :before_headers, :after_headers
|
|
335
|
+
Xcodeproj::Project::Object::PBXHeadersBuildPhase
|
|
336
|
+
else
|
|
337
|
+
raise ArgumentError, "Unknown execution position `#{execution_position}`"
|
|
338
|
+
end
|
|
330
339
|
order_before = case execution_position
|
|
331
|
-
when :before_compile
|
|
340
|
+
when :before_compile, :before_headers
|
|
332
341
|
true
|
|
333
|
-
when :after_compile
|
|
342
|
+
when :after_compile, :after_headers
|
|
334
343
|
false
|
|
335
344
|
else
|
|
336
345
|
raise ArgumentError, "Unknown execution position `#{execution_position}`"
|
|
@@ -387,10 +396,10 @@ module Pod
|
|
|
387
396
|
|
|
388
397
|
# Returns the framework input paths for the given framework paths
|
|
389
398
|
#
|
|
390
|
-
# @param [
|
|
399
|
+
# @param [Array<Xcode::FrameworkPaths>] framework_paths
|
|
391
400
|
# The target's framework paths to map to input paths.
|
|
392
401
|
#
|
|
393
|
-
# @param [
|
|
402
|
+
# @param [Array<XCFramework>] xcframeworks
|
|
394
403
|
# The target's xcframeworks to map to input paths.
|
|
395
404
|
#
|
|
396
405
|
# @return [Array<String>] The embed frameworks script input paths
|
|
@@ -426,6 +435,119 @@ module Pod
|
|
|
426
435
|
end
|
|
427
436
|
paths + xcframework_paths
|
|
428
437
|
end
|
|
438
|
+
|
|
439
|
+
# Updates a projects native targets to include on demand resources specified by the supplied parameters.
|
|
440
|
+
# Note that currently, only app level targets are allowed to include on demand resources.
|
|
441
|
+
#
|
|
442
|
+
# @param [Sandbox] sandbox
|
|
443
|
+
# The sandbox to use for calculating ODR file references.
|
|
444
|
+
#
|
|
445
|
+
# @param [Xcodeproj::Project] project
|
|
446
|
+
# The project to update known asset tags as well as add the ODR group.
|
|
447
|
+
#
|
|
448
|
+
# @param [Xcodeproj::PBXNativeTarget, Array<Xcodeproj::PBXNativeTarget>] native_targets
|
|
449
|
+
# The native targets to integrate on demand resources into.
|
|
450
|
+
#
|
|
451
|
+
# @param [Sandbox::FileAccessor, Array<Sandbox::FileAccessor>] file_accessors
|
|
452
|
+
# The file accessors that that provide the ODRs to integrate.
|
|
453
|
+
#
|
|
454
|
+
# @param [Xcodeproj::PBXGroup] parent_odr_group
|
|
455
|
+
# The group to use as the parent to add ODR file references into.
|
|
456
|
+
#
|
|
457
|
+
# @param [String] target_odr_group_name
|
|
458
|
+
# The name to use for the group created that contains the ODR file references.
|
|
459
|
+
#
|
|
460
|
+
# @return [void]
|
|
461
|
+
#
|
|
462
|
+
def update_on_demand_resources(sandbox, project, native_targets, file_accessors, parent_odr_group,
|
|
463
|
+
target_odr_group_name)
|
|
464
|
+
category_to_tags = {}
|
|
465
|
+
file_accessors = Array(file_accessors)
|
|
466
|
+
native_targets = Array(native_targets)
|
|
467
|
+
|
|
468
|
+
# Target no longer provides ODR references so remove everything related to this target.
|
|
469
|
+
if file_accessors.all? { |fa| fa.on_demand_resources.empty? }
|
|
470
|
+
old_target_odr_group = parent_odr_group[target_odr_group_name]
|
|
471
|
+
old_odr_file_refs = old_target_odr_group&.recursive_children_groups&.each_with_object({}) do |group, hash|
|
|
472
|
+
hash[group.name] = group.files
|
|
473
|
+
end || {}
|
|
474
|
+
native_targets.each do |native_target|
|
|
475
|
+
native_target.remove_on_demand_resources(old_odr_file_refs)
|
|
476
|
+
update_on_demand_resources_build_settings(native_target, nil => old_odr_file_refs.keys)
|
|
477
|
+
end
|
|
478
|
+
old_target_odr_group&.remove_from_project
|
|
479
|
+
return
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
target_odr_group = parent_odr_group[target_odr_group_name] || parent_odr_group.new_group(target_odr_group_name)
|
|
483
|
+
current_file_refs = target_odr_group.recursive_children_groups.flat_map(&:files)
|
|
484
|
+
|
|
485
|
+
added_file_refs = file_accessors.flat_map do |file_accessor|
|
|
486
|
+
target_odr_files_refs = Hash[file_accessor.on_demand_resources.map do |tag, value|
|
|
487
|
+
tag_group = target_odr_group[tag] || target_odr_group.new_group(tag)
|
|
488
|
+
category_to_tags[value[:category]] ||= []
|
|
489
|
+
category_to_tags[value[:category]] << tag
|
|
490
|
+
resources_file_refs = value[:paths].map do |resource|
|
|
491
|
+
odr_resource_file_ref = Pathname.new(resource).relative_path_from(sandbox.root)
|
|
492
|
+
tag_group.find_file_by_path(odr_resource_file_ref.to_s) || tag_group.new_file(odr_resource_file_ref)
|
|
493
|
+
end
|
|
494
|
+
[tag, resources_file_refs]
|
|
495
|
+
end]
|
|
496
|
+
native_targets.each do |native_target|
|
|
497
|
+
native_target.add_on_demand_resources(target_odr_files_refs)
|
|
498
|
+
end
|
|
499
|
+
target_odr_files_refs.values.flatten
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
# if the target ODR file references were updated, make sure we remove the ones that are no longer present
|
|
503
|
+
# for the target.
|
|
504
|
+
remaining_refs = current_file_refs - added_file_refs
|
|
505
|
+
remaining_refs.each do |ref|
|
|
506
|
+
native_targets.each do |user_target|
|
|
507
|
+
user_target.resources_build_phase.remove_file_reference(ref)
|
|
508
|
+
end
|
|
509
|
+
ref.remove_from_project
|
|
510
|
+
end
|
|
511
|
+
target_odr_group.recursive_children_groups.each { |g| g.remove_from_project if g.empty? }
|
|
512
|
+
|
|
513
|
+
attributes = project.root_object.attributes
|
|
514
|
+
attributes['KnownAssetTags'] = (attributes['KnownAssetTags'] ||= []) | category_to_tags.values.flatten
|
|
515
|
+
project.root_object.attributes = attributes
|
|
516
|
+
|
|
517
|
+
native_targets.each do |native_target|
|
|
518
|
+
update_on_demand_resources_build_settings(native_target, category_to_tags)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
def update_on_demand_resources_build_settings(native_target, category_to_tags)
|
|
523
|
+
%w[ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS ON_DEMAND_RESOURCES_PREFETCH_ORDER].each do |category_key|
|
|
524
|
+
native_target.build_configurations.each do |c|
|
|
525
|
+
key = case category_key
|
|
526
|
+
when 'ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS'
|
|
527
|
+
:initial_install
|
|
528
|
+
when 'ON_DEMAND_RESOURCES_PREFETCH_ORDER'
|
|
529
|
+
:prefetched
|
|
530
|
+
else
|
|
531
|
+
:download_on_demand
|
|
532
|
+
end
|
|
533
|
+
tags_for_category = (c.build_settings[category_key] || '').split
|
|
534
|
+
category_to_tags_dup = category_to_tags.dup
|
|
535
|
+
tags_to_add = category_to_tags_dup.delete(key) || []
|
|
536
|
+
tags_to_delete = category_to_tags_dup.values.flatten
|
|
537
|
+
tags_for_category = (tags_for_category + tags_to_add - tags_to_delete).flatten.compact.uniq
|
|
538
|
+
if tags_for_category.empty?
|
|
539
|
+
val = c.build_settings.delete(category_key)
|
|
540
|
+
native_target.project.mark_dirty! unless val.nil?
|
|
541
|
+
else
|
|
542
|
+
tags = tags_for_category.join(' ')
|
|
543
|
+
unless c.build_settings[category_key] == tags
|
|
544
|
+
c.build_settings[category_key] = tags
|
|
545
|
+
native_target.project.mark_dirty!
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
end
|
|
549
|
+
end
|
|
550
|
+
end
|
|
429
551
|
end
|
|
430
552
|
|
|
431
553
|
# Integrates the user project targets. Only the targets that do **not**
|
|
@@ -445,6 +567,7 @@ module Pod
|
|
|
445
567
|
add_copy_resources_script_phase
|
|
446
568
|
add_check_manifest_lock_script_phase
|
|
447
569
|
add_user_script_phases
|
|
570
|
+
add_on_demand_resources
|
|
448
571
|
end
|
|
449
572
|
end
|
|
450
573
|
|
|
@@ -509,10 +632,12 @@ module Pod
|
|
|
509
632
|
output_paths_by_config = {}
|
|
510
633
|
if use_input_output_paths
|
|
511
634
|
target.resource_paths_by_config.each do |config, resource_paths|
|
|
512
|
-
input_paths_key = XCFileListConfigKey.new(target.copy_resources_script_input_files_path(config),
|
|
635
|
+
input_paths_key = XCFileListConfigKey.new(target.copy_resources_script_input_files_path(config),
|
|
636
|
+
target.copy_resources_script_input_files_relative_path)
|
|
513
637
|
input_paths_by_config[input_paths_key] = [script_path] + resource_paths
|
|
514
638
|
|
|
515
|
-
output_paths_key = XCFileListConfigKey.new(target.copy_resources_script_output_files_path(config),
|
|
639
|
+
output_paths_key = XCFileListConfigKey.new(target.copy_resources_script_output_files_path(config),
|
|
640
|
+
target.copy_resources_script_output_files_relative_path)
|
|
516
641
|
output_paths_by_config[output_paths_key] = TargetIntegrator.resource_output_paths(resource_paths)
|
|
517
642
|
end
|
|
518
643
|
end
|
|
@@ -520,7 +645,9 @@ module Pod
|
|
|
520
645
|
native_targets.each do |native_target|
|
|
521
646
|
# Static library targets cannot include resources. Skip this phase from being added instead.
|
|
522
647
|
next if native_target.symbol_type == :static_library
|
|
523
|
-
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path,
|
|
648
|
+
TargetIntegrator.create_or_update_copy_resources_script_phase_to_target(native_target, script_path,
|
|
649
|
+
input_paths_by_config,
|
|
650
|
+
output_paths_by_config)
|
|
524
651
|
end
|
|
525
652
|
end
|
|
526
653
|
|
|
@@ -624,6 +751,20 @@ module Pod
|
|
|
624
751
|
end
|
|
625
752
|
end
|
|
626
753
|
|
|
754
|
+
def add_on_demand_resources
|
|
755
|
+
target.pod_targets.each do |pod_target|
|
|
756
|
+
# When integrating with the user's project we are only interested in integrating ODRs from library specs
|
|
757
|
+
# and not test specs or app specs.
|
|
758
|
+
library_file_accessors = pod_target.file_accessors.select { |fa| fa.spec.library_specification? }
|
|
759
|
+
target_odr_group_name = "#{pod_target.label}-OnDemandResources"
|
|
760
|
+
# The 'Pods' group would always be there for production code however for tests its sometimes not added.
|
|
761
|
+
# This ensures its always present and makes it easier for existing and new tests.
|
|
762
|
+
parent_odr_group = target.user_project.main_group['Pods'] || target.user_project.new_group('Pods')
|
|
763
|
+
TargetIntegrator.update_on_demand_resources(target.sandbox, target.user_project, target.user_targets,
|
|
764
|
+
library_file_accessors, parent_odr_group, target_odr_group_name)
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
|
|
627
768
|
private
|
|
628
769
|
|
|
629
770
|
# @!group Private Helpers
|
|
@@ -45,6 +45,11 @@ module Pod
|
|
|
45
45
|
#
|
|
46
46
|
attr_reader :info_plist_entries
|
|
47
47
|
|
|
48
|
+
# @return [String] product_basename
|
|
49
|
+
# The product basename to use for the target.
|
|
50
|
+
#
|
|
51
|
+
attr_reader :product_basename
|
|
52
|
+
|
|
48
53
|
# Initialize a new instance
|
|
49
54
|
#
|
|
50
55
|
# @param [Sandbox] sandbox @see #sandbox
|
|
@@ -55,8 +60,10 @@ module Pod
|
|
|
55
60
|
# @param [String] app_target_label see #app_target_label
|
|
56
61
|
# @param [Boolean] add_main see #add_main
|
|
57
62
|
# @param [Hash] info_plist_entries see #info_plist_entries
|
|
63
|
+
# @param [String] product_basename see #product_basename
|
|
58
64
|
#
|
|
59
|
-
def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true,
|
|
65
|
+
def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true,
|
|
66
|
+
add_launchscreen_storyboard: platform == :ios, info_plist_entries: {}, product_basename: nil)
|
|
60
67
|
@sandbox = sandbox
|
|
61
68
|
@project = project
|
|
62
69
|
@platform = platform
|
|
@@ -66,6 +73,7 @@ module Pod
|
|
|
66
73
|
@add_main = add_main
|
|
67
74
|
@add_launchscreen_storyboard = add_launchscreen_storyboard
|
|
68
75
|
@info_plist_entries = info_plist_entries
|
|
76
|
+
@product_basename = product_basename || app_target_label
|
|
69
77
|
target_group = project.pod_group(group_name)
|
|
70
78
|
@group = target_group[subgroup_name] || target_group.new_group(subgroup_name)
|
|
71
79
|
end
|
|
@@ -75,9 +83,9 @@ module Pod
|
|
|
75
83
|
def install!
|
|
76
84
|
platform_name = platform.name
|
|
77
85
|
app_host_target = Pod::Generator::AppTargetHelper.add_app_target(project, platform_name, deployment_target,
|
|
78
|
-
app_target_label)
|
|
86
|
+
app_target_label, product_basename)
|
|
79
87
|
app_host_target.build_configurations.each do |configuration|
|
|
80
|
-
configuration.build_settings['PRODUCT_NAME'] =
|
|
88
|
+
configuration.build_settings['PRODUCT_NAME'] = product_basename
|
|
81
89
|
configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
|
|
82
90
|
if platform == :osx
|
|
83
91
|
configuration.build_settings['CODE_SIGN_IDENTITY'] = ''
|
|
@@ -6,6 +6,9 @@ module Pod
|
|
|
6
6
|
# specifications in the Pods project.
|
|
7
7
|
#
|
|
8
8
|
class FileReferencesInstaller
|
|
9
|
+
# Regex for extracting the region portion of a localized file path. Ex. `Resources/en.lproj` --> `en`
|
|
10
|
+
LOCALIZATION_REGION_FILEPATTERN_REGEX = /(\/|^)(?<region>[^\/]*?)\.lproj(\/|$)/
|
|
11
|
+
|
|
9
12
|
# @return [Sandbox] The sandbox of the installation.
|
|
10
13
|
#
|
|
11
14
|
attr_reader :sandbox
|
|
@@ -18,7 +21,7 @@ module Pod
|
|
|
18
21
|
#
|
|
19
22
|
attr_reader :pods_project
|
|
20
23
|
|
|
21
|
-
# @return [
|
|
24
|
+
# @return [Boolean] add support for preserving the file structure of externally sourced pods, in addition to local pods.
|
|
22
25
|
#
|
|
23
26
|
attr_reader :preserve_pod_file_structure
|
|
24
27
|
|
|
@@ -27,7 +30,7 @@ module Pod
|
|
|
27
30
|
# @param [Sandbox] sandbox @see #sandbox
|
|
28
31
|
# @param [Array<PodTarget>] pod_targets @see #pod_targets
|
|
29
32
|
# @param [Project] pods_project @see #pods_project
|
|
30
|
-
# @param [
|
|
33
|
+
# @param [Boolean] preserve_pod_file_structure @see #preserve_pod_file_structure
|
|
31
34
|
#
|
|
32
35
|
def initialize(sandbox, pod_targets, pods_project, preserve_pod_file_structure = false)
|
|
33
36
|
@sandbox = sandbox
|
|
@@ -126,8 +129,9 @@ module Pod
|
|
|
126
129
|
#
|
|
127
130
|
def add_resources
|
|
128
131
|
UI.message '- Adding resources' do
|
|
129
|
-
add_file_accessors_paths_to_pods_group(:resources, :resources, true)
|
|
130
|
-
add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources, true)
|
|
132
|
+
refs = add_file_accessors_paths_to_pods_group(:resources, :resources, true)
|
|
133
|
+
refs.concat add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources, true)
|
|
134
|
+
add_known_regions(refs)
|
|
131
135
|
end
|
|
132
136
|
end
|
|
133
137
|
|
|
@@ -203,24 +207,24 @@ module Pod
|
|
|
203
207
|
# @param [Symbol] group_key
|
|
204
208
|
# The key of the group of the Pods project.
|
|
205
209
|
#
|
|
206
|
-
# @param [
|
|
210
|
+
# @param [Boolean] reflect_file_system_structure
|
|
207
211
|
# Whether organizing a local pod's files in subgroups inside
|
|
208
212
|
# the pod's group is allowed.
|
|
209
213
|
#
|
|
210
|
-
# @return [
|
|
214
|
+
# @return [Array<PBXFileReference>] the added file references
|
|
211
215
|
#
|
|
212
216
|
def add_file_accessors_paths_to_pods_group(file_accessor_key, group_key = nil, reflect_file_system_structure = false)
|
|
213
|
-
file_accessors.
|
|
217
|
+
file_accessors.flat_map do |file_accessor|
|
|
214
218
|
paths = file_accessor.send(file_accessor_key)
|
|
215
219
|
paths = allowable_project_paths(paths)
|
|
216
|
-
next if paths.empty?
|
|
220
|
+
next [] if paths.empty?
|
|
217
221
|
|
|
218
222
|
pod_name = file_accessor.spec.name
|
|
219
223
|
preserve_pod_file_structure_flag = (sandbox.local?(pod_name) || preserve_pod_file_structure) && reflect_file_system_structure
|
|
220
224
|
base_path = preserve_pod_file_structure_flag ? common_path(paths) : nil
|
|
221
225
|
actual_group_key = preserve_pod_file_structure_flag ? nil : group_key
|
|
222
226
|
group = pods_project.group_for_spec(pod_name, actual_group_key)
|
|
223
|
-
paths.
|
|
227
|
+
paths.map do |path|
|
|
224
228
|
pods_project.add_file_reference(path, group, preserve_pod_file_structure_flag, base_path)
|
|
225
229
|
end
|
|
226
230
|
end
|
|
@@ -239,6 +243,10 @@ module Pod
|
|
|
239
243
|
def allowable_project_paths(paths)
|
|
240
244
|
lproj_paths = Set.new
|
|
241
245
|
lproj_paths_with_files = Set.new
|
|
246
|
+
|
|
247
|
+
# Remove all file ref under .docc folder, but preserve the .docc folder
|
|
248
|
+
paths = merge_to_docc_folder(paths)
|
|
249
|
+
|
|
242
250
|
allowable_paths = paths.select do |path|
|
|
243
251
|
path_str = path.to_s
|
|
244
252
|
|
|
@@ -302,9 +310,54 @@ module Pod
|
|
|
302
310
|
return result unless result.to_s == '' || result.to_s == '/'
|
|
303
311
|
end
|
|
304
312
|
|
|
313
|
+
# Adds the known localization regions to the root of the project
|
|
314
|
+
#
|
|
315
|
+
# @param [Array<PBXFileReferences>] file_references the resource file references
|
|
316
|
+
#
|
|
317
|
+
def add_known_regions(file_references)
|
|
318
|
+
pattern = LOCALIZATION_REGION_FILEPATTERN_REGEX
|
|
319
|
+
regions = file_references.map do |ref|
|
|
320
|
+
if (match = ref.path.to_s.match(pattern))
|
|
321
|
+
match[:region]
|
|
322
|
+
end
|
|
323
|
+
end.compact
|
|
324
|
+
|
|
325
|
+
pods_project.root_object.known_regions = (pods_project.root_object.known_regions | regions).sort
|
|
326
|
+
end
|
|
327
|
+
|
|
305
328
|
#-----------------------------------------------------------------------#
|
|
306
329
|
end
|
|
307
330
|
end
|
|
308
331
|
end
|
|
309
332
|
end
|
|
310
333
|
end
|
|
334
|
+
|
|
335
|
+
# If we have an non-empty .docc folder, remove all paths under the folder
|
|
336
|
+
# but keep the folder itself
|
|
337
|
+
#
|
|
338
|
+
# @param [Array<Pathname>] paths the paths to inspect
|
|
339
|
+
#
|
|
340
|
+
# @return [Array<Pathname>] The resulted list of paths.
|
|
341
|
+
#
|
|
342
|
+
def merge_to_docc_folder(paths)
|
|
343
|
+
docc_paths_with_files = Set.new
|
|
344
|
+
allowable_paths = paths.select do |path|
|
|
345
|
+
path_str = path.to_s
|
|
346
|
+
|
|
347
|
+
if path_str =~ /\.docc(\/|$)/i
|
|
348
|
+
|
|
349
|
+
# we want folder with files
|
|
350
|
+
next if path.directory?
|
|
351
|
+
|
|
352
|
+
# remove everything after ".docc", but keep ".docc"
|
|
353
|
+
folder_path = path_str.split("\.docc")[0] + "\.docc"
|
|
354
|
+
|
|
355
|
+
docc_paths_with_files << Pathname(folder_path)
|
|
356
|
+
next
|
|
357
|
+
|
|
358
|
+
end
|
|
359
|
+
true
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
allowable_paths + docc_paths_with_files.to_a
|
|
363
|
+
end
|
data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb
CHANGED
|
@@ -36,25 +36,24 @@ module Pod
|
|
|
36
36
|
pod_target = pod_target_installation_result.target
|
|
37
37
|
native_target = pod_target_installation_result.native_target
|
|
38
38
|
project = native_target.project
|
|
39
|
-
frameworks_group = project.frameworks_group
|
|
40
39
|
|
|
41
40
|
# First, wire up all resource bundles.
|
|
42
41
|
wire_resource_bundle_targets(pod_target_installation_result.resource_bundle_targets,
|
|
43
42
|
native_target, pod_target)
|
|
44
43
|
# Wire up all dependencies to this pod target, if any.
|
|
45
44
|
wire_target_dependencies(pod_target, native_target, project, pod_target_installation_results,
|
|
46
|
-
metadata_cache
|
|
45
|
+
metadata_cache)
|
|
47
46
|
|
|
48
47
|
# Wire up test native targets.
|
|
49
48
|
unless pod_target_installation_result.test_native_targets.empty?
|
|
50
49
|
wire_test_native_targets(pod_target, pod_target_installation_result, pod_target_installation_results,
|
|
51
|
-
project,
|
|
50
|
+
project, metadata_cache)
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
# Wire up app native targets.
|
|
55
54
|
unless pod_target_installation_result.app_native_targets.empty?
|
|
56
55
|
wire_app_native_targets(pod_target, pod_target_installation_result, pod_target_installation_results,
|
|
57
|
-
project,
|
|
56
|
+
project, metadata_cache)
|
|
58
57
|
end
|
|
59
58
|
end
|
|
60
59
|
end
|
|
@@ -70,8 +69,7 @@ module Pod
|
|
|
70
69
|
end
|
|
71
70
|
end
|
|
72
71
|
|
|
73
|
-
def wire_target_dependencies(pod_target, native_target, project,
|
|
74
|
-
pod_target_installation_results, metadata_cache, frameworks_group)
|
|
72
|
+
def wire_target_dependencies(pod_target, native_target, project, pod_target_installation_results, metadata_cache)
|
|
75
73
|
dependent_targets = pod_target.dependent_targets
|
|
76
74
|
dependent_targets.each do |dependent_target|
|
|
77
75
|
is_local = sandbox.local?(dependent_target.pod_name)
|
|
@@ -81,7 +79,6 @@ module Pod
|
|
|
81
79
|
project.add_pod_subproject(dependent_project, is_local)
|
|
82
80
|
end
|
|
83
81
|
native_target.add_dependency(installation_result.native_target)
|
|
84
|
-
add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
|
|
85
82
|
else
|
|
86
83
|
# Hit the cache
|
|
87
84
|
cached_dependency = metadata_cache.target_label_by_metadata[dependent_target.label]
|
|
@@ -91,7 +88,7 @@ module Pod
|
|
|
91
88
|
end
|
|
92
89
|
end
|
|
93
90
|
|
|
94
|
-
def wire_test_native_targets(pod_target, installation_result, pod_target_installation_results, project,
|
|
91
|
+
def wire_test_native_targets(pod_target, installation_result, pod_target_installation_results, project, metadata_cache)
|
|
95
92
|
installation_result.test_specs_by_native_target.each do |test_native_target, test_spec|
|
|
96
93
|
resource_bundle_native_targets = installation_result.test_resource_bundle_targets[test_spec.name] || []
|
|
97
94
|
resource_bundle_native_targets.each do |test_resource_bundle_target|
|
|
@@ -107,7 +104,6 @@ module Pod
|
|
|
107
104
|
project.add_pod_subproject(dependent_test_project, is_local)
|
|
108
105
|
end
|
|
109
106
|
test_native_target.add_dependency(dependency_installation_result.native_target)
|
|
110
|
-
add_framework_file_reference_to_native_target(test_native_target, pod_target, test_dependent_target, frameworks_group)
|
|
111
107
|
else
|
|
112
108
|
# Hit the cache
|
|
113
109
|
cached_dependency = metadata_cache.target_label_by_metadata[test_dependent_target.label]
|
|
@@ -162,7 +158,7 @@ module Pod
|
|
|
162
158
|
end
|
|
163
159
|
end
|
|
164
160
|
|
|
165
|
-
def wire_app_native_targets(pod_target, installation_result, pod_target_installation_results, project,
|
|
161
|
+
def wire_app_native_targets(pod_target, installation_result, pod_target_installation_results, project, metadata_cache)
|
|
166
162
|
installation_result.app_specs_by_native_target.each do |app_native_target, app_spec|
|
|
167
163
|
resource_bundle_native_targets = installation_result.app_resource_bundle_targets[app_spec.name] || []
|
|
168
164
|
resource_bundle_native_targets.each do |app_resource_bundle_target|
|
|
@@ -184,7 +180,6 @@ module Pod
|
|
|
184
180
|
project.add_pod_subproject(dependency_project, is_local)
|
|
185
181
|
end
|
|
186
182
|
app_native_target.add_dependency(dependency_installation_result.native_target)
|
|
187
|
-
add_framework_file_reference_to_native_target(app_native_target, pod_target, app_dependent_target, frameworks_group)
|
|
188
183
|
else
|
|
189
184
|
# Hit the cache
|
|
190
185
|
cached_dependency = metadata_cache.target_label_by_metadata[app_dependent_target.label]
|
|
@@ -194,14 +189,6 @@ module Pod
|
|
|
194
189
|
end
|
|
195
190
|
end
|
|
196
191
|
end
|
|
197
|
-
|
|
198
|
-
def add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
|
|
199
|
-
if pod_target.should_build? && pod_target.build_as_dynamic? && dependent_target.should_build?
|
|
200
|
-
product_ref = frameworks_group.files.find { |f| f.path == dependent_target.product_name } ||
|
|
201
|
-
frameworks_group.new_product_ref_for_target(dependent_target.product_basename, dependent_target.product_type)
|
|
202
|
-
native_target.frameworks_build_phase.add_file_reference(product_ref, true)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
192
|
end
|
|
206
193
|
end
|
|
207
194
|
end
|