cocoapods 1.0.1 → 1.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +107 -0
  3. data/lib/cocoapods/command.rb +1 -0
  4. data/lib/cocoapods/command/repo/push.rb +26 -5
  5. data/lib/cocoapods/command/setup.rb +2 -1
  6. data/lib/cocoapods/downloader.rb +20 -0
  7. data/lib/cocoapods/downloader/cache.rb +1 -0
  8. data/lib/cocoapods/gem_version.rb +1 -1
  9. data/lib/cocoapods/generator/acknowledgements/plist.rb +1 -0
  10. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +9 -2
  11. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +5 -4
  12. data/lib/cocoapods/installer.rb +41 -205
  13. data/lib/cocoapods/installer/analyzer.rb +65 -1
  14. data/lib/cocoapods/installer/analyzer/pod_variant.rb +9 -3
  15. data/lib/cocoapods/installer/analyzer/target_inspector.rb +24 -0
  16. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +23 -6
  17. data/lib/cocoapods/installer/xcode.rb +7 -0
  18. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +265 -0
  19. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +202 -0
  20. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +314 -0
  21. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +397 -0
  22. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +214 -0
  23. data/lib/cocoapods/resolver.rb +1 -2
  24. data/lib/cocoapods/target/aggregate_target.rb +19 -0
  25. data/lib/cocoapods/target/pod_target.rb +15 -2
  26. data/lib/cocoapods/user_interface.rb +6 -1
  27. data/lib/cocoapods/user_interface/error_report.rb +7 -0
  28. data/lib/cocoapods/user_interface/inspector_reporter.rb +109 -0
  29. data/lib/cocoapods/validator.rb +15 -7
  30. metadata +42 -19
  31. data/lib/cocoapods/installer/file_references_installer.rb +0 -310
  32. data/lib/cocoapods/installer/target_installer.rb +0 -210
  33. data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +0 -191
  34. data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +0 -389
@@ -1,310 +0,0 @@
1
- module Pod
2
- class Installer
3
- # Controller class responsible of installing the file references of the
4
- # specifications in the Pods project.
5
- #
6
- class FileReferencesInstaller
7
- # @return [Sandbox] The sandbox of the installation.
8
- #
9
- attr_reader :sandbox
10
-
11
- # @return [Array<PodTarget>] The pod targets of the installation.
12
- #
13
- attr_reader :pod_targets
14
-
15
- # @return [Project] The Pods project.
16
- #
17
- attr_reader :pods_project
18
-
19
- # Initialize a new instance
20
- #
21
- # @param [Sandbox] sandbox @see sandbox
22
- # @param [Array<PodTarget>] pod_targets @see pod_targets
23
- # @param [Project] pods_project @see pod_project
24
- #
25
- def initialize(sandbox, pod_targets, pods_project)
26
- @sandbox = sandbox
27
- @pod_targets = pod_targets
28
- @pods_project = pods_project
29
- end
30
-
31
- # Installs the file references.
32
- #
33
- # @return [void]
34
- #
35
- def install!
36
- refresh_file_accessors
37
- add_source_files_references
38
- add_frameworks_bundles
39
- add_vendored_libraries
40
- add_resources
41
- link_headers
42
- end
43
-
44
- #-----------------------------------------------------------------------#
45
-
46
- private
47
-
48
- # @!group Installation Steps
49
-
50
- # Reads the file accessors contents from the file system.
51
- #
52
- # @note The contents of the file accessors are modified by the clean
53
- # step of the #{PodSourceInstaller} and by the pre install hooks.
54
- #
55
- # @return [void]
56
- #
57
- def refresh_file_accessors
58
- file_accessors.each do |fa|
59
- fa.path_list.read_file_system
60
- end
61
- end
62
-
63
- # Adds the source files of the Pods to the Pods project.
64
- #
65
- # @note The source files are grouped by Pod and in turn by subspec
66
- # (recursively).
67
- #
68
- # @return [void]
69
- #
70
- def add_source_files_references
71
- UI.message '- Adding source files to Pods project' do
72
- add_file_accessors_paths_to_pods_group(:source_files, nil, true)
73
- end
74
- end
75
-
76
- # Adds the bundled frameworks to the Pods project
77
- #
78
- # @return [void]
79
- #
80
- def add_frameworks_bundles
81
- UI.message '- Adding frameworks to Pods project' do
82
- add_file_accessors_paths_to_pods_group(:vendored_frameworks, :frameworks)
83
- end
84
- end
85
-
86
- # Adds the bundled libraries to the Pods project
87
- #
88
- # @return [void]
89
- #
90
- def add_vendored_libraries
91
- UI.message '- Adding libraries to Pods project' do
92
- add_file_accessors_paths_to_pods_group(:vendored_libraries, :frameworks)
93
- end
94
- end
95
-
96
- # Adds the resources of the Pods to the Pods project.
97
- #
98
- # @note The source files are grouped by Pod and in turn by subspec
99
- # (recursively) in the resources group.
100
- #
101
- # @return [void]
102
- #
103
- def add_resources
104
- UI.message '- Adding resources to Pods project' do
105
- add_file_accessors_paths_to_pods_group(:resources, :resources, true)
106
- add_file_accessors_paths_to_pods_group(:resource_bundle_files, :resources, true)
107
- end
108
- end
109
-
110
- # Creates the link to the headers of the Pod in the sandbox.
111
- #
112
- # @return [void]
113
- #
114
- def link_headers
115
- UI.message '- Linking headers' do
116
- pod_targets.each do |pod_target|
117
- pod_target.file_accessors.each do |file_accessor|
118
- framework_exp = /\.framework\//
119
- headers_sandbox = Pathname.new(file_accessor.spec.root.name)
120
-
121
- # When integrating Pod as frameworks, built Pods are built into
122
- # frameworks, whose headers are included inside the built
123
- # framework. Those headers do not need to be linked from the
124
- # sandbox.
125
- unless pod_target.requires_frameworks? && pod_target.should_build?
126
- pod_target.build_headers.add_search_path(headers_sandbox, pod_target.platform)
127
- sandbox.public_headers.add_search_path(headers_sandbox, pod_target.platform)
128
-
129
- header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
130
- pod_target.build_headers.add_files(namespaced_path, files.reject { |f| f.to_path =~ framework_exp })
131
- end
132
-
133
- header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
134
- sandbox.public_headers.add_files(namespaced_path, files.reject { |f| f.to_path =~ framework_exp })
135
- end
136
- end
137
-
138
- unless pod_target.requires_frameworks?
139
- vendored_frameworks_header_mappings(headers_sandbox, file_accessor).each do |namespaced_path, files|
140
- sandbox.public_headers.add_files(namespaced_path, files)
141
- end
142
- end
143
- end
144
- end
145
- end
146
- end
147
-
148
- #-----------------------------------------------------------------------#
149
-
150
- private
151
-
152
- # @!group Private Helpers
153
-
154
- # @return [Array<Sandbox::FileAccessor>] The file accessors for all the
155
- # specs platform combinations.
156
- #
157
- def file_accessors
158
- @file_accessors ||= pod_targets.map(&:file_accessors).flatten.compact
159
- end
160
-
161
- # Adds file references to the list of the paths returned by the file
162
- # accessor with the given key to the given group of the Pods project.
163
- #
164
- # @param [Symbol] file_accessor_key
165
- # The method of the file accessor which would return the list of
166
- # the paths.
167
- #
168
- # @param [Symbol] group_key
169
- # The key of the group of the Pods project.
170
- #
171
- # @param [Bool] reflect_file_system_structure_for_development
172
- # Whether organizing a local pod's files in subgroups inside
173
- # the pod's group is allowed.
174
- #
175
- # @return [void]
176
- #
177
- def add_file_accessors_paths_to_pods_group(file_accessor_key, group_key = nil, reflect_file_system_structure_for_development = false)
178
- file_accessors.each do |file_accessor|
179
- pod_name = file_accessor.spec.name
180
- local = sandbox.local?(pod_name)
181
- paths = file_accessor.send(file_accessor_key)
182
- paths = allowable_project_paths(paths)
183
- paths.each do |path|
184
- group = pods_project.group_for_spec(file_accessor.spec.name, group_key)
185
- pods_project.add_file_reference(path, group, local && reflect_file_system_structure_for_development)
186
- end
187
- end
188
- end
189
-
190
- # Filters a list of paths down to those paths which can be added to
191
- # the Xcode project. Some paths are intermediates and only their children
192
- # should be added, while some paths are treated as bundles and their
193
- # children should not be added directly.
194
- #
195
- # @param [Array<Pathname>] paths
196
- # The paths to files or directories on disk.
197
- #
198
- # @return [Array<Pathname>] The paths which can be added to the Xcode project
199
- #
200
- def allowable_project_paths(paths)
201
- lproj_paths = Set.new
202
- lproj_paths_with_files = Set.new
203
- allowable_paths = paths.select do |path|
204
- path_str = path.to_s
205
-
206
- # We add the directory for a Core Data model, but not the items in it.
207
- next if path_str =~ /.*\.xcdatamodeld\/.+/i
208
-
209
- # We add the directory for a Core Data migration mapping, but not the items in it.
210
- next if path_str =~ /.*\.xcmappingmodel\/.+/i
211
-
212
- # We add the directory for an asset catalog, but not the items in it.
213
- next if path_str =~ /.*\.xcassets\/.+/i
214
-
215
- if path_str =~ /\.lproj(\/|$)/i
216
- # If the element is an .lproj directory then save it and potentially
217
- # add it later if we don't find any contained items.
218
- if path_str =~ /\.lproj$/i && path.directory?
219
- lproj_paths << path
220
- next
221
- end
222
-
223
- # Collect the paths for the .lproj directories that contain files.
224
- lproj_path = /(^.*\.lproj)\/.*/i.match(path_str)[1]
225
- lproj_paths_with_files << Pathname(lproj_path)
226
-
227
- # Directories nested within an .lproj directory are added as file
228
- # system references so their contained items are not added directly.
229
- next if path.dirname.dirname == lproj_path
230
- end
231
-
232
- true
233
- end
234
-
235
- # Only add the path for the .lproj directories that do not have anything
236
- # within them added as well. This generally happens if the glob within the
237
- # resources directory was not a recursive glob.
238
- allowable_paths + lproj_paths.subtract(lproj_paths_with_files).to_a
239
- end
240
-
241
- # Computes the destination sub-directory in the sandbox
242
- #
243
- # @param [Pathname] headers_sandbox
244
- # The sandbox where the header links should be stored for this
245
- # Pod.
246
- #
247
- # @param [Sandbox::FileAccessor] file_accessor
248
- # The consumer file accessor for which the headers need to be
249
- # linked.
250
- #
251
- # @param [Array<Pathname>] headers
252
- # The absolute paths of the headers which need to be mapped.
253
- #
254
- # @return [Hash{Pathname => Array<Pathname>}] A hash containing the
255
- # headers folders as the keys and the absolute paths of the
256
- # header files as the values.
257
- #
258
- def header_mappings(headers_sandbox, file_accessor, headers)
259
- consumer = file_accessor.spec_consumer
260
- dir = headers_sandbox
261
- dir += consumer.header_dir if consumer.header_dir
262
-
263
- mappings = {}
264
- headers.each do |header|
265
- sub_dir = dir
266
- if consumer.header_mappings_dir
267
- header_mappings_dir = file_accessor.path_list.root + consumer.header_mappings_dir
268
- relative_path = header.relative_path_from(header_mappings_dir)
269
- sub_dir += relative_path.dirname
270
- end
271
- mappings[sub_dir] ||= []
272
- mappings[sub_dir] << header
273
- end
274
- mappings
275
- end
276
-
277
- # Computes the destination sub-directory in the sandbox for headers
278
- # from inside vendored frameworks.
279
- #
280
- # @param [Pathname] headers_sandbox
281
- # The sandbox where the header links should be stored for this
282
- # Pod.
283
- #
284
- # @param [Sandbox::FileAccessor] file_accessor
285
- # The consumer file accessor for which the headers need to be
286
- # linked.
287
- #
288
- def vendored_frameworks_header_mappings(headers_sandbox, file_accessor)
289
- mappings = {}
290
- file_accessor.vendored_frameworks.each do |framework|
291
- headers_dir = Sandbox::FileAccessor.vendored_frameworks_headers_dir(framework)
292
- headers = Sandbox::FileAccessor.vendored_frameworks_headers(framework)
293
- framework_name = framework.basename(framework.extname)
294
- dir = headers_sandbox + framework_name
295
- headers.each do |header|
296
- # the relative path of framework headers should be kept,
297
- # not flattened like is done for most public headers.
298
- relative_path = header.relative_path_from(headers_dir)
299
- sub_dir = dir + relative_path.dirname
300
- mappings[sub_dir] ||= []
301
- mappings[sub_dir] << header
302
- end
303
- end
304
- mappings
305
- end
306
-
307
- #-----------------------------------------------------------------------#
308
- end
309
- end
310
- end
@@ -1,210 +0,0 @@
1
- module Pod
2
- class Installer
3
- # Controller class responsible of creating and configuring the static
4
- # library target in Pods project. It also creates the support file needed
5
- # by the target.
6
- #
7
- class TargetInstaller
8
- # @return [Sandbox] sandbox the sandbox where the support files should
9
- # be generated.
10
- #
11
- attr_reader :sandbox
12
-
13
- # @return [Target] The library whose target needs to be generated.
14
- #
15
- attr_reader :target
16
-
17
- # @param [Project] project @see project
18
- # @param [Target] target @see target
19
- #
20
- def initialize(sandbox, target)
21
- @sandbox = sandbox
22
- @target = target
23
- end
24
-
25
- private
26
-
27
- #-----------------------------------------------------------------------#
28
-
29
- # @!group Installation steps
30
-
31
- # Adds the target for the library to the Pods project with the
32
- # appropriate build configurations.
33
- #
34
- # @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
35
- #
36
- # @return [void]
37
- #
38
- def add_target
39
- product_type = target.product_type
40
- name = target.label
41
- platform = target.platform.name
42
- language = target.uses_swift? ? :swift : :objc
43
- @native_target = project.new_target(product_type, name, platform, deployment_target, nil, language)
44
-
45
- product_name = target.product_name
46
- product = @native_target.product_reference
47
- product.name = product_name
48
-
49
- target.user_build_configurations.each do |bc_name, type|
50
- @native_target.add_build_configuration(bc_name, type)
51
- end
52
-
53
- @native_target.build_configurations.each do |configuration|
54
- configuration.build_settings.merge!(custom_build_settings)
55
- end
56
-
57
- target.native_target = @native_target
58
- end
59
-
60
- # @return [String] The deployment target.
61
- #
62
- def deployment_target
63
- target.platform.deployment_target.to_s
64
- end
65
-
66
- # Returns the customized build settings which are overridden in the build
67
- # settings of the user target.
68
- #
69
- # @return [Hash{String => String}]
70
- #
71
- def custom_build_settings
72
- settings = {}
73
-
74
- unless target.archs.empty?
75
- settings['ARCHS'] = target.archs
76
- end
77
-
78
- if target.requires_frameworks?
79
- settings['PRODUCT_NAME'] = target.product_module_name
80
- else
81
- settings.merge!('OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '')
82
- end
83
-
84
- settings
85
- end
86
-
87
- # Creates the directory where to store the support files of the target.
88
- #
89
- def create_support_files_dir
90
- target.support_files_dir.mkdir
91
- end
92
-
93
- # Creates the Info.plist file which sets public framework attributes
94
- #
95
- # @return [void]
96
- #
97
- def create_info_plist_file
98
- path = target.info_plist_path
99
- UI.message "- Generating Info.plist file at #{UI.path(path)}" do
100
- generator = Generator::InfoPlistFile.new(target)
101
- generator.save_as(path)
102
- add_file_to_support_group(path)
103
-
104
- native_target.build_configurations.each do |c|
105
- relative_path = path.relative_path_from(sandbox.root)
106
- c.build_settings['INFOPLIST_FILE'] = relative_path.to_s
107
- end
108
- end
109
- end
110
-
111
- # Creates the module map file which ensures that the umbrella header is
112
- # recognized with a customized path
113
- #
114
- # @yield_param [Generator::ModuleMap]
115
- # yielded once to configure the private headers
116
- #
117
- # @return [void]
118
- #
119
- def create_module_map
120
- path = target.module_map_path
121
- UI.message "- Generating module map file at #{UI.path(path)}" do
122
- generator = Generator::ModuleMap.new(target)
123
- yield generator if block_given?
124
- generator.save_as(path)
125
- add_file_to_support_group(path)
126
-
127
- native_target.build_configurations.each do |c|
128
- relative_path = path.relative_path_from(sandbox.root)
129
- c.build_settings['MODULEMAP_FILE'] = relative_path.to_s
130
- end
131
- end
132
- end
133
-
134
- # Generates a header which ensures that all header files are exported
135
- # in the module map
136
- #
137
- # @yield_param [Generator::UmbrellaHeader]
138
- # yielded once to configure the imports
139
- #
140
- def create_umbrella_header
141
- path = target.umbrella_header_path
142
- UI.message "- Generating umbrella header at #{UI.path(path)}" do
143
- generator = Generator::UmbrellaHeader.new(target)
144
- yield generator if block_given?
145
- generator.save_as(path)
146
-
147
- # Add the file to the support group and the native target,
148
- # so it will been added to the header build phase
149
- file_ref = add_file_to_support_group(path)
150
- native_target.add_file_references([file_ref])
151
-
152
- # Make the umbrella header public
153
- build_file = native_target.headers_build_phase.build_file(file_ref)
154
- build_file.settings ||= {}
155
- build_file.settings['ATTRIBUTES'] = ['Public']
156
- end
157
- end
158
-
159
- # Generates a dummy source file for each target so libraries that contain
160
- # only categories build.
161
- #
162
- # @return [void]
163
- #
164
- def create_dummy_source
165
- path = target.dummy_source_path
166
- generator = Generator::DummySource.new(target.label)
167
- generator.save_as(path)
168
- file_reference = add_file_to_support_group(path)
169
- native_target.source_build_phase.add_file_reference(file_reference)
170
- end
171
-
172
- # @return [PBXNativeTarget] the target generated by the installation
173
- # process.
174
- #
175
- # @note Generated by the {#add_target} step.
176
- #
177
- attr_reader :native_target
178
-
179
- private
180
-
181
- #-----------------------------------------------------------------------#
182
-
183
- # @!group Private helpers.
184
-
185
- # @return [Project] the Pods project of the sandbox.
186
- #
187
- def project
188
- sandbox.project
189
- end
190
-
191
- # @return [PBXGroup] the group where the file references to the support
192
- # files should be stored.
193
- #
194
- attr_reader :support_files_group
195
-
196
- # Adds a reference to the given file in the support group of this target.
197
- #
198
- # @param [Pathname] path
199
- # The path of the file to which the reference should be added.
200
- #
201
- # @return [PBXFileReference] the file reference of the added file.
202
- #
203
- def add_file_to_support_group(path)
204
- support_files_group.new_file(path)
205
- end
206
-
207
- #-----------------------------------------------------------------------#
208
- end
209
- end
210
- end