cocoapods 1.6.2 → 1.7.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +101 -7
  3. data/README.md +9 -9
  4. data/lib/cocoapods.rb +2 -0
  5. data/lib/cocoapods/command.rb +1 -1
  6. data/lib/cocoapods/command/init.rb +2 -12
  7. data/lib/cocoapods/command/install.rb +3 -0
  8. data/lib/cocoapods/command/lib/create.rb +1 -1
  9. data/lib/cocoapods/command/lib/lint.rb +5 -1
  10. data/lib/cocoapods/command/list.rb +3 -5
  11. data/lib/cocoapods/command/repo.rb +1 -0
  12. data/lib/cocoapods/command/repo/add.rb +4 -5
  13. data/lib/cocoapods/command/repo/add_cdn.rb +58 -0
  14. data/lib/cocoapods/command/repo/list.rb +5 -6
  15. data/lib/cocoapods/command/repo/push.rb +6 -5
  16. data/lib/cocoapods/command/spec/create.rb +12 -12
  17. data/lib/cocoapods/command/spec/lint.rb +1 -1
  18. data/lib/cocoapods/command/update.rb +3 -0
  19. data/lib/cocoapods/config.rb +1 -0
  20. data/lib/cocoapods/executable.rb +32 -7
  21. data/lib/cocoapods/gem_version.rb +1 -1
  22. data/lib/cocoapods/generator/app_target_helper.rb +1 -1
  23. data/lib/cocoapods/generator/embed_frameworks_script.rb +13 -0
  24. data/lib/cocoapods/generator/file_list.rb +39 -0
  25. data/lib/cocoapods/generator/module_map.rb +1 -1
  26. data/lib/cocoapods/installer.rb +188 -46
  27. data/lib/cocoapods/installer/analyzer.rb +64 -39
  28. data/lib/cocoapods/installer/analyzer/pod_variant.rb +14 -9
  29. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +11 -2
  30. data/lib/cocoapods/installer/installation_options.rb +70 -44
  31. data/lib/cocoapods/installer/pod_source_installer.rb +9 -4
  32. data/lib/cocoapods/installer/podfile_validator.rb +9 -0
  33. data/lib/cocoapods/installer/post_install_hooks_context.rb +5 -2
  34. data/lib/cocoapods/installer/project_cache/project_cache.rb +11 -0
  35. data/lib/cocoapods/installer/project_cache/project_cache_analysis_result.rb +53 -0
  36. data/lib/cocoapods/installer/project_cache/project_cache_analyzer.rb +156 -0
  37. data/lib/cocoapods/installer/project_cache/project_cache_version.rb +43 -0
  38. data/lib/cocoapods/installer/project_cache/project_installation_cache.rb +77 -0
  39. data/lib/cocoapods/installer/project_cache/project_metadata_cache.rb +63 -0
  40. data/lib/cocoapods/installer/project_cache/target_cache_key.rb +134 -0
  41. data/lib/cocoapods/installer/project_cache/target_metadata.rb +70 -0
  42. data/lib/cocoapods/installer/sandbox_dir_cleaner.rb +89 -0
  43. data/lib/cocoapods/installer/sandbox_header_paths_installer.rb +45 -0
  44. data/lib/cocoapods/installer/target_uuid_generator.rb +32 -0
  45. data/lib/cocoapods/installer/user_project_integrator.rb +8 -6
  46. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +128 -63
  47. data/lib/cocoapods/installer/xcode.rb +3 -0
  48. data/lib/cocoapods/installer/xcode/multi_pods_project_generator.rb +72 -0
  49. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +102 -218
  50. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +75 -0
  51. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +1 -1
  52. data/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +29 -17
  53. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +31 -65
  54. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +155 -0
  55. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +265 -110
  56. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb +70 -43
  57. data/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb +75 -0
  58. data/lib/cocoapods/installer/xcode/pods_project_generator/project_generator.rb +119 -0
  59. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb +44 -7
  60. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +5 -7
  61. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +32 -0
  62. data/lib/cocoapods/installer/xcode/pods_project_generator_result.rb +35 -0
  63. data/lib/cocoapods/installer/xcode/single_pods_project_generator.rb +38 -0
  64. data/lib/cocoapods/installer/xcode/target_validator.rb +32 -25
  65. data/lib/cocoapods/native_target_extension.rb +54 -0
  66. data/lib/cocoapods/open-uri.rb +1 -1
  67. data/lib/cocoapods/podfile.rb +13 -0
  68. data/lib/cocoapods/project.rb +88 -10
  69. data/lib/cocoapods/resolver.rb +11 -8
  70. data/lib/cocoapods/resolver/resolver_specification.rb +7 -7
  71. data/lib/cocoapods/sandbox.rb +38 -9
  72. data/lib/cocoapods/sandbox/file_accessor.rb +21 -0
  73. data/lib/cocoapods/sandbox/headers_store.rb +18 -3
  74. data/lib/cocoapods/sandbox/pod_dir_cleaner.rb +1 -14
  75. data/lib/cocoapods/sources_manager.rb +11 -3
  76. data/lib/cocoapods/target.rb +67 -7
  77. data/lib/cocoapods/target/aggregate_target.rb +70 -8
  78. data/lib/cocoapods/target/build_settings.rb +124 -65
  79. data/lib/cocoapods/target/build_type.rb +139 -0
  80. data/lib/cocoapods/target/framework_paths.rb +12 -7
  81. data/lib/cocoapods/target/pod_target.rb +322 -65
  82. data/lib/cocoapods/user_interface.rb +2 -2
  83. data/lib/cocoapods/user_interface/error_report.rb +3 -0
  84. data/lib/cocoapods/user_interface/inspector_reporter.rb +1 -1
  85. data/lib/cocoapods/validator.rb +74 -39
  86. data/lib/cocoapods/version_metadata.rb +7 -0
  87. metadata +30 -6
@@ -0,0 +1,75 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ # Wires up the dependencies for aggregate targets from the target installation results
5
+ #
6
+ class AggregateTargetDependencyInstaller
7
+ require 'cocoapods/native_target_extension.rb'
8
+
9
+ # @return [Hash{String => TargetInstallationResult}] The target installation results for pod targets.
10
+ #
11
+ attr_reader :pod_target_installation_results
12
+
13
+ # @return [Hash{String => TargetInstallationResult}] The target installation results for aggregate targets.
14
+ #
15
+ attr_reader :aggregate_target_installation_results
16
+
17
+ # @return [ProjectMetadataCache] The project metadata cache.
18
+ #
19
+ attr_reader :metadata_cache
20
+
21
+ # Initialize a new instance.
22
+ #
23
+ # @param [Hash{String => TargetInstallationResult}] aggregate_target_installation_results @see #aggregate_target_installation_results
24
+ # @param [Hash{String => TargetInstallationResult}] pod_target_installation_results @see #pod_target_installation_results
25
+ # @param [ProjectMetadataCache] metadata_cache @see #metadata_cache
26
+ #
27
+ def initialize(aggregate_target_installation_results, pod_target_installation_results, metadata_cache)
28
+ @aggregate_target_installation_results = aggregate_target_installation_results
29
+ @pod_target_installation_results = pod_target_installation_results
30
+ @metadata_cache = metadata_cache
31
+ end
32
+
33
+ def install!
34
+ aggregate_target_installation_results.values.each do |aggregate_target_installation_result|
35
+ aggregate_target = aggregate_target_installation_result.target
36
+ aggregate_native_target = aggregate_target_installation_result.native_target
37
+ project = aggregate_native_target.project
38
+ is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) &
39
+ [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty?
40
+ is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' }
41
+ configure_app_extension_api_only_to_native_target(aggregate_native_target) if is_app_extension
42
+ # Wire up dependencies that are part of inherit search paths for this aggregate target.
43
+ aggregate_target.search_paths_aggregate_targets.each do |search_paths_target|
44
+ aggregate_native_target.add_dependency(aggregate_target_installation_results[search_paths_target.name].native_target)
45
+ end
46
+ # Wire up all pod target dependencies to aggregate target.
47
+ aggregate_target.pod_targets.each do |pod_target|
48
+ if pod_target_installation_result = pod_target_installation_results[pod_target.name]
49
+ pod_target_native_target = pod_target_installation_result.native_target
50
+ aggregate_native_target.add_dependency(pod_target_native_target)
51
+ configure_app_extension_api_only_to_native_target(pod_target_native_target) if is_app_extension
52
+ else
53
+ # Hit the cache
54
+ cached_dependency = metadata_cache.target_label_by_metadata[pod_target.label]
55
+ project.add_cached_subproject_reference(cached_dependency, project.dependencies_group)
56
+ Project.add_cached_dependency(aggregate_native_target, cached_dependency)
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ # Sets the APPLICATION_EXTENSION_API_ONLY build setting to YES for all
65
+ # configurations of the given native target.
66
+ #
67
+ def configure_app_extension_api_only_to_native_target(native_target)
68
+ native_target.build_configurations.each do |config|
69
+ config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES'
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -16,7 +16,7 @@ module Pod
16
16
  create_support_files_dir
17
17
  create_support_files_group
18
18
  create_xcconfig_file(native_target)
19
- if target.requires_frameworks?
19
+ if target.host_requires_frameworks?
20
20
  create_info_plist_file(target.info_plist_path, native_target, target.version, target.platform)
21
21
  create_module_map(native_target)
22
22
  create_umbrella_header(native_target)
@@ -13,7 +13,7 @@ module Pod
13
13
  attr_reader :sandbox
14
14
 
15
15
  # @return [Pod::Project]
16
- # The `Pods/Pods.xcodeproj` to install the app host into.
16
+ # The project to install the app host into.
17
17
  #
18
18
  attr_reader :project
19
19
 
@@ -21,30 +21,42 @@ module Pod
21
21
  #
22
22
  attr_reader :platform
23
23
 
24
- # @return [String] the name to use for this app host target.
24
+ # @return [String] the name of the sub group.
25
25
  #
26
- attr_reader :name
26
+ attr_reader :subgroup_name
27
27
 
28
- # @return [String] the name of the pod the app host installer will be installing within.
28
+ # @return [String] the name of the group the app host installer will be installing within.
29
29
  #
30
- attr_reader :pod_name
30
+ attr_reader :group_name
31
+
32
+ # @return [String] the name of the app target label that will be used.
33
+ #
34
+ attr_reader :app_target_label
35
+
36
+ # @return [Boolean] whether the app host installer should add main.m
37
+ #
38
+ attr_reader :add_main
31
39
 
32
40
  # Initialize a new instance
33
41
  #
34
42
  # @param [Sandbox] sandbox @see #sandbox
35
43
  # @param [Pod::Project] project @see #project
36
44
  # @param [Platform] platform @see #platform
37
- # @param [String] name @see #name
38
- # @param [String] pod_name @see #pod_name
45
+ # @param [String] subgroup_name @see #subgroup_name
46
+ # @param [String] group_name @see #group_name
47
+ # @param [String] app_target_label see #app_target_label
48
+ # @param [Boolean] add_main see #add_main
39
49
  #
40
- def initialize(sandbox, project, platform, name, pod_name)
50
+ def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true)
41
51
  @sandbox = sandbox
42
52
  @project = project
43
53
  @platform = platform
44
- @name = name
45
- @pod_name = pod_name
46
- target_group = project.pod_group(pod_name)
47
- @group = target_group[name] || target_group.new_group(name)
54
+ @subgroup_name = subgroup_name
55
+ @group_name = group_name
56
+ @app_target_label = app_target_label
57
+ @add_main = add_main
58
+ target_group = project.pod_group(group_name)
59
+ @group = target_group[subgroup_name] || target_group.new_group(subgroup_name)
48
60
  end
49
61
 
50
62
  # @return [PBXNativeTarget] the app host native target that was installed.
@@ -52,16 +64,16 @@ module Pod
52
64
  def install!
53
65
  platform_name = platform.name
54
66
  app_host_target = Pod::Generator::AppTargetHelper.add_app_target(project, platform_name, deployment_target,
55
- name)
67
+ app_target_label)
56
68
  app_host_target.build_configurations.each do |configuration|
57
- configuration.build_settings['PRODUCT_NAME'] = name
69
+ configuration.build_settings['PRODUCT_NAME'] = app_target_label
58
70
  configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
59
71
  configuration.build_settings['CODE_SIGN_IDENTITY'] = '' if platform == :osx
60
72
  configuration.build_settings['CURRENT_PROJECT_VERSION'] = '1'
61
73
  end
62
74
 
63
- Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, @group, name)
64
- Pod::Generator::AppTargetHelper.add_launchscreen_storyboard(project, app_host_target, @group, deployment_target, name) if platform == :ios
75
+ Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, @group, app_target_label) if add_main
76
+ Pod::Generator::AppTargetHelper.add_launchscreen_storyboard(project, app_host_target, @group, deployment_target, app_target_label) if platform == :ios
65
77
  additional_entries = platform == :ios ? ADDITIONAL_IOS_INFO_PLIST_ENTRIES : {}
66
78
  create_info_plist_file_with_sandbox(sandbox, app_host_info_plist_path, app_host_target, '1.0.0', platform,
67
79
  :appl, additional_entries)
@@ -89,7 +101,7 @@ module Pod
89
101
  # @return [Pathname] The absolute path of the Info.plist to use for an app host.
90
102
  #
91
103
  def app_host_info_plist_path
92
- project.path.dirname.+(name).+("#{name}-Info.plist")
104
+ project.path.dirname.+(subgroup_name).+("#{app_target_label}-Info.plist")
93
105
  end
94
106
 
95
107
  # @return [String] The deployment target.
@@ -14,7 +14,7 @@ module Pod
14
14
  #
15
15
  attr_reader :pod_targets
16
16
 
17
- # @return [Project] The Pods project.
17
+ # @return [Project] The project to install the file references into.
18
18
  #
19
19
  attr_reader :pods_project
20
20
 
@@ -42,6 +42,7 @@ module Pod
42
42
  #
43
43
  def install!
44
44
  refresh_file_accessors
45
+ prepare_pod_groups
45
46
  add_source_files_references
46
47
  add_frameworks_bundles
47
48
  add_vendored_libraries
@@ -67,6 +68,19 @@ module Pod
67
68
  file_accessors.map(&:path_list).uniq.each(&:read_file_system)
68
69
  end
69
70
 
71
+ # Prepares the main groups to which all files will be added for the respective target
72
+ #
73
+ def prepare_pod_groups
74
+ file_accessors.each do |file_accessor|
75
+ pod_name = file_accessor.spec.name
76
+ next unless sandbox.local?(pod_name)
77
+ root_name = Specification.root_name(pod_name)
78
+ path = file_accessor.root
79
+ group = pods_project.group_for_spec(root_name)
80
+ group.set_path(path) unless group.path == path
81
+ end
82
+ end
83
+
70
84
  # Adds the source files of the Pods to the Pods project.
71
85
  #
72
86
  # @note The source files are grouped by Pod and in turn by subspec
@@ -75,7 +89,7 @@ module Pod
75
89
  # @return [void]
76
90
  #
77
91
  def add_source_files_references
78
- UI.message '- Adding source files to Pods project' do
92
+ UI.message '- Adding source files' do
79
93
  add_file_accessors_paths_to_pods_group(:source_files, nil, true)
80
94
  end
81
95
  end
@@ -85,7 +99,7 @@ module Pod
85
99
  # @return [void]
86
100
  #
87
101
  def add_frameworks_bundles
88
- UI.message '- Adding frameworks to Pods project' do
102
+ UI.message '- Adding frameworks' do
89
103
  add_file_accessors_paths_to_pods_group(:vendored_frameworks, :frameworks)
90
104
  end
91
105
  end
@@ -95,7 +109,7 @@ module Pod
95
109
  # @return [void]
96
110
  #
97
111
  def add_vendored_libraries
98
- UI.message '- Adding libraries to Pods project' do
112
+ UI.message '- Adding libraries' do
99
113
  add_file_accessors_paths_to_pods_group(:vendored_libraries, :frameworks)
100
114
  end
101
115
  end
@@ -108,14 +122,14 @@ module Pod
108
122
  # @return [void]
109
123
  #
110
124
  def add_resources
111
- UI.message '- Adding resources to Pods project' do
125
+ UI.message '- Adding resources' do
112
126
  add_file_accessors_paths_to_pods_group(:resources, :resources, true)
113
127
  add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources, true)
114
128
  end
115
129
  end
116
130
 
117
131
  def add_developer_files
118
- UI.message '- Adding development pod helper files to Pods project' do
132
+ UI.message '- Adding development pod helper files' do
119
133
  file_accessors.each do |file_accessor|
120
134
  pod_name = file_accessor.spec.name
121
135
  next unless sandbox.local?(pod_name)
@@ -144,31 +158,21 @@ module Pod
144
158
  # frameworks, whose headers are included inside the built
145
159
  # framework. Those headers do not need to be linked from the
146
160
  # sandbox.
147
- next if pod_target.requires_frameworks? && pod_target.should_build?
148
-
149
- headers_sandbox = Pathname.new(pod_target.pod_name)
150
- added_build_headers = false
151
- added_public_headers = false
152
-
153
- file_accessors = pod_target.file_accessors.reject { |fa| fa.spec.test_specification? }
154
- file_accessors.each do |file_accessor|
155
- # Private headers will always end up in Pods/Headers/Private/PodA/*.h
156
- # This will allow for `""` imports to work.
157
- header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
158
- added_build_headers = true
161
+ next if pod_target.build_as_framework? && pod_target.should_build?
162
+
163
+ pod_target_header_mappings = pod_target.header_mappings_by_file_accessor.values
164
+ pod_target_header_mappings.each do |header_mappings|
165
+ header_mappings.each do |namespaced_path, files|
159
166
  pod_target.build_headers.add_files(namespaced_path, files)
160
167
  end
168
+ end
161
169
 
162
- # Public headers on the other hand will be added in Pods/Headers/Public/PodA/PodA/*.h
163
- # The extra folder is intentional in order for `<>` imports to work.
164
- header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
165
- added_public_headers = true
170
+ public_header_mappings = pod_target.public_header_mappings_by_file_accessor.values
171
+ public_header_mappings.each do |header_mappings|
172
+ header_mappings.each do |namespaced_path, files|
166
173
  sandbox.public_headers.add_files(namespaced_path, files)
167
174
  end
168
175
  end
169
-
170
- pod_target.build_headers.add_search_path(headers_sandbox, pod_target.platform) if added_build_headers
171
- sandbox.public_headers.add_search_path(headers_sandbox, pod_target.platform) if added_public_headers
172
176
  end
173
177
  end
174
178
  end
@@ -209,11 +213,11 @@ module Pod
209
213
  next if paths.empty?
210
214
 
211
215
  pod_name = file_accessor.spec.name
212
- preserve_pod_file_structure_flag = (sandbox.local?(pod_name) || preserve_pod_file_structure)
216
+ preserve_pod_file_structure_flag = (sandbox.local?(pod_name) || preserve_pod_file_structure) && reflect_file_system_structure
213
217
  base_path = preserve_pod_file_structure_flag ? common_path(paths) : nil
214
218
  group = pods_project.group_for_spec(pod_name, group_key)
215
219
  paths.each do |path|
216
- pods_project.add_file_reference(path, group, preserve_pod_file_structure_flag && reflect_file_system_structure, base_path)
220
+ pods_project.add_file_reference(path, group, preserve_pod_file_structure_flag, base_path)
217
221
  end
218
222
  end
219
223
  end
@@ -294,44 +298,6 @@ module Pod
294
298
  return result unless result.to_s == '' || result.to_s == '/'
295
299
  end
296
300
 
297
- # Computes the destination sub-directory in the sandbox
298
- #
299
- # @param [Pathname] headers_sandbox
300
- # The sandbox where the header links should be stored for this
301
- # Pod.
302
- #
303
- # @param [Sandbox::FileAccessor] file_accessor
304
- # The consumer file accessor for which the headers need to be
305
- # linked.
306
- #
307
- # @param [Array<Pathname>] headers
308
- # The absolute paths of the headers which need to be mapped.
309
- #
310
- # @return [Hash{Pathname => Array<Pathname>}] A hash containing the
311
- # headers folders as the keys and the absolute paths of the
312
- # header files as the values.
313
- #
314
- def header_mappings(headers_sandbox, file_accessor, headers)
315
- consumer = file_accessor.spec_consumer
316
- header_mappings_dir = consumer.header_mappings_dir
317
- dir = headers_sandbox
318
- dir += consumer.header_dir if consumer.header_dir
319
-
320
- mappings = {}
321
- headers.each do |header|
322
- next if header.to_s.include?('.framework/')
323
-
324
- sub_dir = dir
325
- if header_mappings_dir
326
- relative_path = header.relative_path_from(file_accessor.path_list.root + header_mappings_dir)
327
- sub_dir += relative_path.dirname
328
- end
329
- mappings[sub_dir] ||= []
330
- mappings[sub_dir] << header
331
- end
332
- mappings
333
- end
334
-
335
301
  #-----------------------------------------------------------------------#
336
302
  end
337
303
  end
@@ -0,0 +1,155 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ # Wires up the dependencies between targets from the target installation results
5
+ #
6
+ class PodTargetDependencyInstaller
7
+ require 'cocoapods/native_target_extension.rb'
8
+
9
+ # @return [TargetInstallationResults] The target installation results for pod targets.
10
+ #
11
+ attr_reader :pod_target_installation_results
12
+
13
+ # @return [ProjectMetadataCache] The metadata cache for targets.
14
+ #
15
+ attr_reader :metadata_cache
16
+
17
+ # Initialize a new instance.
18
+ #
19
+ # @param [TargetInstallationResults] pod_target_installation_results @see #pod_target_installation_results
20
+ # @param [ProjectMetadataCache] metadata_cache @see #metadata_cache
21
+ #
22
+ def initialize(pod_target_installation_results, metadata_cache)
23
+ @pod_target_installation_results = pod_target_installation_results
24
+ @metadata_cache = metadata_cache
25
+ end
26
+
27
+ def install!
28
+ # Wire up pod targets
29
+ pod_target_installation_results.values.each do |pod_target_installation_result|
30
+ pod_target = pod_target_installation_result.target
31
+ native_target = pod_target_installation_result.native_target
32
+ project = native_target.project
33
+ frameworks_group = project.frameworks_group
34
+
35
+ # First, wire up all resource bundles.
36
+ wire_resource_bundle_targets(pod_target_installation_result.resource_bundle_targets,
37
+ native_target, pod_target)
38
+ # Wire up all dependencies to this pod target, if any.
39
+ wire_target_dependencies(pod_target, native_target, project, pod_target_installation_results,
40
+ metadata_cache, frameworks_group)
41
+
42
+ # Wire up test native targets.
43
+ unless pod_target_installation_result.test_native_targets.empty?
44
+ wire_test_native_targets(pod_target, pod_target_installation_result, pod_target_installation_results,
45
+ project, frameworks_group, metadata_cache)
46
+ end
47
+
48
+ # Wire up app native targets.
49
+ unless pod_target_installation_result.app_native_targets.empty?
50
+ wire_app_native_targets(pod_target, native_target, pod_target_installation_result,
51
+ pod_target_installation_results, project, frameworks_group, metadata_cache)
52
+ end
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def wire_resource_bundle_targets(resource_bundle_targets, native_target, pod_target)
59
+ resource_bundle_targets.each do |resource_bundle_target|
60
+ native_target.add_dependency(resource_bundle_target)
61
+ if pod_target.build_as_dynamic_framework? && pod_target.should_build?
62
+ native_target.add_resources([resource_bundle_target.product_reference])
63
+ end
64
+ end
65
+ end
66
+
67
+ def wire_target_dependencies(pod_target, native_target, project,
68
+ pod_target_installation_results, metadata_cache, frameworks_group)
69
+ dependent_targets = pod_target.dependent_targets
70
+ dependent_targets.each do |dependent_target|
71
+ if installation_result = pod_target_installation_results[dependent_target.name]
72
+ dependent_project = installation_result.native_target.project
73
+ if dependent_project != project
74
+ project.add_subproject_reference(dependent_project, project.dependencies_group)
75
+ end
76
+ native_target.add_dependency(installation_result.native_target)
77
+ add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
78
+ else
79
+ # Hit the cache
80
+ cached_dependency = metadata_cache.target_label_by_metadata[dependent_target.label]
81
+ project.add_cached_subproject_reference(cached_dependency, project.dependencies_group)
82
+ Project.add_cached_dependency(native_target, cached_dependency)
83
+ end
84
+ end
85
+ end
86
+
87
+ def wire_test_native_targets(pod_target, installation_result, pod_target_installation_results, project, frameworks_group, metadata_cache)
88
+ installation_result.test_specs_by_native_target.each do |test_native_target, test_spec|
89
+ resource_bundle_native_targets = installation_result.test_resource_bundle_targets[test_spec.name] || []
90
+ resource_bundle_native_targets.each do |test_resource_bundle_target|
91
+ test_native_target.add_dependency(test_resource_bundle_target)
92
+ end
93
+
94
+ test_dependent_targets = pod_target.test_dependent_targets_by_spec_name.fetch(test_spec.name, []).unshift(pod_target).uniq
95
+ test_dependent_targets.each do |test_dependent_target|
96
+ if dependency_installation_result = pod_target_installation_results[test_dependent_target.name]
97
+ dependent_test_project = dependency_installation_result.native_target.project
98
+ if dependent_test_project != project
99
+ project.add_subproject_reference(dependent_test_project, project.dependencies_group)
100
+ end
101
+ test_native_target.add_dependency(dependency_installation_result.native_target)
102
+ add_framework_file_reference_to_native_target(test_native_target, pod_target, test_dependent_target, frameworks_group)
103
+ else
104
+ # Hit the cache
105
+ cached_dependency = metadata_cache.target_label_by_metadata[test_dependent_target.label]
106
+ project.add_cached_subproject_reference(cached_dependency, project.dependencies_group)
107
+ Project.add_cached_dependency(test_native_target, cached_dependency)
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ def wire_app_native_targets(pod_target, native_target, installation_result, pod_target_installation_results, project, frameworks_group, metadata_cache)
114
+ installation_result.app_specs_by_native_target.each do |app_native_target, app_spec|
115
+ resource_bundle_native_targets = installation_result.app_resource_bundle_targets[app_spec.name] || []
116
+ resource_bundle_native_targets.each do |app_resource_bundle_target|
117
+ app_native_target.add_dependency(app_resource_bundle_target)
118
+ end
119
+
120
+ app_dependent_targets = pod_target.app_dependent_targets_by_spec_name.fetch(app_spec.name, []).unshift(pod_target).uniq
121
+ app_dependent_targets.each do |app_dependent_target|
122
+ if dependency_installation_result = pod_target_installation_results[app_dependent_target.name]
123
+ resource_bundle_native_targets = dependency_installation_result.app_resource_bundle_targets[app_spec.name]
124
+ unless resource_bundle_native_targets.nil?
125
+ resource_bundle_native_targets.each do |app_resource_bundle_target|
126
+ app_native_target.add_dependency(app_resource_bundle_target)
127
+ end
128
+ end
129
+ dependency_project = dependency_installation_result.native_target.project
130
+ if dependency_project != project
131
+ project.add_subproject_reference(dependency_project, project.dependencies_group)
132
+ end
133
+ app_native_target.add_dependency(dependency_installation_result.native_target)
134
+ add_framework_file_reference_to_native_target(app_native_target, pod_target, app_dependent_target, frameworks_group)
135
+ else
136
+ # Hit the cache
137
+ cached_dependency = metadata_cache.target_label_by_metadata[app_dependent_target.label]
138
+ project.add_cached_subproject_reference(cached_dependency, project.dependencies_group)
139
+ Project.add_cached_dependency(native_target, cached_dependency)
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ def add_framework_file_reference_to_native_target(native_target, pod_target, dependent_target, frameworks_group)
146
+ if pod_target.should_build? && pod_target.build_as_dynamic? && dependent_target.should_build?
147
+ product_ref = frameworks_group.files.find { |f| f.path == dependent_target.product_name } ||
148
+ frameworks_group.new_product_ref_for_target(dependent_target.product_basename, dependent_target.product_type)
149
+ native_target.frameworks_build_phase.add_file_reference(product_ref, true)
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end