cocoapods 1.5.2 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +365 -1
  3. data/bin/pod +1 -1
  4. data/lib/cocoapods/command/cache/clean.rb +1 -1
  5. data/lib/cocoapods/command/init.rb +4 -2
  6. data/lib/cocoapods/command/install.rb +7 -0
  7. data/lib/cocoapods/command/lib/lint.rb +8 -1
  8. data/lib/cocoapods/command/outdated.rb +4 -9
  9. data/lib/cocoapods/command/repo/add.rb +1 -1
  10. data/lib/cocoapods/command/repo/list.rb +1 -1
  11. data/lib/cocoapods/command/repo/push.rb +17 -12
  12. data/lib/cocoapods/command/repo/remove.rb +1 -1
  13. data/lib/cocoapods/command/repo/update.rb +1 -1
  14. data/lib/cocoapods/command/setup.rb +1 -1
  15. data/lib/cocoapods/command/spec/create.rb +39 -39
  16. data/lib/cocoapods/command/spec/lint.rb +8 -1
  17. data/lib/cocoapods/command.rb +3 -1
  18. data/lib/cocoapods/config.rb +13 -2
  19. data/lib/cocoapods/downloader/cache.rb +1 -1
  20. data/lib/cocoapods/executable.rb +3 -3
  21. data/lib/cocoapods/external_sources/abstract_external_source.rb +23 -13
  22. data/lib/cocoapods/external_sources.rb +7 -4
  23. data/lib/cocoapods/gem_version.rb +1 -1
  24. data/lib/cocoapods/generator/acknowledgements/markdown.rb +6 -0
  25. data/lib/cocoapods/generator/acknowledgements/plist.rb +13 -2
  26. data/lib/cocoapods/generator/app_target_helper.rb +141 -17
  27. data/lib/cocoapods/generator/copy_resources_script.rb +14 -3
  28. data/lib/cocoapods/generator/dummy_source.rb +14 -5
  29. data/lib/cocoapods/generator/embed_frameworks_script.rb +37 -20
  30. data/lib/cocoapods/generator/header.rb +1 -1
  31. data/lib/cocoapods/generator/info_plist_file.rb +12 -4
  32. data/lib/cocoapods/generator/prefix_header.rb +2 -2
  33. data/lib/cocoapods/hooks_manager.rb +28 -17
  34. data/lib/cocoapods/installer/analyzer/analysis_result.rb +52 -22
  35. data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +14 -6
  36. data/lib/cocoapods/installer/analyzer/pod_variant.rb +4 -5
  37. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +3 -14
  38. data/lib/cocoapods/installer/analyzer/specs_state.rb +28 -4
  39. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +27 -14
  40. data/lib/cocoapods/installer/analyzer/target_inspector.rb +17 -11
  41. data/lib/cocoapods/installer/analyzer.rb +391 -284
  42. data/lib/cocoapods/installer/installation_options.rb +2 -0
  43. data/lib/cocoapods/installer/pod_source_installer.rb +31 -43
  44. data/lib/cocoapods/installer/post_install_hooks_context.rb +72 -47
  45. data/lib/cocoapods/installer/pre_install_hooks_context.rb +22 -13
  46. data/lib/cocoapods/installer/source_provider_hooks_context.rb +3 -1
  47. data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +44 -11
  48. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +69 -29
  49. data/lib/cocoapods/installer/user_project_integrator.rb +6 -4
  50. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +25 -16
  51. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +104 -0
  52. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +23 -50
  53. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +296 -177
  54. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +51 -33
  55. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +93 -0
  56. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +62 -69
  57. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +72 -0
  58. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +130 -122
  59. data/lib/cocoapods/installer/xcode/target_validator.rb +15 -9
  60. data/lib/cocoapods/installer.rb +140 -63
  61. data/lib/cocoapods/project.rb +16 -14
  62. data/lib/cocoapods/resolver/resolver_specification.rb +41 -0
  63. data/lib/cocoapods/resolver.rb +79 -98
  64. data/lib/cocoapods/sandbox/file_accessor.rb +11 -6
  65. data/lib/cocoapods/sandbox/headers_store.rb +9 -8
  66. data/lib/cocoapods/sandbox/path_list.rb +5 -8
  67. data/lib/cocoapods/sandbox.rb +31 -43
  68. data/lib/cocoapods/sources_manager.rb +1 -1
  69. data/lib/cocoapods/target/aggregate_target.rb +143 -85
  70. data/lib/cocoapods/target/build_settings.rb +1124 -0
  71. data/lib/cocoapods/target/framework_paths.rb +36 -0
  72. data/lib/cocoapods/target/pod_target.rb +198 -295
  73. data/lib/cocoapods/target.rb +92 -37
  74. data/lib/cocoapods/user_interface.rb +5 -0
  75. data/lib/cocoapods/validator.rb +149 -44
  76. data/lib/cocoapods.rb +0 -1
  77. metadata +31 -23
  78. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +0 -260
  79. data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +0 -87
  80. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +0 -558
  81. data/lib/cocoapods/generator/xcconfig.rb +0 -13
@@ -33,6 +33,8 @@ module Pod
33
33
  dependency_graph = Molinillo::DependencyGraph.new
34
34
 
35
35
  if lockfile
36
+ added_dependency_strings = Set.new
37
+
36
38
  explicit_dependencies = lockfile.dependencies
37
39
  explicit_dependencies.each do |dependency|
38
40
  dependency_graph.add_vertex(dependency.name, dependency, true)
@@ -40,7 +42,7 @@ module Pod
40
42
 
41
43
  pods = lockfile.to_hash['PODS'] || []
42
44
  pods.each do |pod|
43
- add_to_dependency_graph(pod, [], dependency_graph, pods_to_unlock)
45
+ add_to_dependency_graph(pod, [], dependency_graph, pods_to_unlock, added_dependency_strings)
44
46
  end
45
47
 
46
48
  pods_to_update = pods_to_update.flat_map do |u|
@@ -51,6 +53,11 @@ module Pod
51
53
  pods_to_update.each do |u|
52
54
  dependency_graph.detach_vertex_named(u)
53
55
  end
56
+
57
+ dependency_graph.each do |vertex|
58
+ next unless dep = vertex.payload
59
+ dep.podspec_repo ||= lockfile.spec_repo(dep.root_name)
60
+ end
54
61
  end
55
62
 
56
63
  dependency_graph
@@ -67,7 +74,8 @@ module Pod
67
74
 
68
75
  private
69
76
 
70
- def self.add_child_vertex_to_graph(dependency_string, parents, dependency_graph, pods_to_unlock)
77
+ def self.add_child_vertex_to_graph(dependency_string, parents, dependency_graph, pods_to_unlock, added_dependency_strings)
78
+ return unless added_dependency_strings.add?(dependency_string)
71
79
  dependency = Dependency.from_string(dependency_string)
72
80
  if pods_to_unlock.include?(dependency.root_name)
73
81
  dependency = Dependency.new(dependency.name)
@@ -78,14 +86,14 @@ module Pod
78
86
  dependency
79
87
  end
80
88
 
81
- def self.add_to_dependency_graph(object, parents, dependency_graph, pods_to_unlock)
89
+ def self.add_to_dependency_graph(object, parents, dependency_graph, pods_to_unlock, added_dependency_strings)
82
90
  case object
83
91
  when String
84
- add_child_vertex_to_graph(object, parents, dependency_graph, pods_to_unlock)
92
+ add_child_vertex_to_graph(object, parents, dependency_graph, pods_to_unlock, added_dependency_strings)
85
93
  when Hash
86
94
  object.each do |key, value|
87
- dependency = add_child_vertex_to_graph(key, parents, dependency_graph, pods_to_unlock)
88
- value.each { |v| add_to_dependency_graph(v, [dependency.name], dependency_graph, pods_to_unlock) }
95
+ dependency = add_child_vertex_to_graph(key, parents, dependency_graph, pods_to_unlock, added_dependency_strings)
96
+ value.each { |v| add_to_dependency_graph(v, [dependency.name], dependency_graph, pods_to_unlock, added_dependency_strings) }
89
97
  end
90
98
  end
91
99
  end
@@ -38,6 +38,7 @@ module Pod
38
38
  @test_specs = test_specs
39
39
  @platform = platform
40
40
  @requires_frameworks = requires_frameworks
41
+ @hash = [specs, platform, requires_frameworks].hash
41
42
  end
42
43
 
43
44
  # @note Test specs are intentionally not included as part of the equality for pod variants since a
@@ -48,9 +49,9 @@ module Pod
48
49
  #
49
50
  def ==(other)
50
51
  self.class == other.class &&
51
- specs == other.specs &&
52
+ requires_frameworks == other.requires_frameworks &&
52
53
  platform == other.platform &&
53
- requires_frameworks == other.requires_frameworks
54
+ specs == other.specs
54
55
  end
55
56
  alias_method :eql?, :==
56
57
 
@@ -59,9 +60,7 @@ module Pod
59
60
  # This adds support to make instances usable as Hash keys.
60
61
  #
61
62
  # @!visibility private
62
- def hash
63
- [specs, platform, requires_frameworks].hash
64
- end
63
+ attr_reader :hash
65
64
  end
66
65
  end
67
66
  end
@@ -42,27 +42,16 @@ module Pod
42
42
 
43
43
  alias_method :update_mode?, :update_mode
44
44
 
45
- # @return [Lockfile] The lockfile of the installation as a fall-back if
46
- # there is no sandbox manifest. This is indented as a temporary
47
- # solution to prevent the full re-installation from users which
48
- # are upgrading from CP < 0.17.
49
- #
50
- # @todo Remove for CP 0.18.
51
- #
52
- attr_reader :lockfile
53
-
54
45
  # Init a new SandboxAnalyzer
55
46
  #
56
47
  # @param [Sandbox] sandbox @see sandbox
57
48
  # @param [Array<Specifications>] specs @see specs
58
49
  # @param [Bool] update_mode @see update_mode
59
- # @param [Lockfile] lockfile @see lockfile
60
50
  #
61
- def initialize(sandbox, specs, update_mode, lockfile = nil)
51
+ def initialize(sandbox, specs, update_mode)
62
52
  @sandbox = sandbox
63
53
  @specs = specs
64
54
  @update_mode = update_mode
65
- @lockfile = lockfile
66
55
  end
67
56
 
68
57
  # Performs the analysis to the detect the state of the sandbox respect
@@ -114,7 +103,7 @@ module Pod
114
103
  #
115
104
  def pod_added?(pod)
116
105
  return true if resolved_pods.include?(pod) && !sandbox_pods.include?(pod)
117
- return true unless folder_exist?(pod)
106
+ return true if !folder_exist?(pod) && !sandbox.local?(pod)
118
107
  false
119
108
  end
120
109
 
@@ -164,7 +153,7 @@ module Pod
164
153
  # @return [Lockfile] The manifest to use for the sandbox.
165
154
  #
166
155
  def sandbox_manifest
167
- sandbox.manifest || lockfile
156
+ sandbox.manifest
168
157
  end
169
158
 
170
159
  #--------------------------------------#
@@ -59,10 +59,14 @@ module Pod
59
59
  # @return [void]
60
60
  #
61
61
  def print
62
- added .sort.each { |pod| UI.message('A'.green + " #{pod}", '', 2) }
63
- deleted .sort.each { |pod| UI.message('R'.red + " #{pod}", '', 2) }
64
- changed .sort.each { |pod| UI.message('M'.yellow + " #{pod}", '', 2) }
65
- unchanged.sort.each { |pod| UI.message('-' + " #{pod}", '', 2) }
62
+ states = %i(added deleted changed unchanged)
63
+ lines(states).each do |line|
64
+ UI.message(line, '', 2)
65
+ end
66
+ end
67
+
68
+ def to_s(states: %i(added deleted changed unchanged))
69
+ lines(states).join("\n")
66
70
  end
67
71
 
68
72
  # Adds the name of a Pod to the give state.
@@ -78,6 +82,26 @@ module Pod
78
82
  def add_name(name, state)
79
83
  send(state) << Specification.root_name(name)
80
84
  end
85
+
86
+ private
87
+
88
+ # @return [Array<String>] A description of changes for the given states,
89
+ # one per line
90
+ #
91
+ def lines(states)
92
+ prefixes = {
93
+ :added => 'A'.green,
94
+ :deleted => 'R'.red,
95
+ :changed => 'M'.yellow,
96
+ :unchanged => '-',
97
+ }
98
+
99
+ states.flat_map do |state|
100
+ send(state).sort.map do |pod|
101
+ prefixes[state.to_sym] + " #{pod}"
102
+ end
103
+ end
104
+ end
81
105
  end
82
106
  end
83
107
  end
@@ -5,40 +5,53 @@ module Pod
5
5
  # @return [TargetDefinition] the target definition, whose project was
6
6
  # inspected
7
7
  #
8
- attr_accessor :target_definition
8
+ attr_reader :target_definition
9
9
 
10
- # @return [Pathname] the path of the user project that the
11
- # #target_definition should integrate
10
+ # @return [Xcodeproj::Project] the user's Xcode project
12
11
  #
13
- attr_accessor :project_path
12
+ attr_reader :project
14
13
 
15
14
  # @return [Array<String>] the uuid of the user's targets
16
15
  #
17
- attr_accessor :project_target_uuids
16
+ attr_reader :project_target_uuids
18
17
 
19
18
  # @return [Hash{String=>Symbol}] A hash representing the user build
20
19
  # configurations where each key corresponds to the name of a
21
20
  # configuration and its value to its type (`:debug` or
22
21
  # `:release`).
23
22
  #
24
- attr_accessor :build_configurations
23
+ attr_reader :build_configurations
25
24
 
26
25
  # @return [Platform] the platform of the user targets
27
26
  #
28
- attr_accessor :platform
27
+ attr_reader :platform
29
28
 
30
29
  # @return [Array<String>] the architectures used by user's targets
31
30
  #
32
- attr_accessor :archs
31
+ attr_reader :archs
33
32
 
34
- # @return [Bool] whether frameworks are recommended for the integration
35
- # due to the presence of Swift source in the user's targets
33
+ # @return [Pathname] the path to the root of the project containing the user target
36
34
  #
37
- attr_accessor :recommends_frameworks
35
+ attr_reader :client_root
38
36
 
39
- # @return [Xcodeproj::Project] the user's Xcode project
40
- #
41
- attr_accessor :project
37
+ # Initialize a new instance
38
+ #
39
+ # @param [TargetDefinition] target_definition @see #target_definition
40
+ # @param [Xcodeproj::Project] project @see #project
41
+ # @param [Array<String>] project_target_uuids @see #project_target_uuids
42
+ # @param [Hash{String=>Symbol}] build_configurations @see #build_configurations
43
+ # @param [Platform] platform @see #platform
44
+ # @param [Array<String>] archs @see #archs
45
+ #
46
+ def initialize(target_definition, project, project_target_uuids, build_configurations, platform, archs)
47
+ @target_definition = target_definition
48
+ @project = project
49
+ @project_target_uuids = project_target_uuids
50
+ @build_configurations = build_configurations
51
+ @platform = platform
52
+ @archs = archs
53
+ @client_root = project.project_dir.realpath
54
+ end
42
55
  end
43
56
  end
44
57
  end
@@ -32,22 +32,21 @@ module Pod
32
32
  #
33
33
  # @raise If no `user_project` is set
34
34
  #
35
- # @return [TargetInspectionResult]
35
+ # @return [TargetInspectionResult] the result of the inspection of the target definition within the user project
36
36
  #
37
37
  def compute_results(user_project)
38
38
  raise ArgumentError, 'Cannot compute results without a user project set' unless user_project
39
39
 
40
40
  targets = compute_targets(user_project)
41
+ project_target_uuids = targets.map(&:uuid)
42
+ build_configurations = compute_build_configurations(targets)
43
+ platform = compute_platform(targets)
44
+ archs = compute_archs(targets)
45
+ swift_version = compute_swift_version_from_targets(targets)
41
46
 
42
- result = TargetInspectionResult.new
43
- result.target_definition = target_definition
44
- result.project_path = user_project.path
45
- result.project_target_uuids = targets.map(&:uuid)
46
- result.build_configurations = compute_build_configurations(targets)
47
- result.platform = compute_platform(targets)
48
- result.archs = compute_archs(targets)
49
- result.project = user_project
50
- result.target_definition.swift_version = compute_swift_version_from_targets(targets)
47
+ result = TargetInspectionResult.new(target_definition, user_project, project_target_uuids,
48
+ build_configurations, platform, archs)
49
+ result.target_definition.swift_version = swift_version
51
50
  result
52
51
  end
53
52
 
@@ -219,7 +218,14 @@ module Pod
219
218
  #
220
219
  def compute_swift_version_from_targets(targets)
221
220
  versions_to_targets = targets.inject({}) do |memo, target|
222
- versions = target.resolved_build_setting('SWIFT_VERSION').values
221
+ # User project may have an xcconfig that specifies the `SWIFT_VERSION`. We first check if that is true and
222
+ # that the xcconfig file actually exists. After the first integration the xcconfig set is most probably
223
+ # the one that was generated from CocoaPods. See https://github.com/CocoaPods/CocoaPods/issues/7731 for
224
+ # more details.
225
+ resolve_against_xcconfig = target.build_configuration_list.build_configurations.all? do |bc|
226
+ !bc.base_configuration_reference.nil? && File.exist?(bc.base_configuration_reference.real_path)
227
+ end
228
+ versions = target.resolved_build_setting('SWIFT_VERSION', resolve_against_xcconfig).values
223
229
  versions.each do |version|
224
230
  memo[version] = [] if memo[version].nil?
225
231
  memo[version] << target.name unless memo[version].include? target.name