cocoapods 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +329 -0
  3. data/lib/cocoapods/command/init.rb +6 -6
  4. data/lib/cocoapods/command/ipc/list.rb +40 -0
  5. data/lib/cocoapods/command/ipc/podfile.rb +31 -0
  6. data/lib/cocoapods/command/ipc/repl.rb +51 -0
  7. data/lib/cocoapods/command/ipc/spec.rb +29 -0
  8. data/lib/cocoapods/command/ipc/update_search_index.rb +24 -0
  9. data/lib/cocoapods/command/ipc.rb +18 -0
  10. data/lib/cocoapods/command/lib/create.rb +105 -0
  11. data/lib/cocoapods/command/lib/lint.rb +111 -0
  12. data/lib/cocoapods/command/lib.rb +3 -207
  13. data/lib/cocoapods/command/repo/push.rb +44 -20
  14. data/lib/cocoapods/command/setup.rb +2 -1
  15. data/lib/cocoapods/command/spec/lint.rb +4 -0
  16. data/lib/cocoapods/command.rb +2 -1
  17. data/lib/cocoapods/config.rb +4 -1
  18. data/lib/cocoapods/downloader/cache.rb +1 -0
  19. data/lib/cocoapods/downloader.rb +20 -0
  20. data/lib/cocoapods/executable.rb +1 -1
  21. data/lib/cocoapods/gem_version.rb +1 -1
  22. data/lib/cocoapods/generator/acknowledgements/plist.rb +4 -1
  23. data/lib/cocoapods/generator/copy_resources_script.rb +4 -10
  24. data/lib/cocoapods/generator/header.rb +2 -1
  25. data/lib/cocoapods/generator/prefix_header.rb +0 -12
  26. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +38 -5
  27. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +5 -4
  28. data/lib/cocoapods/installer/analyzer/pod_variant_set.rb +5 -1
  29. data/lib/cocoapods/installer/analyzer/target_inspector.rb +24 -1
  30. data/lib/cocoapods/installer/analyzer.rb +161 -1
  31. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +29 -9
  32. data/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb +204 -0
  33. data/lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb +314 -0
  34. data/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +401 -0
  35. data/lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb +214 -0
  36. data/lib/cocoapods/installer/xcode/pods_project_generator.rb +265 -0
  37. data/lib/cocoapods/installer/xcode.rb +7 -0
  38. data/lib/cocoapods/installer.rb +50 -214
  39. data/lib/cocoapods/resolver.rb +15 -9
  40. data/lib/cocoapods/sandbox/headers_store.rb +4 -10
  41. data/lib/cocoapods/sandbox/path_list.rb +20 -9
  42. data/lib/cocoapods/sources_manager.rb +7 -10
  43. data/lib/cocoapods/target/aggregate_target.rb +20 -0
  44. data/lib/cocoapods/target/pod_target.rb +37 -7
  45. data/lib/cocoapods/user_interface/error_report.rb +7 -0
  46. data/lib/cocoapods/user_interface/inspector_reporter.rb +109 -0
  47. data/lib/cocoapods/user_interface.rb +7 -5
  48. data/lib/cocoapods/validator.rb +59 -11
  49. metadata +112 -83
  50. data/lib/cocoapods/command/inter_process_communication.rb +0 -177
  51. data/lib/cocoapods/installer/file_references_installer.rb +0 -310
  52. data/lib/cocoapods/installer/migrator.rb +0 -86
  53. data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +0 -191
  54. data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +0 -368
  55. data/lib/cocoapods/installer/target_installer.rb +0 -210
@@ -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,86 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Pod
4
- class Installer
5
- # Migrates installations performed by previous versions of CocoaPods.
6
- #
7
- class Migrator
8
- class << self
9
- # Performs the migration.
10
- #
11
- # @param [Sandbox] sandbox
12
- # The sandbox which should be migrated.
13
- #
14
- def migrate(sandbox)
15
- return unless sandbox.manifest
16
- end
17
-
18
- # @!group Migration Steps
19
-
20
- # @!group Private helpers
21
-
22
- # Check whether a migration is required
23
- #
24
- # @param [#to_s] target_version
25
- # See Version#new.
26
- #
27
- # @param [Sandbox] sandbox
28
- # The sandbox
29
- #
30
- # @return [void]
31
- #
32
- def installation_minor?(target_version, sandbox)
33
- sandbox.manifest.cocoapods_version < Version.new(target_version)
34
- end
35
-
36
- # Makes a path creating any intermediate directory and printing an UI
37
- # message.
38
- #
39
- # @path [#to_s] path
40
- # The path.
41
- #
42
- # @return [void]
43
- #
44
- def make_path(path)
45
- return if path.exist?
46
- UI.message "- Making path #{UI.path(path)}" do
47
- path.mkpath
48
- end
49
- end
50
-
51
- # Moves a path to another one printing an UI message.
52
- #
53
- # @path [#to_s] source
54
- # The path to move.
55
- #
56
- # @path [#to_s] destination
57
- # The destination path.
58
- #
59
- # @return [void]
60
- #
61
- def move(source, destination)
62
- return unless source.exist?
63
- make_path(destination.dirname)
64
- UI.message "- Moving #{UI.path(source)} to #{UI.path(destination)}" do
65
- FileUtils.mv(source.to_s, destination.to_s)
66
- end
67
- end
68
-
69
- # Deletes a path, including non empty directories, printing an UI
70
- # message.
71
- #
72
- # @path [#to_s] path
73
- # The path.
74
- #
75
- # @return [void]
76
- #
77
- def delete(path)
78
- return unless path.exist?
79
- UI.message "- Deleting #{UI.path(path)}" do
80
- FileUtils.rm_rf(path)
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,191 +0,0 @@
1
- module Pod
2
- class Installer
3
- # Creates the targets which aggregate the Pods libraries in the Pods
4
- # project and the relative support files.
5
- #
6
- class AggregateTargetInstaller < TargetInstaller
7
- # Creates the target in the Pods project and the relative support files.
8
- #
9
- # @return [void]
10
- #
11
- def install!
12
- UI.message "- Installing target `#{target.name}` #{target.platform}" do
13
- add_target
14
- create_support_files_dir
15
- create_support_files_group
16
- create_xcconfig_file
17
- if target.requires_frameworks?
18
- create_info_plist_file
19
- create_module_map
20
- create_umbrella_header
21
- end
22
- create_embed_frameworks_script
23
- create_bridge_support_file
24
- create_copy_resources_script
25
- create_acknowledgements
26
- create_dummy_source
27
- end
28
- end
29
-
30
- #-----------------------------------------------------------------------#
31
-
32
- private
33
-
34
- # @return [TargetDefinition] the target definition of the library.
35
- #
36
- def target_definition
37
- target.target_definition
38
- end
39
-
40
- # Ensure that vendored static frameworks and libraries are not linked
41
- # twice to the aggregate target, which shares the xcconfig of the user
42
- # target.
43
- #
44
- def custom_build_settings
45
- settings = {
46
- 'MACH_O_TYPE' => 'staticlib',
47
- 'OTHER_LDFLAGS' => '',
48
- 'OTHER_LIBTOOLFLAGS' => '',
49
- 'PODS_ROOT' => '$(SRCROOT)',
50
- 'PRODUCT_BUNDLE_IDENTIFIER' => 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}',
51
- 'SKIP_INSTALL' => 'YES',
52
- }
53
- super.merge(settings)
54
- end
55
-
56
- # Creates the group that holds the references to the support files
57
- # generated by this installer.
58
- #
59
- # @return [void]
60
- #
61
- def create_support_files_group
62
- parent = project.support_files_group
63
- name = target.name
64
- dir = target.support_files_dir
65
- @support_files_group = parent.new_group(name, dir)
66
- end
67
-
68
- # Generates the contents of the xcconfig file and saves it to disk.
69
- #
70
- # @return [void]
71
- #
72
- def create_xcconfig_file
73
- native_target.build_configurations.each do |configuration|
74
- path = target.xcconfig_path(configuration.name)
75
- gen = Generator::XCConfig::AggregateXCConfig.new(target, configuration.name)
76
- gen.save_as(path)
77
- target.xcconfigs[configuration.name] = gen.xcconfig
78
- xcconfig_file_ref = add_file_to_support_group(path)
79
- configuration.base_configuration_reference = xcconfig_file_ref
80
- end
81
- end
82
-
83
- # Generates the bridge support metadata if requested by the {Podfile}.
84
- #
85
- # @note The bridge support metadata is added to the resources of the
86
- # target because it is needed for environments interpreted at
87
- # runtime.
88
- #
89
- # @return [void]
90
- #
91
- def create_bridge_support_file
92
- if target.podfile.generate_bridge_support?
93
- path = target.bridge_support_path
94
- headers = native_target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
95
- generator = Generator::BridgeSupport.new(headers)
96
- generator.save_as(path)
97
- add_file_to_support_group(path)
98
- @bridge_support_file = path.relative_path_from(sandbox.root)
99
- end
100
- end
101
-
102
- # Uniqued Resources grouped by config
103
- #
104
- # @return [Hash{ Symbol => Array<Pathname> }]
105
- #
106
- def resources_by_config
107
- library_targets = target.pod_targets.reject do |pod_target|
108
- pod_target.should_build? && pod_target.requires_frameworks?
109
- end
110
- target.user_build_configurations.keys.each_with_object({}) do |config, resources_by_config|
111
- resources_by_config[config] = library_targets.flat_map do |library_target|
112
- next [] unless library_target.include_in_build_config?(target_definition, config)
113
- resource_paths = library_target.file_accessors.flat_map do |accessor|
114
- accessor.resources.flat_map { |res| res.relative_path_from(project.path.dirname) }
115
- end
116
- resource_bundles = library_target.file_accessors.flat_map do |accessor|
117
- accessor.resource_bundles.keys.map { |name| "#{library_target.configuration_build_dir}/#{name.shellescape}.bundle" }
118
- end
119
- (resource_paths + resource_bundles + [bridge_support_file].compact).uniq
120
- end
121
- end
122
- end
123
-
124
- # Creates a script that copies the resources to the bundle of the client
125
- # target.
126
- #
127
- # @note The bridge support file needs to be created before the prefix
128
- # header, otherwise it will not be added to the resources script.
129
- #
130
- # @return [void]
131
- #
132
- def create_copy_resources_script
133
- path = target.copy_resources_script_path
134
- generator = Generator::CopyResourcesScript.new(resources_by_config, target.platform)
135
- generator.save_as(path)
136
- add_file_to_support_group(path)
137
- end
138
-
139
- # Creates a script that embeds the frameworks to the bundle of the client
140
- # target.
141
- #
142
- # @note We can't use Xcode default copy bundle resource phase, because
143
- # we need to ensure that we only copy the resources, which are
144
- # relevant for the current build configuration.
145
- #
146
- # @return [void]
147
- #
148
- def create_embed_frameworks_script
149
- path = target.embed_frameworks_script_path
150
- frameworks_by_config = {}
151
- target.user_build_configurations.keys.each do |config|
152
- relevant_pod_targets = target.pod_targets.select do |pod_target|
153
- pod_target.include_in_build_config?(target_definition, config)
154
- end
155
- frameworks_by_config[config] = relevant_pod_targets.flat_map do |pod_target|
156
- frameworks = pod_target.file_accessors.flat_map(&:vendored_dynamic_artifacts).map { |fw| "${PODS_ROOT}/#{fw.relative_path_from(sandbox.root)}" }
157
- frameworks << pod_target.build_product_path('$BUILT_PRODUCTS_DIR') if pod_target.should_build? && pod_target.requires_frameworks?
158
- frameworks
159
- end
160
- end
161
- generator = Generator::EmbedFrameworksScript.new(frameworks_by_config)
162
- generator.save_as(path)
163
- add_file_to_support_group(path)
164
- end
165
-
166
- # Generates the acknowledgement files (markdown and plist) for the target.
167
- #
168
- # @return [void]
169
- #
170
- def create_acknowledgements
171
- basepath = target.acknowledgements_basepath
172
- Generator::Acknowledgements.generators.each do |generator_class|
173
- path = generator_class.path_from_basepath(basepath)
174
- file_accessors = target.pod_targets.map(&:file_accessors).flatten
175
- generator = generator_class.new(file_accessors)
176
- generator.save_as(path)
177
- add_file_to_support_group(path)
178
- end
179
- end
180
-
181
- # @return [Pathname] the path of the bridge support file relative to the
182
- # sandbox.
183
- #
184
- # @return [Nil] if no bridge support file was generated.
185
- #
186
- attr_reader :bridge_support_file
187
-
188
- #-----------------------------------------------------------------------#
189
- end
190
- end
191
- end