cocoapods 0.33.1 → 0.34.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +171 -46
  3. data/README.md +9 -9
  4. data/bin/pod +5 -5
  5. data/bin/sandbox-pod +2 -6
  6. data/lib/cocoapods.rb +4 -4
  7. data/lib/cocoapods/command.rb +12 -10
  8. data/lib/cocoapods/command/init.rb +12 -13
  9. data/lib/cocoapods/command/inter_process_communication.rb +6 -17
  10. data/lib/cocoapods/command/lib.rb +27 -24
  11. data/lib/cocoapods/command/list.rb +9 -9
  12. data/lib/cocoapods/command/outdated.rb +4 -9
  13. data/lib/cocoapods/command/project.rb +57 -19
  14. data/lib/cocoapods/command/push.rb +0 -1
  15. data/lib/cocoapods/command/repo.rb +14 -15
  16. data/lib/cocoapods/command/repo/push.rb +24 -19
  17. data/lib/cocoapods/command/search.rb +12 -13
  18. data/lib/cocoapods/command/setup.rb +10 -9
  19. data/lib/cocoapods/command/spec.rb +67 -63
  20. data/lib/cocoapods/config.rb +21 -54
  21. data/lib/cocoapods/downloader.rb +0 -1
  22. data/lib/cocoapods/executable.rb +3 -8
  23. data/lib/cocoapods/external_sources.rb +2 -4
  24. data/lib/cocoapods/external_sources/abstract_external_source.rb +15 -10
  25. data/lib/cocoapods/external_sources/downloader_source.rb +0 -2
  26. data/lib/cocoapods/external_sources/path_source.rb +1 -4
  27. data/lib/cocoapods/external_sources/podspec_source.rb +1 -3
  28. data/lib/cocoapods/gem_version.rb +1 -2
  29. data/lib/cocoapods/generator/acknowledgements.rb +5 -8
  30. data/lib/cocoapods/generator/acknowledgements/markdown.rb +5 -7
  31. data/lib/cocoapods/generator/acknowledgements/plist.rb +9 -10
  32. data/lib/cocoapods/generator/bridge_support.rb +1 -1
  33. data/lib/cocoapods/generator/copy_resources_script.rb +10 -14
  34. data/lib/cocoapods/generator/dummy_source.rb +3 -3
  35. data/lib/cocoapods/generator/prefix_header.rb +15 -16
  36. data/lib/cocoapods/generator/target_environment_header.rb +122 -36
  37. data/lib/cocoapods/generator/xcconfig.rb +0 -4
  38. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +74 -65
  39. data/lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb +92 -95
  40. data/lib/cocoapods/generator/xcconfig/public_pod_xcconfig.rb +48 -51
  41. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +10 -10
  42. data/lib/cocoapods/hooks/installer_representation.rb +15 -18
  43. data/lib/cocoapods/hooks/library_representation.rb +4 -8
  44. data/lib/cocoapods/hooks/pod_representation.rb +1 -5
  45. data/lib/cocoapods/hooks_manager.rb +63 -0
  46. data/lib/cocoapods/installer.rb +60 -47
  47. data/lib/cocoapods/installer/analyzer.rb +60 -62
  48. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +5 -8
  49. data/lib/cocoapods/installer/file_references_installer.rb +7 -10
  50. data/lib/cocoapods/installer/hooks_context.rb +74 -0
  51. data/lib/cocoapods/installer/migrator.rb +99 -0
  52. data/lib/cocoapods/installer/pod_source_installer.rb +9 -29
  53. data/lib/cocoapods/installer/target_installer.rb +7 -17
  54. data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +40 -41
  55. data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +43 -54
  56. data/lib/cocoapods/installer/user_project_integrator.rb +54 -10
  57. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +66 -117
  58. data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +116 -0
  59. data/lib/cocoapods/open_uri.rb +1 -2
  60. data/lib/cocoapods/project.rb +34 -8
  61. data/lib/cocoapods/resolver.rb +43 -21
  62. data/lib/cocoapods/sandbox.rb +80 -75
  63. data/lib/cocoapods/sandbox/file_accessor.rb +3 -8
  64. data/lib/cocoapods/sandbox/headers_store.rb +6 -7
  65. data/lib/cocoapods/sandbox/path_list.rb +7 -10
  66. data/lib/cocoapods/sources_manager.rb +81 -49
  67. data/lib/cocoapods/target.rb +18 -12
  68. data/lib/cocoapods/target/aggregate_target.rb +43 -18
  69. data/lib/cocoapods/target/pod_target.rb +37 -4
  70. data/lib/cocoapods/user_interface.rb +19 -18
  71. data/lib/cocoapods/user_interface/error_report.rb +23 -4
  72. data/lib/cocoapods/validator.rb +30 -33
  73. metadata +100 -73
  74. data/lib/cocoapods/command/help.rb +0 -25
@@ -1,11 +1,9 @@
1
1
  module Pod
2
2
  class Installer
3
-
4
3
  # Creates the targets which aggregate the Pods libraries in the Pods
5
4
  # project and the relative support files.
6
5
  #
7
6
  class AggregateTargetInstaller < TargetInstaller
8
-
9
7
  # Creates the target in the Pods project and the relative support files.
10
8
  #
11
9
  # @return [void]
@@ -13,6 +11,7 @@ module Pod
13
11
  def install!
14
12
  UI.message "- Installing target `#{library.name}` #{library.platform}" do
15
13
  add_target
14
+ create_support_files_dir
16
15
  create_suport_files_group
17
16
  create_xcconfig_file
18
17
  create_target_environment_header
@@ -27,21 +26,30 @@ module Pod
27
26
 
28
27
  private
29
28
 
29
+ # Creates the group that holds the references to the support files
30
+ # generated by this installer.
31
+ #
32
+ # @return [void]
33
+ #
34
+ def create_suport_files_group
35
+ parent = project.support_files_group
36
+ name = library.name
37
+ dir = library.support_files_dir
38
+ @support_files_group = parent.new_group(name, dir)
39
+ end
40
+
30
41
  # Generates the contents of the xcconfig file and saves it to disk.
31
42
  #
32
43
  # @return [void]
33
44
  #
34
45
  def create_xcconfig_file
35
- path = library.xcconfig_path
36
- UI.message "- Generating xcconfig file at #{UI.path(path)}" do
37
- gen = Generator::XCConfig::AggregateXCConfig.new(library)
46
+ target.build_configurations.each do |configuration|
47
+ path = library.xcconfig_path(configuration.name)
48
+ gen = Generator::XCConfig::AggregateXCConfig.new(library, configuration.name)
38
49
  gen.save_as(path)
39
- library.xcconfig = gen.xcconfig
50
+ library.xcconfigs[configuration.name] = gen.xcconfig
40
51
  xcconfig_file_ref = add_file_to_support_group(path)
41
-
42
- target.build_configurations.each do |c|
43
- c.base_configuration_reference = xcconfig_file_ref
44
- end
52
+ configuration.base_configuration_reference = xcconfig_file_ref
45
53
  end
46
54
  end
47
55
 
@@ -50,11 +58,9 @@ module Pod
50
58
  #
51
59
  def create_target_environment_header
52
60
  path = library.target_environment_header_path
53
- UI.message "- Generating target environment header at #{UI.path(path)}" do
54
- generator = Generator::TargetEnvironmentHeader.new(library.pod_targets.map { |l| l.specs }.flatten)
55
- generator.save_as(path)
56
- add_file_to_support_group(path)
57
- end
61
+ generator = Generator::TargetEnvironmentHeader.new(library.specs_by_build_configuration)
62
+ generator.save_as(path)
63
+ add_file_to_support_group(path)
58
64
  end
59
65
 
60
66
  # Generates the bridge support metadata if requested by the {Podfile}.
@@ -68,13 +74,11 @@ module Pod
68
74
  def create_bridge_support_file
69
75
  if target_definition.podfile.generate_bridge_support?
70
76
  path = library.bridge_support_path
71
- UI.message "- Generating BridgeSupport metadata at #{UI.path(path)}" do
72
- headers = target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
73
- generator = Generator::BridgeSupport.new(headers)
74
- generator.save_as(path)
75
- add_file_to_support_group(path)
76
- @bridge_support_file = path.relative_path_from(sandbox.root)
77
- end
77
+ headers = target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
78
+ generator = Generator::BridgeSupport.new(headers)
79
+ generator.save_as(path)
80
+ add_file_to_support_group(path)
81
+ @bridge_support_file = path.relative_path_from(sandbox.root)
78
82
  end
79
83
  end
80
84
 
@@ -88,18 +92,16 @@ module Pod
88
92
  #
89
93
  def create_copy_resources_script
90
94
  path = library.copy_resources_script_path
91
- UI.message "- Generating copy resources script at #{UI.path(path)}" do
92
- file_accessors = library.pod_targets.map(&:file_accessors).flatten
93
- resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) }}.flatten
94
- resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
95
- resources = []
96
- resources.concat(resource_paths)
97
- resources.concat(resource_bundles)
98
- resources << bridge_support_file if bridge_support_file
99
- generator = Generator::CopyResourcesScript.new(resources, library.platform)
100
- generator.save_as(path)
101
- add_file_to_support_group(path)
102
- end
95
+ file_accessors = library.pod_targets.map(&:file_accessors).flatten
96
+ resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten
97
+ resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
98
+ resources = []
99
+ resources.concat(resource_paths)
100
+ resources.concat(resource_bundles)
101
+ resources << bridge_support_file if bridge_support_file
102
+ generator = Generator::CopyResourcesScript.new(resources, library.platform)
103
+ generator.save_as(path)
104
+ add_file_to_support_group(path)
103
105
  end
104
106
 
105
107
  # Generates the acknowledgement files (markdown and plist) for the target.
@@ -110,12 +112,10 @@ module Pod
110
112
  basepath = library.acknowledgements_basepath
111
113
  Generator::Acknowledgements.generators.each do |generator_class|
112
114
  path = generator_class.path_from_basepath(basepath)
113
- UI.message "- Generating acknowledgements at #{UI.path(path)}" do
114
- file_accessors = library.pod_targets.map(&:file_accessors).flatten
115
- generator = generator_class.new(file_accessors)
116
- generator.save_as(path)
117
- add_file_to_support_group(path)
118
- end
115
+ file_accessors = library.pod_targets.map(&:file_accessors).flatten
116
+ generator = generator_class.new(file_accessors)
117
+ generator.save_as(path)
118
+ add_file_to_support_group(path)
119
119
  end
120
120
  end
121
121
 
@@ -127,7 +127,6 @@ module Pod
127
127
  attr_reader :bridge_support_file
128
128
 
129
129
  #-----------------------------------------------------------------------#
130
-
131
130
  end
132
131
  end
133
132
  end
@@ -1,11 +1,9 @@
1
1
  module Pod
2
2
  class Installer
3
-
4
3
  # Creates the target for the Pods libraries in the Pods project and the
5
4
  # relative support files.
6
5
  #
7
6
  class PodTargetInstaller < TargetInstaller
8
-
9
7
  # Creates the target in the Pods project and the relative support files.
10
8
  #
11
9
  # @return [void]
@@ -13,6 +11,7 @@ module Pod
13
11
  def install!
14
12
  UI.message "- Installing target `#{library.name}` #{library.platform}" do
15
13
  add_target
14
+ create_support_files_dir
16
15
  add_files_to_build_phases
17
16
  add_resources_bundle_targets
18
17
  create_xcconfig_file
@@ -34,17 +33,15 @@ module Pod
34
33
  # @return [void]
35
34
  #
36
35
  def add_files_to_build_phases
37
- UI.message "- Adding Build files" do
38
- library.file_accessors.each do |file_accessor|
39
- consumer = file_accessor.spec_consumer
40
- flags = compiler_flags_for_consumer(consumer)
41
- all_source_files = file_accessor.source_files
42
- regular_source_files = all_source_files.reject { |sf| sf.extname == ".d" }
43
- regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) }
44
- target.add_file_references(regular_file_refs, flags)
45
- other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) }
46
- target.add_file_references(other_file_refs, nil)
47
- end
36
+ library.file_accessors.each do |file_accessor|
37
+ consumer = file_accessor.spec_consumer
38
+ flags = compiler_flags_for_consumer(consumer)
39
+ all_source_files = file_accessor.source_files
40
+ regular_source_files = all_source_files.reject { |sf| sf.extname == '.d' }
41
+ regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) }
42
+ target.add_file_references(regular_file_refs, flags)
43
+ other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) }
44
+ target.add_file_references(other_file_refs, nil)
48
45
  end
49
46
  end
50
47
 
@@ -56,24 +53,22 @@ module Pod
56
53
  # @return [void]
57
54
  #
58
55
  def add_resources_bundle_targets
59
- UI.message "- Adding resource bundles to Pods project" do
60
- library.file_accessors.each do |file_accessor|
61
- file_accessor.resource_bundles.each do |bundle_name, paths|
62
- # Add a dependency on an existing Resource Bundle target if possible
63
- if bundle_target = project.targets.detect { |target| target.name == bundle_name }
64
- target.add_dependency(bundle_target)
65
- next
66
- end
67
- file_references = paths.map { |sf| project.reference_for_path(sf) }
68
- bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
69
- bundle_target.add_resources(file_references)
70
-
71
- library.user_build_configurations.each do |bc_name, type|
72
- bundle_target.add_build_configuration(bc_name, type)
73
- end
74
-
56
+ library.file_accessors.each do |file_accessor|
57
+ file_accessor.resource_bundles.each do |bundle_name, paths|
58
+ # Add a dependency on an existing Resource Bundle target if possible
59
+ if bundle_target = project.targets.find { |target| target.name == bundle_name }
75
60
  target.add_dependency(bundle_target)
61
+ next
62
+ end
63
+ file_references = paths.map { |sf| project.reference_for_path(sf) }
64
+ bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
65
+ bundle_target.add_resources(file_references)
66
+
67
+ library.user_build_configurations.each do |bc_name, type|
68
+ bundle_target.add_build_configuration(bc_name, type)
76
69
  end
70
+
71
+ target.add_dependency(bundle_target)
77
72
  end
78
73
  end
79
74
  end
@@ -85,20 +80,16 @@ module Pod
85
80
  def create_xcconfig_file
86
81
  path = library.xcconfig_path
87
82
  public_gen = Generator::XCConfig::PublicPodXCConfig.new(library)
88
- UI.message "- Generating public xcconfig file at #{UI.path(path)}" do
89
- public_gen.save_as(path)
90
- add_file_to_support_group(path)
91
- end
83
+ public_gen.save_as(path)
84
+ add_file_to_support_group(path)
92
85
 
93
86
  path = library.xcconfig_private_path
94
87
  private_gen = Generator::XCConfig::PrivatePodXCConfig.new(library, public_gen.xcconfig)
95
- UI.message "- Generating private xcconfig file at #{UI.path(path)}" do
96
- private_gen.save_as(path)
97
- xcconfig_file_ref = add_file_to_support_group(path)
88
+ private_gen.save_as(path)
89
+ xcconfig_file_ref = add_file_to_support_group(path)
98
90
 
99
- target.build_configurations.each do |c|
100
- c.base_configuration_reference = xcconfig_file_ref
101
- end
91
+ target.build_configurations.each do |c|
92
+ c.base_configuration_reference = xcconfig_file_ref
102
93
  end
103
94
  end
104
95
 
@@ -110,22 +101,20 @@ module Pod
110
101
  #
111
102
  def create_prefix_header
112
103
  path = library.prefix_header_path
113
- UI.message "- Generating prefix header at #{UI.path(path)}" do
114
- generator = Generator::PrefixHeader.new(library.file_accessors, library.platform)
115
- generator.imports << library.target_environment_header_path.basename
116
- generator.save_as(path)
117
- add_file_to_support_group(path)
118
-
119
- target.build_configurations.each do |c|
120
- relative_path = path.relative_path_from(sandbox.root)
121
- c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
122
- end
104
+ generator = Generator::PrefixHeader.new(library.file_accessors, library.platform)
105
+ generator.imports << library.target_environment_header_path.basename
106
+ generator.save_as(path)
107
+ add_file_to_support_group(path)
108
+
109
+ target.build_configurations.each do |c|
110
+ relative_path = path.relative_path_from(project.path.dirname)
111
+ c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
123
112
  end
124
113
  end
125
114
 
126
115
  ENABLE_OBJECT_USE_OBJC_FROM = {
127
116
  :ios => Version.new('6'),
128
- :osx => Version.new('10.8')
117
+ :osx => Version.new('10.8'),
129
118
  }
130
119
 
131
120
  # Returns the compiler flags for the source files of the given specification.
@@ -174,9 +163,9 @@ module Pod
174
163
  end
175
164
  end
176
165
  if target_definition.inhibits_warnings_for_pod?(consumer.spec.root.name)
177
- flags << '-w -Xanalyzer -analyzer-disable-checker'
166
+ flags << '-w -Xanalyzer -analyzer-disable-checker -Xanalyzer deadcode'
178
167
  end
179
- flags * " "
168
+ flags * ' '
180
169
  end
181
170
 
182
171
  # Adds a reference to the given file in the support group of this target.
@@ -188,12 +177,12 @@ module Pod
188
177
  #
189
178
  def add_file_to_support_group(path)
190
179
  pod_name = library.pod_name
191
- group = project.pod_support_files_group(pod_name)
180
+ dir = library.support_files_dir
181
+ group = project.pod_support_files_group(pod_name, dir)
192
182
  group.new_file(path)
193
183
  end
194
184
 
195
185
  #-----------------------------------------------------------------------#
196
-
197
186
  end
198
187
  end
199
188
  end
@@ -6,13 +6,11 @@ require 'active_support/core_ext/array/conversions'
6
6
 
7
7
  module Pod
8
8
  class Installer
9
-
10
9
  # The {UserProjectIntegrator} integrates the libraries generated by
11
10
  # TargetDefinitions of the {Podfile} with their correspondent user
12
11
  # projects.
13
12
  #
14
13
  class UserProjectIntegrator
15
-
16
14
  autoload :TargetIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator'
17
15
 
18
16
  # @return [Podfile] the podfile that should be integrated with the user
@@ -62,6 +60,7 @@ module Pod
62
60
  create_workspace
63
61
  integrate_user_targets
64
62
  warn_about_empty_podfile
63
+ warn_about_xcconfig_overrides
65
64
  end
66
65
 
67
66
  #-----------------------------------------------------------------------#
@@ -128,8 +127,30 @@ module Pod
128
127
  # @return [void]
129
128
  #
130
129
  def warn_about_empty_podfile
131
- if podfile.target_definitions.values.all?{ |td| td.empty? }
132
- UI.warn "[!] The Podfile does not contain any dependencies."
130
+ if podfile.target_definitions.values.all?(&:empty?)
131
+ UI.warn '[!] The Podfile does not contain any dependencies.'
132
+ end
133
+ end
134
+
135
+ # Checks whether the settings of the CocoaPods generated xcconfig are
136
+ # overridden by the build configuration of a target and prints a
137
+ # warning to inform the user if needed.
138
+ #
139
+ def warn_about_xcconfig_overrides
140
+ targets.each do |aggregate_target|
141
+ aggregate_target.user_targets.each do |user_target|
142
+ user_target.build_configurations.each do |config|
143
+ xcconfig = aggregate_target.xcconfigs[config.name]
144
+ if xcconfig
145
+ xcconfig.to_hash.keys.each do |key|
146
+ target_value = config.build_settings[key]
147
+ if target_value && !target_value.include?('$(inherited)')
148
+ print_override_warning(aggregate_target, user_target, config, key)
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
133
154
  end
134
155
  end
135
156
 
@@ -152,7 +173,7 @@ module Pod
152
173
  project = user_project_paths.first.basename('.xcodeproj')
153
174
  installation_root + "#{project}.xcworkspace"
154
175
  else
155
- raise Informative, "Could not automatically select an Xcode " \
176
+ raise Informative, 'Could not automatically select an Xcode ' \
156
177
  "workspace. Specify one in your Podfile like so:\n\n" \
157
178
  " workspace 'path/to/Workspace.xcworkspace'\n"
158
179
  end
@@ -164,18 +185,41 @@ module Pod
164
185
  # @note Empty target definitions are ignored.
165
186
  #
166
187
  def user_project_paths
167
- targets.map do |target|
168
- target.user_project_path
169
- end.compact.uniq
188
+ targets.map(&:user_project_path).compact.uniq
170
189
  end
171
190
 
172
-
173
191
  def targets_to_integrate
174
192
  targets.reject { |target| target.target_definition.empty? }
175
193
  end
176
194
 
177
- #-----------------------------------------------------------------------#
195
+ # Prints a warning informing the user that a build configuration of
196
+ # the integrated target is overriding the CocoaPods build settings.
197
+ #
198
+ # @param [Target::AggregateTarget] aggregate_target
199
+ # The umbrella target.
200
+ #
201
+ # @param [XcodeProj::PBXNativeTarget] user_target
202
+ # The native target.
203
+ #
204
+ # @param [Xcodeproj::XCBuildConfiguration] config
205
+ # The build configuration.
206
+ #
207
+ # @param [String] key
208
+ # The key of the overridden build setting.
209
+ #
210
+ def print_override_warning(aggregate_target, user_target, config, key)
211
+ actions = [
212
+ 'Use the `$(inherited)` flag, or',
213
+ 'Remove the build settings from the target.',
214
+ ]
215
+ message = "The `#{user_target.name} [#{config.name}]` " \
216
+ "target overrides the `#{key}` build setting defined in " \
217
+ "`#{aggregate_target.xcconfig_relative_path(config.name)}'. " \
218
+ 'This can lead to problems with the CocoaPods installation'
219
+ UI.warn(message, actions)
220
+ end
178
221
 
222
+ #-----------------------------------------------------------------------#
179
223
  end
180
224
  end
181
225
  end
@@ -3,11 +3,11 @@ require 'active_support/core_ext/string/inflections'
3
3
  module Pod
4
4
  class Installer
5
5
  class UserProjectIntegrator
6
-
7
6
  # This class is responsible for integrating the library generated by a
8
7
  # {TargetDefinition} with its destination project.
9
8
  #
10
9
  class TargetIntegrator
10
+ autoload :XCConfigIntegrator, 'cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator'
11
11
 
12
12
  # @return [Target] the target that should be integrated.
13
13
  #
@@ -26,54 +26,17 @@ module Pod
26
26
  # @return [void]
27
27
  #
28
28
  def integrate!
29
- return if native_targets.empty?
30
29
  UI.section(integration_message) do
31
- add_xcconfig_base_configuration
32
- add_pods_library
33
- add_copy_resources_script_phase
34
- add_check_manifest_lock_script_phase
35
- user_project.save
36
- end
37
- end
30
+ XCConfigIntegrator.integrate(target, native_targets)
31
+ update_to_cocoapods_0_34
38
32
 
39
- # @return [Array<PBXNativeTarget>] the user targets for integration.
40
- #
41
- def native_targets
42
- unless @native_targets
43
- target_uuids = target.user_target_uuids
44
- native_targets = target_uuids.map do |uuid|
45
- native_target = user_project.objects_by_uuid[uuid]
46
- unless native_target
47
- raise Informative, "[Bug] Unable to find the target with " \
48
- "the `#{uuid}` UUID for the `#{target}` integration library"
49
- end
50
- native_target
33
+ unless native_targets_to_integrate.empty?
34
+ add_pods_library
35
+ add_copy_resources_script_phase
36
+ add_check_manifest_lock_script_phase
51
37
  end
52
- non_integrated = native_targets.reject do |native_target|
53
- native_target.frameworks_build_phase.files.any? do |build_file|
54
- file_ref = build_file.file_ref
55
- file_ref &&
56
- file_ref.isa == 'PBXFileReference' &&
57
- file_ref.display_name == target.product_name
58
- end
59
- end
60
- @native_targets = non_integrated
38
+ user_project.save
61
39
  end
62
- @native_targets
63
- end
64
-
65
- # Read the project from the disk to ensure that it is up to date as
66
- # other TargetIntegrators might have modified it.
67
- #
68
- def user_project
69
- @user_project ||= Xcodeproj::Project.open(target.user_project_path)
70
- end
71
-
72
- # Read the pods project from the disk to ensure that it is up to date as
73
- # other TargetIntegrators might have modified it.
74
- #
75
- def pods_project
76
- @pods_project ||= Xcodeproj::Project.open(target.sandbox.project_path)
77
40
  end
78
41
 
79
42
  # @return [String] a string representation suitable for debugging.
@@ -82,39 +45,25 @@ module Pod
82
45
  "#<#{self.class} for target `#{target.label}'>"
83
46
  end
84
47
 
85
- #---------------------------------------------------------------------#
86
-
87
- # @!group Integration steps
88
-
89
48
  private
90
49
 
91
- # @return [Specification::Consumer] the consumer for the specifications.
92
- #
93
- def spec_consumers
94
- @spec_consumers ||= target.pod_targets.map(&:file_accessors).flatten.map(&:spec_consumer)
95
- end
50
+ # @!group Integration steps
51
+ #---------------------------------------------------------------------#
96
52
 
97
- # Adds the `xcconfig` configurations files generated for the current
98
- # {TargetDefinition} to the build configurations of the targets that
99
- # should be integrated.
100
- #
101
- # @note It also checks if any build setting of the build
102
- # configurations overrides the `xcconfig` file and warns the
103
- # user.
53
+ # Fixes the paths of the copy resource scripts.
104
54
  #
105
- # @todo If the xcconfig is already set don't override it and inform
106
- # the user.
55
+ # @todo This can be removed for CocoaPods 1.0
107
56
  #
108
- # @return [void]
109
- #
110
- def add_xcconfig_base_configuration
111
- xcconfig = user_project.files.select { |f| f.path == target.xcconfig_relative_path }.first ||
112
- user_project.new_file(target.xcconfig_relative_path)
113
- native_targets.each do |native_target|
114
- check_overridden_build_settings(target.xcconfig, native_target)
115
- native_target.build_configurations.each do |config|
116
- config.base_configuration_reference = xcconfig
57
+ def update_to_cocoapods_0_34
58
+ phases = native_targets.map do |target|
59
+ target.shell_script_build_phases.select do |bp|
60
+ bp.name == 'Copy Pods Resources'
117
61
  end
62
+ end.flatten
63
+
64
+ script_path = target.copy_resources_script_relative_path
65
+ phases.each do |phase|
66
+ phase.shell_script = %("#{script_path}"\n)
118
67
  end
119
68
  end
120
69
 
@@ -127,11 +76,11 @@ module Pod
127
76
  #
128
77
  def add_pods_library
129
78
  frameworks = user_project.frameworks_group
130
- native_targets.each do |native_target|
79
+ native_targets_to_integrate.each do |native_target|
131
80
  library = frameworks.files.select { |f| f.path == target.product_name }.first ||
132
81
  frameworks.new_product_ref_for_target(target.name, :static_library)
133
82
  unless native_target.frameworks_build_phase.files_references.include?(library)
134
- native_target.frameworks_build_phase.add_file_reference(library)
83
+ native_target.frameworks_build_phase.add_file_reference(library)
135
84
  end
136
85
  end
137
86
  end
@@ -143,12 +92,12 @@ module Pod
143
92
  # @return [void]
144
93
  #
145
94
  def add_copy_resources_script_phase
146
- phase_name = "Copy Pods Resources"
147
- native_targets.each do |native_target|
148
- phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||
149
- native_target.new_shell_script_build_phase(phase_name)
150
- path = target.copy_resources_script_relative_path
151
- phase.shell_script = %{"#{path}"\n}
95
+ phase_name = 'Copy Pods Resources'
96
+ native_targets_to_integrate.each do |native_target|
97
+ phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first
98
+ phase ||= native_target.new_shell_script_build_phase(phase_name)
99
+ script_path = target.copy_resources_script_relative_path
100
+ phase.shell_script = %("#{script_path}"\n)
152
101
  phase.show_env_vars_in_log = '0'
153
102
  end
154
103
  end
@@ -164,7 +113,7 @@ module Pod
164
113
  #
165
114
  def add_check_manifest_lock_script_phase
166
115
  phase_name = 'Check Pods Manifest.lock'
167
- native_targets.each do |native_target|
116
+ native_targets_to_integrate.each do |native_target|
168
117
  next if native_target.shell_script_build_phases.any? { |phase| phase.name == phase_name }
169
118
  phase = native_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
170
119
  native_target.build_phases.unshift(phase)
@@ -182,56 +131,56 @@ module Pod
182
131
  end
183
132
  end
184
133
 
185
- #---------------------------------------------------------------------#
186
-
187
- # @!group Private helpers.
188
-
189
134
  private
190
135
 
191
- # Informs the user about any build setting of the target which might
192
- # override the given xcconfig file.
193
- #
194
- # @return [void]
195
- #
196
- def check_overridden_build_settings(xcconfig, native_target)
197
- return unless xcconfig
136
+ # @!group Private helpers
137
+ #---------------------------------------------------------------------#
198
138
 
199
- configs_by_overridden_key = {}
200
- native_target.build_configurations.each do |config|
201
- xcconfig.attributes.keys.each do |key|
202
- target_value = config.build_settings[key]
139
+ # @return [Array<PBXNativeTarget>] The list of all the targets that
140
+ # match the given target.
141
+ #
142
+ def native_targets
143
+ @native_targets ||= target.user_targets(user_project)
144
+ end
203
145
 
204
- if target_value && !target_value.include?('$(inherited)')
205
- configs_by_overridden_key[key] ||= []
206
- configs_by_overridden_key[key] << config.name
146
+ # @return [Array<PBXNativeTarget>] The list of the targets
147
+ # that have not been integrated by past installations
148
+ # of
149
+ #
150
+ def native_targets_to_integrate
151
+ unless @native_targets_to_integrate
152
+ @native_targets_to_integrate = native_targets.reject do |native_target|
153
+ native_target.frameworks_build_phase.files.any? do |build_file|
154
+ file_ref = build_file.file_ref
155
+ file_ref &&
156
+ file_ref.isa == 'PBXFileReference' &&
157
+ file_ref.display_name == target.product_name
207
158
  end
208
159
  end
209
-
210
- configs_by_overridden_key.each do |key, config_names|
211
- name = "#{native_target.name} [#{config_names.join(' - ')}]"
212
- actions = [
213
- "Use the `$(inherited)` flag, or",
214
- "Remove the build settings from the target."
215
- ]
216
- UI.warn("The target `#{name}` overrides the `#{key}` build " \
217
- "setting defined in `#{target.xcconfig_relative_path}'.",
218
- actions)
219
- end
220
160
  end
161
+ @native_targets_to_integrate
162
+ end
163
+
164
+ # Read the project from the disk to ensure that it is up to date as
165
+ # other TargetIntegrators might have modified it.
166
+ #
167
+ def user_project
168
+ @user_project ||= Xcodeproj::Project.open(target.user_project_path)
169
+ end
170
+
171
+ # @return [Specification::Consumer] the consumer for the specifications.
172
+ #
173
+ def spec_consumers
174
+ @spec_consumers ||= target.pod_targets.map(&:file_accessors).flatten.map(&:spec_consumer)
221
175
  end
222
176
 
223
177
  # @return [String] the message that should be displayed for the target
224
178
  # integration.
225
179
  #
226
180
  def integration_message
227
- "Integrating Pod #{'target'.pluralize(target.pod_targets.size)} " \
228
- "`#{target.pod_targets.map(&:name).to_sentence}` " \
229
- "into aggregate target #{target.name} " \
230
- "of project #{UI.path target.user_project_path}."
181
+ "Integrating target `#{target.name}` " \
182
+ "(#{UI.path target.user_project_path} project)"
231
183
  end
232
-
233
- #---------------------------------------------------------------------#
234
-
235
184
  end
236
185
  end
237
186
  end