cocoapods 1.8.4 → 1.9.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -1
  3. data/lib/cocoapods.rb +1 -0
  4. data/lib/cocoapods/command/setup.rb +1 -0
  5. data/lib/cocoapods/executable.rb +1 -1
  6. data/lib/cocoapods/gem_version.rb +1 -1
  7. data/lib/cocoapods/generator/embed_frameworks_script.rb +36 -6
  8. data/lib/cocoapods/generator/prepare_artifacts_script.rb +244 -0
  9. data/lib/cocoapods/installer.rb +6 -5
  10. data/lib/cocoapods/installer/analyzer.rb +137 -59
  11. data/lib/cocoapods/installer/analyzer/pod_variant.rb +27 -12
  12. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +11 -2
  13. data/lib/cocoapods/installer/project_cache/project_cache_analyzer.rb +10 -2
  14. data/lib/cocoapods/installer/project_cache/project_installation_cache.rb +15 -2
  15. data/lib/cocoapods/installer/project_cache/target_cache_key.rb +7 -5
  16. data/lib/cocoapods/installer/user_project_integrator.rb +1 -10
  17. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +100 -19
  18. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +3 -0
  19. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +29 -4
  20. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +7 -2
  21. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +106 -45
  22. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +68 -1
  23. data/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb +29 -14
  24. data/lib/cocoapods/sandbox/file_accessor.rb +32 -21
  25. data/lib/cocoapods/sources_manager.rb +9 -2
  26. data/lib/cocoapods/target.rb +11 -14
  27. data/lib/cocoapods/target/aggregate_target.rb +78 -18
  28. data/lib/cocoapods/target/build_settings.rb +64 -31
  29. data/lib/cocoapods/target/pod_target.rb +236 -87
  30. data/lib/cocoapods/user_interface/error_report.rb +14 -4
  31. data/lib/cocoapods/validator.rb +2 -0
  32. data/lib/cocoapods/xcode.rb +7 -0
  33. data/lib/cocoapods/{target → xcode}/framework_paths.rb +14 -1
  34. data/lib/cocoapods/xcode/linkage_analyzer.rb +22 -0
  35. data/lib/cocoapods/xcode/xcframework.rb +81 -0
  36. data/lib/cocoapods/xcode/xcframework/xcframework_slice.rb +51 -0
  37. metadata +12 -8
  38. data/lib/cocoapods/target/build_type.rb +0 -139
@@ -337,7 +337,7 @@ module Pod
337
337
  cli_host_with_frameworks = []
338
338
  cli_product_type = 'com.apple.product-type.tool'
339
339
  # Collect aggregate target definitions by uuid to later lookup host target
340
- # definitions and verify their compatiblity with their embedded targets
340
+ # definitions and verify their compatibility with their embedded targets
341
341
  aggregate_targets.each do |target|
342
342
  target.user_targets.each do |user_target|
343
343
  target_definitions_by_uuid[user_target.uuid] = target.target_definition
@@ -415,11 +415,11 @@ module Pod
415
415
 
416
416
  # Creates the models that represent the targets generated by CocoaPods.
417
417
  #
418
- # @param [Hash{Podfile::TargetDefinition => Array<ResolvedSpecification>}] resolver_specs_by_target
418
+ # @param [Hash{TargetDefinition => Array<ResolvedSpecification>}] resolver_specs_by_target
419
419
  # mapping of targets to resolved specs (containing information about test usage)
420
420
  # aggregate targets
421
421
  #
422
- # @param [Array<TargetInspection>] target_inspections
422
+ # @param [Hash{TargetDefinition => TargetInspectionResult}] target_inspections
423
423
  # the user target inspections used to construct the aggregate and pod targets.
424
424
  #
425
425
  # @return [(Array<AggregateTarget>, Array<PodTarget>)] the list of aggregate targets generated,
@@ -442,7 +442,9 @@ module Pod
442
442
  aggregate_targets.each do |aggregate_target|
443
443
  is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) &
444
444
  [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?
445
- is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' }
445
+ is_app_extension ||= aggregate_target.user_targets.any? do |user_target|
446
+ user_target.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY', :resolve_against_xcconfig => true) == 'YES'
447
+ end
446
448
 
447
449
  next unless is_app_extension
448
450
 
@@ -456,7 +458,7 @@ module Pod
456
458
  embedded_targets = aggregate_targets.select(&:requires_host_target?)
457
459
  analyze_host_targets_in_podfile(aggregate_targets, embedded_targets)
458
460
 
459
- use_frameworks_embedded_targets, non_use_frameworks_embedded_targets = embedded_targets.partition(&:host_requires_frameworks?)
461
+ use_frameworks_embedded_targets, non_use_frameworks_embedded_targets = embedded_targets.partition(&:build_as_framework?)
460
462
  aggregate_targets = aggregate_targets.map do |aggregate_target|
461
463
  # For targets that require dynamic frameworks, we always have to copy their pods to their
462
464
  # host targets because those frameworks will all be loaded from the host target's bundle
@@ -481,7 +483,7 @@ module Pod
481
483
  # @param [Hash{TargetDefinition => TargetInspectionResult}] target_inspections
482
484
  # the user target inspections used to construct the aggregate and pod targets.
483
485
  #
484
- # @param [Hash{Podfile::TargetDefinition => Array<PodTarget>}] pod_targets_by_target_definition
486
+ # @param [Hash{TargetDefinition => Array<PodTarget>}] pod_targets_by_target_definition
485
487
  # the pod targets grouped by target.
486
488
  #
487
489
  # @return [AggregateTarget]
@@ -506,13 +508,12 @@ module Pod
506
508
  end
507
509
  platform = target_definition.platform
508
510
  build_configurations = user_build_configurations.keys.concat(target_definition.all_whitelisted_configurations).uniq
509
- pod_targets_for_build_configuration = filter_pod_targets_for_target_definition(target_definition, pod_targets_by_target_definition,
511
+ pod_targets_for_build_configuration = filter_pod_targets_for_target_definition(target_definition,
512
+ pod_targets_by_target_definition,
510
513
  build_configurations)
511
-
512
- build_type = target_definition.uses_frameworks? ? Target::BuildType.static_framework : Target::BuildType.static_library
513
- AggregateTarget.new(sandbox, target_definition.uses_frameworks?, user_build_configurations, archs, platform,
514
- target_definition, client_root, user_project, user_target_uuids,
515
- pod_targets_for_build_configuration, :build_type => build_type)
514
+ build_type = target_definition.uses_frameworks? ? BuildType.static_framework : BuildType.static_library
515
+ AggregateTarget.new(sandbox, build_type, user_build_configurations, archs, platform, target_definition,
516
+ client_root, user_project, user_target_uuids, pod_targets_for_build_configuration)
516
517
  end
517
518
 
518
519
  # Returns a filtered list of pod targets that should or should not be part of the target definition. Pod targets
@@ -542,16 +543,17 @@ module Pod
542
543
  # @param [TargetDefinition] target_definition
543
544
  # the target definition to use as the base for filtering
544
545
  #
545
- # @param [Hash{Podfile::TargetDefinition => Array<PodTarget>}] pod_targets_by_target_definition
546
+ # @param [Hash{TargetDefinition => Array<PodTarget>}] pod_targets_by_target_definition
546
547
  # the pod targets grouped by target.
547
548
  #
548
549
  # @param [Array<String>] build_configurations
549
550
  # The list of all build configurations the targets will be built for.
550
551
  #
551
- # @return [Hash<String => Array<PodTarget>>]
552
+ # @return [Hash{String => Array<PodTarget>}]
552
553
  # the filtered list of pod targets, grouped by build configuration.
553
554
  #
554
- def filter_pod_targets_for_target_definition(target_definition, pod_targets_by_target_definition, build_configurations)
555
+ def filter_pod_targets_for_target_definition(target_definition, pod_targets_by_target_definition,
556
+ build_configurations)
555
557
  pod_targets_by_build_config = Hash.new([].freeze)
556
558
  build_configurations.each { |config| pod_targets_by_build_config[config] = [] }
557
559
 
@@ -588,7 +590,7 @@ module Pod
588
590
  # targets by grouping by platform and subspec by their root
589
591
  # to create a {PodTarget} for each spec.
590
592
  #
591
- # @param [Hash{Podfile::TargetDefinition => Array<ResolvedSpecification>}] resolver_specs_by_target
593
+ # @param [Hash{TargetDefinition => Array<ResolvedSpecification>}] resolver_specs_by_target
592
594
  # the resolved specifications grouped by target.
593
595
  #
594
596
  # @param [Hash{TargetDefinition => TargetInspectionResult}] target_inspections
@@ -606,8 +608,8 @@ module Pod
606
608
  library_specs = all_specs_by_type[:library] || []
607
609
  test_specs = all_specs_by_type[:test] || []
608
610
  app_specs = all_specs_by_type[:app] || []
609
- target_type = Target::BuildType.infer_from_spec(root_spec, :host_requires_frameworks => target_definition.uses_frameworks?)
610
- pod_variant = PodVariant.new(library_specs, test_specs, app_specs, target_definition.platform, target_type)
611
+ build_type = determine_build_type(root_spec, target_definition.build_type)
612
+ pod_variant = PodVariant.new(library_specs, test_specs, app_specs, target_definition.platform, build_type)
611
613
  hash[root_spec] ||= {}
612
614
  (hash[root_spec][pod_variant] ||= []) << target_definition
613
615
  pod_variant_spec = hash[root_spec].keys.find { |k| k == pod_variant }
@@ -616,13 +618,25 @@ module Pod
616
618
  end
617
619
  end
618
620
 
621
+ # Remap pod variants to a new instance that includes the Swift version since we now have the full set
622
+ # of target definitions.
623
+ distinct_targets = Hash[distinct_targets.map do |root, target_definitions_by_variant|
624
+ variants = Hash[target_definitions_by_variant.map do |variant, target_definitions|
625
+ swift_version = determine_swift_version(variant.root_spec, target_definitions)
626
+ [variant.scoped_with_swift_version(swift_version), target_definitions]
627
+ end]
628
+ [root, variants]
629
+ end]
630
+
619
631
  pod_targets = distinct_targets.flat_map do |_root, target_definitions_by_variant|
620
632
  target_definitions_by_variant.each_value do |target_definitions|
621
633
  target_definitions.reject!(&:abstract?) unless target_definitions.all?(&:abstract?)
622
634
  end
623
635
  suffixes = PodVariantSet.new(target_definitions_by_variant.keys).scope_suffixes
624
636
  target_definitions_by_variant.map do |variant, target_definitions|
625
- generate_pod_target(target_definitions, target_inspections, variant.specs + variant.test_specs + variant.app_specs, :build_type => variant.build_type, :scope_suffix => suffixes[variant])
637
+ all_specs = variant.specs + variant.test_specs + variant.app_specs
638
+ generate_pod_target(target_definitions, variant.build_type, target_inspections, all_specs,
639
+ :scope_suffix => suffixes[variant], :swift_version => variant.swift_version)
626
640
  end
627
641
  end
628
642
 
@@ -633,8 +647,8 @@ module Pod
633
647
  resolver_specs_by_target.flat_map do |target_definition, specs|
634
648
  grouped_specs = specs.group_by(&:root).values.uniq
635
649
  pod_targets = grouped_specs.flat_map do |pod_specs|
636
- target_type = Target::BuildType.infer_from_spec(pod_specs.first, :host_requires_frameworks => target_definition.uses_frameworks?)
637
- generate_pod_target([target_definition], target_inspections, pod_specs.map(&:spec), :build_type => target_type).scoped(dedupe_cache)
650
+ build_type = determine_build_type(pod_specs.first, target_definition.build_type)
651
+ generate_pod_target([target_definition], build_type, target_inspections, pod_specs.map(&:spec)).scoped(dedupe_cache)
638
652
  end
639
653
 
640
654
  compute_pod_target_dependencies(pod_targets, specs.map(&:spec).group_by(&:name))
@@ -660,23 +674,26 @@ module Pod
660
674
  end
661
675
 
662
676
  pod_targets.each do |target|
663
- dependencies = dependencies_for_specs(target.library_specs.to_set, target.platform, all_specs).group_by(&:root)
664
- target.dependent_targets = filter_dependencies(dependencies, pod_targets_by_name, target)
665
- target.test_dependent_targets_by_spec_name = target.test_specs.each_with_object({}) do |test_spec, hash|
666
- test_dependencies = dependencies_for_specs([test_spec], target.platform, all_specs).group_by(&:root)
667
- test_dependencies.delete_if { |k, _| dependencies.key? k }
668
- hash[test_spec.name] = filter_dependencies(test_dependencies, pod_targets_by_name, target)
677
+ dependencies_by_config = dependencies_for_specs(target.library_specs, target.platform, all_specs)
678
+ target.dependent_targets_by_config = Hash[dependencies_by_config.map { |k, v| [k, filter_dependencies(v, pod_targets_by_name, target)] }]
679
+
680
+ target.test_dependent_targets_by_spec_name_by_config = target.test_specs.each_with_object({}) do |test_spec, hash|
681
+ test_dependencies_by_config = dependencies_for_specs([test_spec], target.platform, all_specs)
682
+ test_dependencies_by_config.each { |config, deps| deps.delete_if { |k, _| dependencies_by_config[config].key? k } }
683
+ hash[test_spec.name] = Hash[test_dependencies_by_config.map { |k, v| [k, filter_dependencies(v, pod_targets_by_name, target)] }]
669
684
  end
670
685
 
671
- target.app_dependent_targets_by_spec_name = target.app_specs.each_with_object({}) do |app_spec, hash|
672
- app_dependencies = dependencies_for_specs([app_spec], target.platform, all_specs).group_by(&:root)
673
- app_dependencies.delete_if { |k, _| dependencies.key? k }
674
- hash[app_spec.name] = filter_dependencies(app_dependencies, pod_targets_by_name, target)
686
+ target.app_dependent_targets_by_spec_name_by_config = target.app_specs.each_with_object({}) do |app_spec, hash|
687
+ app_dependencies_by_config = dependencies_for_specs([app_spec], target.platform, all_specs)
688
+ app_dependencies_by_config.each { |config, deps| deps.delete_if { |k, _| dependencies_by_config[config].key? k } }
689
+ hash[app_spec.name] = Hash[app_dependencies_by_config.map { |k, v| [k, filter_dependencies(v, pod_targets_by_name, target)] }]
675
690
  end
676
691
 
677
692
  target.test_app_hosts_by_spec_name = target.test_specs.each_with_object({}) do |test_spec, hash|
678
693
  next unless app_host_name = test_spec.consumer(target.platform).app_host_name
679
- app_host_spec = pod_targets_by_name[Specification.root_name(app_host_name)].flat_map(&:app_specs).find { |pt| pt.name == app_host_name }
694
+ app_host_spec = pod_targets_by_name[Specification.root_name(app_host_name)].flat_map(&:app_specs).find do |pt|
695
+ pt.name == app_host_name
696
+ end
680
697
  app_host_dependencies = { app_host_spec.root => [app_host_spec] }
681
698
  hash[test_spec.name] = [app_host_spec, filter_dependencies(app_host_dependencies, pod_targets_by_name, target).first]
682
699
  end
@@ -687,7 +704,7 @@ module Pod
687
704
  dependencies.map do |root_spec, deps|
688
705
  pod_targets_by_name[root_spec.name].find do |t|
689
706
  next false if t.platform.symbolic_name != target.platform.symbolic_name ||
690
- t.host_requires_frameworks? != target.host_requires_frameworks? # rather than target type or requires_frameworks? since we want to group by what was specified in that _target definition_
707
+ t.build_as_framework? != target.build_as_framework? # rather than target type or requires_frameworks? since we want to group by what was specified in that _target definition_
691
708
  spec_names = t.specs.map(&:name)
692
709
  deps.all? { |dep| spec_names.include?(dep.name) }
693
710
  end
@@ -705,38 +722,48 @@ module Pod
705
722
  # @param [Platform] platform
706
723
  # The platform for which the dependencies should be returned.
707
724
  #
708
- # @param [Hash<String, Specification>] all_specs
725
+ # @param [Hash{String => Array<Specification>}] all_specs
709
726
  # All specifications which are installed alongside.
710
727
  #
711
- # @return [Array<Specification>]
728
+ # @return [Hash{Symbol => Set<Specification>}]
712
729
  #
713
730
  def dependencies_for_specs(specs, platform, all_specs)
714
- return [] if specs.empty? || all_specs.empty?
715
-
716
- dependent_specs = Set.new
731
+ dependent_specs = {
732
+ :debug => Set.new,
733
+ :release => Set.new,
734
+ }
735
+
736
+ if !specs.empty? && !all_specs.empty?
737
+ specs.each do |s|
738
+ s.dependencies(platform).each do |dep|
739
+ all_specs[dep.name].each do |spec|
740
+ if spec.non_library_specification?
741
+ if s.test_specification? && spec.name == s.consumer(platform).app_host_name && spec.app_specification?
742
+ # This needs to be handled separately, since we _don't_ want to treat this as a "normal" dependency
743
+ next
744
+ end
745
+ raise Informative, "`#{s}` depends upon `#{spec}`, which is a `#{spec.spec_type}` spec."
746
+ end
717
747
 
718
- specs.each do |s|
719
- s.dependencies(platform).each do |dep|
720
- all_specs[dep.name].each do |spec|
721
- if spec.non_library_specification?
722
- if s.test_specification? && spec.name == s.consumer(platform).app_host_name && spec.app_specification?
723
- # This needs to be handled separately, since we _don't_ want to treat this as a "normal" dependency
724
- next
748
+ dependent_specs.each do |config, set|
749
+ next unless s.dependency_whitelisted_for_configuration?(dep, config)
750
+ set << spec
725
751
  end
726
- raise Informative, "#{s} depends upon `#{spec}`, which is a `#{spec.spec_type}` spec."
727
752
  end
728
- dependent_specs << spec
729
753
  end
730
754
  end
731
755
  end
732
756
 
733
- dependent_specs - specs
757
+ Hash[dependent_specs.map { |k, v| [k, (v - specs).group_by(&:root)] }].freeze
734
758
  end
735
759
 
736
760
  # Create a target for each spec group
737
761
  #
738
762
  # @param [Array<TargetDefinition>] target_definitions
739
- # the target definitions of the aggregate target
763
+ # the target definitions of the pod target
764
+ #
765
+ # @param [BuildType] build_type
766
+ # the BuildType to use for this pod target.
740
767
  #
741
768
  # @param [Hash{TargetDefinition => TargetInspectionResult}] target_inspections
742
769
  # the user target inspections used to construct the aggregate and pod targets.
@@ -747,9 +774,13 @@ module Pod
747
774
  # @param [String] scope_suffix
748
775
  # @see PodTarget#scope_suffix
749
776
  #
777
+ # @param [String] swift_version
778
+ # @see PodTarget#swift_version
779
+ #
750
780
  # @return [PodTarget]
751
781
  #
752
- def generate_pod_target(target_definitions, target_inspections, specs, scope_suffix: nil, build_type: nil)
782
+ def generate_pod_target(target_definitions, build_type, target_inspections, specs, scope_suffix: nil,
783
+ swift_version: nil)
753
784
  target_inspections = target_inspections.select { |t, _| target_definitions.include?(t) }.values
754
785
  object_version = target_inspections.map { |ti| ti.project.object_version }.min
755
786
  target_requires_64_bit = target_definitions.all? { |td| Analyzer.requires_64_bit_archs?(td.platform, object_version) }
@@ -761,14 +792,15 @@ module Pod
761
792
  target_inspections.flat_map(&:archs).compact.uniq.sort
762
793
  end
763
794
  else
764
- user_build_configurations = Target::DEFAULT_BUILD_CONFIGURATIONS
795
+ user_build_configurations = Target::DEFAULT_BUILD_CONFIGURATIONS.merge(
796
+ target_definitions.map { |td| td.build_configurations || {} }.reduce({}, &:merge),
797
+ )
765
798
  archs = target_requires_64_bit ? ['$(ARCHS_STANDARD_64_BIT)'] : []
766
799
  end
767
- host_requires_frameworks = target_definitions.any?(&:uses_frameworks?)
768
- platform = determine_platform(specs, target_definitions, host_requires_frameworks)
800
+ platform = determine_platform(specs, target_definitions, build_type)
769
801
  file_accessors = create_file_accessors(specs, platform)
770
- PodTarget.new(sandbox, host_requires_frameworks, user_build_configurations, archs, platform, specs,
771
- target_definitions, file_accessors, scope_suffix, :build_type => build_type)
802
+ PodTarget.new(sandbox, build_type, user_build_configurations, archs, platform, specs, target_definitions,
803
+ file_accessors, scope_suffix, swift_version)
772
804
  end
773
805
 
774
806
  # Creates the file accessors for a given pod.
@@ -802,25 +834,71 @@ module Pod
802
834
  # @param [Array<TargetDefinition>] target_definitions
803
835
  # the target definitions these specs are part of.
804
836
  #
805
- # @param [Boolean] host_requires_frameworks
806
- # whether the platform is calculated for a target that needs to be packaged as a framework.
837
+ # @param [BuildType] build_type
838
+ # the #BuildType used for calculating the platform.
807
839
  #
808
840
  # @return [Platform]
809
841
  #
810
- def determine_platform(specs, target_definitions, host_requires_frameworks)
842
+ def determine_platform(specs, target_definitions, build_type)
811
843
  library_specs = specs.select(&:library_specification?)
812
844
  platform_name = target_definitions.first.platform.name
813
845
  default = Podfile::TargetDefinition::PLATFORM_DEFAULTS[platform_name]
814
846
  deployment_target = library_specs.map do |library_spec|
815
847
  Version.new(library_spec.deployment_target(platform_name) || default)
816
848
  end.max
817
- if platform_name == :ios && host_requires_frameworks
849
+ if platform_name == :ios && build_type.framework?
818
850
  minimum = Version.new('8.0')
819
851
  deployment_target = [deployment_target, minimum].max
820
852
  end
821
853
  Platform.new(platform_name, deployment_target)
822
854
  end
823
855
 
856
+ # Determines the Swift version for the given spec within a list of target definitions. If the pod author has
857
+ # provided a set of Swift versions supported by their pod then the max Swift version is chosen, unless the target
858
+ # definitions specify explicit requirements for supported Swift versions. Otherwise the Swift version is derived
859
+ # by the target definitions that integrate this pod.
860
+ #
861
+ # @param [Specification] spec
862
+ # the specs to inspect and determine what Swift version to use.
863
+ #
864
+ # @param [Array<TargetDefinition>] target_definitions
865
+ # the target definitions the spec is part of.
866
+ #
867
+ # @return [String, nil] the computed Swift version or `nil` if the Swift version could not be determined.
868
+ #
869
+ def determine_swift_version(spec, target_definitions)
870
+ if spec.swift_versions.empty?
871
+ target_definitions.map(&:swift_version).compact.uniq.first
872
+ else
873
+ spec.swift_versions.sort.reverse_each.find do |swift_version|
874
+ target_definitions.all? do |td|
875
+ td.supports_swift_version?(swift_version)
876
+ end
877
+ end.to_s
878
+ end
879
+ end
880
+
881
+ # Calculates and returns the #BuildType to use for the given spec. If the spec specifies `static_framework` then
882
+ # it is honored as long as the host #BuildType also requires its pods to be integrated as frameworks.
883
+ #
884
+ # @param [Specification] spec
885
+ # the spec to determine the #BuildType for.
886
+ #
887
+ # @param [BuildType] target_definition_build_type
888
+ # The desired #BuildType by the target definition that integrates this target. If the pod target spec does
889
+ # not specify explicitly a `static_framework` #BuildType then the one from the target definition is used.
890
+ #
891
+ # @return [BuildType]
892
+ #
893
+ def determine_build_type(spec, target_definition_build_type)
894
+ if target_definition_build_type.framework?
895
+ root_spec = spec.root
896
+ root_spec.static_framework ? BuildType.static_framework : target_definition_build_type
897
+ else
898
+ BuildType.static_library
899
+ end
900
+ end
901
+
824
902
  # Generates dependencies that require the specific version of the Pods
825
903
  # that haven't changed in the {Lockfile}.
826
904
  #
@@ -19,15 +19,13 @@ module Pod
19
19
  #
20
20
  attr_reader :platform
21
21
 
22
- # @return [Target::BuildType] the build type of the target
22
+ # @return [BuildType] the build type of the target
23
23
  #
24
24
  attr_reader :build_type
25
25
 
26
- # @return [Specification] the root specification
26
+ # @return [String] the Swift version of the target.
27
27
  #
28
- def root_spec
29
- specs.first.root
30
- end
28
+ attr_reader :swift_version
31
29
 
32
30
  # Initialize a new instance from its attributes.
33
31
  #
@@ -35,26 +33,35 @@ module Pod
35
33
  # @param [Array<Specification>] test_specs @see #test_specs
36
34
  # @param [Array<Specification>] app_specs @see #app_specs
37
35
  # @param [Platform] platform @see #platform
38
- # @param [Target::BuildType] build_type @see #build_type
36
+ # @param [BuildType] build_type @see #build_type
37
+ # @param [String] swift_version @see #swift_version
39
38
  #
40
- def initialize(specs, test_specs, app_specs, platform, build_type = Target::BuildType.static_library)
39
+ def initialize(specs, test_specs, app_specs, platform, build_type = BuildType.static_library,
40
+ swift_version = nil)
41
41
  @specs = specs
42
42
  @test_specs = test_specs
43
43
  @app_specs = app_specs
44
44
  @platform = platform
45
45
  @build_type = build_type
46
- @hash = [specs, platform, build_type].hash
46
+ @swift_version = swift_version
47
+ @hash = [specs, platform, build_type, swift_version].hash
48
+ end
49
+
50
+ # @return [Specification] the root specification
51
+ #
52
+ def root_spec
53
+ specs.first.root
47
54
  end
48
55
 
49
- # @note Test specs are intentionally not included as part of the equality for pod variants since a
50
- # pod variant should not be affected by the number of test nor app specs included.
56
+ # @note Non library specs are intentionally not included as part of the equality for pod variants since a pod
57
+ # variant should not be affected by the number of test nor app specs included.
51
58
  #
52
- # @return [Bool] whether the {PodVariant} is equal to another taking all
53
- # all their attributes into account
59
+ # @return [Bool] whether the {PodVariant} is equal to another taking all all their attributes into account
54
60
  #
55
61
  def ==(other)
56
62
  self.class == other.class &&
57
63
  build_type == other.build_type &&
64
+ swift_version == other.swift_version &&
58
65
  platform == other.platform &&
59
66
  specs == other.specs
60
67
  end
@@ -66,6 +73,14 @@ module Pod
66
73
  #
67
74
  # @!visibility private
68
75
  attr_reader :hash
76
+
77
+ # @param [String] swift_version The swift version to use for this variant.
78
+ #
79
+ # @return [PodVariant] A copy of this pod variant with the specified Swift version.
80
+ #
81
+ def scoped_with_swift_version(swift_version)
82
+ PodVariant.new(specs, test_specs, app_specs, platform, build_type, swift_version)
83
+ end
69
84
  end
70
85
  end
71
86
  end
@@ -98,7 +98,16 @@ module Pod
98
98
  # => Platform name + SDK version
99
99
  platform_name_proc = proc { |v| v.platform.to_s.tr(' ', '') }
100
100
  end
101
- scope_if_necessary(grouped_variants.map(&:scope_without_suffix), &platform_name_proc)
101
+ scope_if_necessary(grouped_variants.map(&:scope_by_swift_version), &platform_name_proc)
102
+ end
103
+
104
+ # @private
105
+ # @return [Hash<PodVariant, String>]
106
+ #
107
+ def scope_by_swift_version
108
+ scope_if_necessary(group_by(&:swift_version).map(&:scope_without_suffix)) do |variant|
109
+ variant.swift_version ? "Swift#{variant.swift_version}" : ''
110
+ end
102
111
  end
103
112
 
104
113
  # @private
@@ -113,7 +122,7 @@ module Pod
113
122
  root_spec.default_subspecs.map do |subspec_name|
114
123
  root_spec.subspec_by_name("#{root_spec.name}/#{subspec_name}")
115
124
  end
116
- end
125
+ end
117
126
  default_specs = Set.new(specs)
118
127
  grouped_variants = group_by(&:specs)
119
128
  all_spec_variants = grouped_variants.map { |set| set.variants.first.specs }