cocoapods 0.22.3 → 0.23.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -285,7 +285,7 @@ module Pod
285
285
  #
286
286
  def prepare_pods_project
287
287
  UI.message "- Creating Pods project" do
288
- @pods_project = Pod::Project.new(sandbox.project_path)
288
+ @pods_project = Pod::Project.new(sandbox)
289
289
  if config.podfile_path
290
290
  @pods_project.add_podfile(config.podfile_path)
291
291
  end
@@ -337,7 +337,7 @@ module Pod
337
337
  def set_target_dependencies
338
338
  aggregate_targets.each do |aggregate_target|
339
339
  aggregate_target.pod_targets.each do |pod_target|
340
- add_dependency(aggregate_target, pod_target)
340
+ aggregate_target.target.add_dependency(pod_target.target)
341
341
  pod_target.dependencies.each do |dep|
342
342
 
343
343
  unless dep == pod_target.pod_name
@@ -346,30 +346,13 @@ module Pod
346
346
  unless pod_dependency_target
347
347
  puts "[BUG] DEP: #{dep}"
348
348
  end
349
- add_dependency(pod_target, pod_dependency_target)
349
+ pod_target.target.add_dependency(pod_dependency_target.target)
350
350
  end
351
351
  end
352
352
  end
353
353
  end
354
354
  end
355
355
 
356
- # TODO: tmp - move
357
- #
358
- def add_dependency(dependent_target, dependency_target)
359
- container_proxy = pods_project.new(Xcodeproj::Project::PBXContainerItemProxy)
360
- container_proxy.container_portal = pods_project.root_object.uuid
361
- container_proxy.proxy_type = '1'
362
- container_proxy.remote_global_id_string = dependency_target.target.uuid
363
- container_proxy.remote_info = dependency_target.target.name
364
-
365
- dependency = pods_project.new(Xcodeproj::Project::PBXTargetDependency)
366
- dependency.target = dependency_target.target
367
- dependency.targetProxy = container_proxy
368
-
369
- dependent_target.target.dependencies << dependency
370
- end
371
-
372
-
373
356
  # Links the aggregate targets with all the dependent libraries.
374
357
  #
375
358
  # @note This is run in the integration step to ensure that targets
@@ -35,7 +35,9 @@ module Pod
35
35
  def install!
36
36
  refresh_file_accessors
37
37
  add_source_files_references
38
- add_resources_references
38
+ add_frameworks_bundles
39
+ add_vendored_libraries
40
+ add_resources
39
41
  link_headers
40
42
  end
41
43
 
@@ -71,13 +73,27 @@ module Pod
71
73
  #
72
74
  def add_source_files_references
73
75
  UI.message "- Adding source files to Pods project" do
74
- file_accessors.each do |file_accessor|
75
- files = file_accessor.source_files
76
- spec_name = file_accessor.spec.name
77
- local = sandbox.local?(file_accessor.spec.root.name)
78
- parent_group = local ? pods_project.local_pods : pods_project.pods
79
- pods_project.add_file_references(files, spec_name, parent_group)
80
- end
76
+ add_file_acessors_paths_to_pods_group(:source_files, :source_files)
77
+ end
78
+ end
79
+
80
+ # Adds the bundled frameworks to the Pods project
81
+ #
82
+ # @return [void]
83
+ #
84
+ def add_frameworks_bundles
85
+ UI.message "- Adding frameworks to Pods project" do
86
+ add_file_acessors_paths_to_pods_group(:vendored_frameworks, :frameworks_and_libraries)
87
+ end
88
+ end
89
+
90
+ # Adds the bundled libraries to the Pods project
91
+ #
92
+ # @return [void]
93
+ #
94
+ def add_vendored_libraries
95
+ UI.message "- Adding frameworks to Pods project" do
96
+ add_file_acessors_paths_to_pods_group(:vendored_libraries, :frameworks_and_libraries)
81
97
  end
82
98
  end
83
99
 
@@ -88,16 +104,10 @@ module Pod
88
104
  #
89
105
  # @return [void]
90
106
  #
91
- def add_resources_references
107
+ def add_resources
92
108
  UI.message "- Adding resources to Pods project" do
93
- file_accessors.each do |file_accessor|
94
- file_accessor.resources.each do |resources|
95
- files = file_accessor.resources
96
- spec_name = file_accessor.spec.name
97
- parent_group = pods_project.resources
98
- pods_project.add_file_references(files, spec_name, parent_group)
99
- end
100
- end
109
+ add_file_acessors_paths_to_pods_group(:resources, :resources)
110
+ add_file_acessors_paths_to_pods_group(:resource_bundle_files, :resources)
101
111
  end
102
112
  end
103
113
 
@@ -138,6 +148,28 @@ module Pod
138
148
  @file_accessors ||= libraries.map(&:file_accessors).flatten.compact
139
149
  end
140
150
 
151
+ # Adds file references to the list of the paths returned by the file
152
+ # accessor with the given key to the given group of the Pods project.
153
+ #
154
+ # @param [Symbol] file_accessor_key
155
+ # The method of the file accessor which would return the list of
156
+ # the paths.
157
+ #
158
+ # @param [Symbol] group_key
159
+ # The key of the group of the Pods project.
160
+ #
161
+ # @return [void]
162
+ #
163
+ def add_file_acessors_paths_to_pods_group(file_accessor_key, group_key)
164
+ file_accessors.each do |file_accessor|
165
+ paths = file_accessor.send(file_accessor_key)
166
+ paths.each do |path|
167
+ group = pods_project.group_for_spec(file_accessor.spec.name, group_key)
168
+ pods_project.add_file_reference(path, group)
169
+ end
170
+ end
171
+ end
172
+
141
173
  # Computes the destination sub-directory in the sandbox
142
174
  #
143
175
  # @param [Pathname] headers_sandbox
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string/strip'
2
+
1
3
  module Pod
2
4
  class Installer
3
5
 
@@ -60,6 +62,7 @@ module Pod
60
62
  #
61
63
  def install!
62
64
  download_source unless predownloaded? || local?
65
+ run_prepare_command
63
66
  end
64
67
 
65
68
  # Cleans the installations if appropriate.
@@ -106,6 +109,24 @@ module Pod
106
109
  end
107
110
  end
108
111
 
112
+ extend Executable
113
+ executable :bash
114
+
115
+ # Runs the prepare command bash script of the spec.
116
+ #
117
+ # @return [void]
118
+ #
119
+ def run_prepare_command
120
+ return unless root_spec.prepare_command
121
+ UI.section(" > Running prepare command", '', 1) do
122
+ Dir.chdir(root) do
123
+ prepare_command = root_spec.prepare_command.strip_heredoc.chomp
124
+ full_command = "\nset -e\n" + prepare_command
125
+ bash!(full_command)
126
+ end
127
+ end
128
+ end
129
+
109
130
  # Removes all the files not needed for the installation according to the
110
131
  # specs by platform.
111
132
  #
@@ -229,12 +250,15 @@ module Pod
229
250
  #
230
251
  def used_files
231
252
  files = [
232
- file_accessors.map(&:source_files),
233
- file_accessors.map(&:resources),
234
- file_accessors.map(&:preserve_paths),
253
+ file_accessors.map(&:vendored_frameworks),
254
+ file_accessors.map(&:vendored_libraries),
255
+ file_accessors.map(&:resource_bundle_files),
256
+ file_accessors.map(&:license),
235
257
  file_accessors.map(&:prefix_header),
258
+ file_accessors.map(&:preserve_paths),
236
259
  file_accessors.map(&:readme),
237
- file_accessors.map(&:license),
260
+ file_accessors.map(&:resources),
261
+ file_accessors.map(&:source_files),
238
262
  ]
239
263
 
240
264
  files.flatten.compact.map{ |path| path.to_s }.uniq
@@ -34,7 +34,7 @@ module Pod
34
34
  def create_xcconfig_file
35
35
  path = library.xcconfig_path
36
36
  UI.message "- Generating xcconfig file at #{UI.path(path)}" do
37
- gen = Generator::AggregateXCConfig.new(library)
37
+ gen = Generator::XCConfig::AggregateXCConfig.new(library)
38
38
  gen.save_as(path)
39
39
  library.xcconfig = gen.xcconfig
40
40
  xcconfig_file_ref = add_file_to_support_group(path)
@@ -90,7 +90,11 @@ module Pod
90
90
  path = library.copy_resources_script_path
91
91
  UI.message "- Generating copy resources script at #{UI.path(path)}" do
92
92
  file_accessors = library.pod_targets.map(&:file_accessors).flatten
93
- resources = file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
93
+ resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
94
+ resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILD_DIR}/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/#{name}.bundle" } }.flatten
95
+ resources = []
96
+ resources.concat(resource_paths)
97
+ resources.concat(resource_bundles)
94
98
  resources << bridge_support_file if bridge_support_file
95
99
  generator = Generator::CopyResourcesScript.new(resources, library.platform)
96
100
  generator.save_as(path)
@@ -14,6 +14,7 @@ module Pod
14
14
  UI.message "- Installing target `#{library.name}` #{library.platform}" do
15
15
  add_target
16
16
  add_files_to_build_phases
17
+ add_resources_bundle_targets
17
18
  create_suport_files_group
18
19
  create_xcconfig_file
19
20
  create_prefix_header
@@ -21,10 +22,10 @@ module Pod
21
22
  end
22
23
  end
23
24
 
24
- #-----------------------------------------------------------------------#
25
-
26
25
  private
27
26
 
27
+ #-----------------------------------------------------------------------#
28
+
28
29
  # Adds the build files of the pods to the target and adds a reference to
29
30
  # the frameworks of the Pods.
30
31
  #
@@ -49,20 +50,48 @@ module Pod
49
50
  end
50
51
  end
51
52
 
53
+ # Adds the resources of the Pods to the Pods project.
54
+ #
55
+ # @note The source files are grouped by Pod and in turn by subspec
56
+ # (recursively) in the resources group.
57
+ #
58
+ # @return [void]
59
+ #
60
+ def add_resources_bundle_targets
61
+ UI.message "- Adding resource bundles to Pods project" do
62
+ library.file_accessors.each do |file_accessor|
63
+ file_accessor.resource_bundles.each do |bundle_name, paths|
64
+ file_references = paths.map { |sf| project.file_reference(sf) }
65
+ group = project.group_for_spec(file_accessor.spec.name, :resources)
66
+ product_group = project.group_for_spec(file_accessor.spec.name, :resources)
67
+ bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name, product_group)
68
+ bundle_target.add_resources(file_references)
69
+
70
+ target.add_dependency(bundle_target)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
52
76
  # Generates the contents of the xcconfig file and saves it to disk.
53
77
  #
54
78
  # @return [void]
55
79
  #
56
80
  def create_xcconfig_file
57
81
  path = library.xcconfig_path
58
- public_gen = Generator::PublicPodXCConfig.new(library)
82
+ public_gen = Generator::XCConfig::PublicPodXCConfig.new(library)
59
83
  UI.message "- Generating public xcconfig file at #{UI.path(path)}" do
60
84
  public_gen.save_as(path)
85
+ #
86
+ # TODO
61
87
  add_file_to_support_group(path)
88
+ # relative_path = path.relative_path_from(sandbox.root)
89
+ # group = project.group_for_spec(library.root_spec.name, :support_files)
90
+ # group.new_file(relative_path)
62
91
  end
63
92
 
64
93
  path = library.xcconfig_private_path
65
- private_gen = Generator::PrivatePodXCConfig.new(library, public_gen.xcconfig)
94
+ private_gen = Generator::XCConfig::PrivatePodXCConfig.new(library, public_gen.xcconfig)
66
95
  UI.message "- Generating private xcconfig file at #{UI.path(path)}" do
67
96
  private_gen.save_as(path)
68
97
  xcconfig_file_ref = add_file_to_support_group(path)
@@ -9,16 +9,20 @@ module Pod
9
9
  #
10
10
  class Project < Xcodeproj::Project
11
11
 
12
- # @return [Pathname] the path of the xcodeproj file which stores the
13
- # project.
12
+
13
+ # @return [Sandbox] the sandbox which returns the information about which
14
+ # Pods are local.
14
15
  #
15
- attr_reader :path
16
+ attr_reader :sandbox
16
17
 
17
18
  # @param [Sandbox] sandbox @see #sandbox
18
19
  #
19
- def initialize(path = nil)
20
+ def initialize(sandbox)
20
21
  super(nil) # Recreate the project from scratch for now.
21
- @path = path
22
+ # TODO
23
+ raise unless sandbox.is_a?(Sandbox)
24
+ @sandbox = sandbox
25
+ @path = sandbox.project_path
22
26
  @support_files_group = new_group('Targets Support Files')
23
27
 
24
28
  @refs_by_absolute_path = {}
@@ -107,25 +111,25 @@ module Pod
107
111
  @resources ||= new_group('Resources')
108
112
  end
109
113
 
110
- # Adds a group as child to the `Pods` group namespacing subspecs.
111
- #
112
- # @param [String] spec_name
113
- # The full name of the specification.
114
- #
115
- # @param [PBXGroup] root_group
116
- # The group where to add the specification. Either `Pods` or `Local
117
- # Pods`.
118
- #
114
+
119
115
  # @return [PBXGroup] the group for the spec with the given name.
120
116
  #
121
- def add_spec_group(spec_name, root_group)
122
- current_group = root_group
123
- group = nil
124
- spec_name.split('/').each do |name|
125
- group = current_group[name] || current_group.new_group(name)
126
- current_group = group
117
+ def group_for_spec(spec_name, type = nil)
118
+ local = sandbox.local?(spec_name)
119
+ parent_group = local ? local_pods : pods
120
+ spec_group = add_spec_group(spec_name, parent_group)
121
+ if type
122
+ case type
123
+ when :source_files then sub_group = 'Source Files'
124
+ when :resources then sub_group = 'Resources'
125
+ when :frameworks_and_libraries then sub_group = 'Frameworks & Libraries'
126
+ when :support_files then sub_group = 'Support Files'
127
+ else raise "[BUG]"
128
+ end
129
+ spec_group.find_subpath(sub_group, true)
130
+ else
131
+ spec_group
127
132
  end
128
- group
129
133
  end
130
134
 
131
135
  #-------------------------------------------------------------------------#
@@ -154,7 +158,7 @@ module Pod
154
158
  # @return [void]
155
159
  #
156
160
  def add_file_references(absolute_path, spec_name, parent_group)
157
- group = add_spec_group(spec_name, parent_group)
161
+ group = group_for_spec(spec_name, :source_files)
158
162
  absolute_path.each do |file|
159
163
  existing = file_reference(file)
160
164
  unless existing
@@ -165,6 +169,13 @@ module Pod
165
169
  end
166
170
  end
167
171
 
172
+ # TODO: missing customization for file reference
173
+ #
174
+ def add_file_reference(absolute_path, group)
175
+ ref = group.new_file(relativize(absolute_path))
176
+ @refs_by_absolute_path[absolute_path] = ref
177
+ end
178
+
168
179
  # Returns the file reference for the given absolute file path.
169
180
  #
170
181
  # @param [Pathname,String] absolute_path
@@ -204,6 +215,28 @@ module Pod
204
215
  #
205
216
  attr_reader :refs_by_absolute_path
206
217
 
218
+ # Returns a subgroup of the give group for the given spec creating it if
219
+ # needed.
220
+ #
221
+ # @param [String] spec_name
222
+ # The full name of the specification.
223
+ #
224
+ # @param [PBXGroup] root_group
225
+ # The group where to add the specification. Either `Pods` or `Local
226
+ # Pods`.
227
+ #
228
+ # @return [PBXGroup] the group for the spec with the given name.
229
+ #
230
+ def add_spec_group(spec_name, root_group)
231
+ current_group = root_group
232
+ group = nil
233
+ spec_name.split('/').each do |name|
234
+ group = current_group[name] || current_group.new_group(name)
235
+ current_group = group
236
+ end
237
+ group
238
+ end
239
+
207
240
  #-------------------------------------------------------------------------#
208
241
 
209
242
  end
@@ -21,11 +21,15 @@ module Pod
21
21
  #
22
22
  attr_reader :spec_consumer
23
23
 
24
- # @param [Sandbox::PathList] path_list @see path_list
24
+ # @param [Sandbox::PathList, Pathname] path_list @see path_list
25
25
  # @param [Specification::Consumer] spec_consumer @see spec_consumer
26
26
  #
27
27
  def initialize(path_list, spec_consumer)
28
- @path_list = path_list
28
+ if path_list.is_a?(PathList)
29
+ @path_list = path_list
30
+ else
31
+ @path_list = PathList.new(path_list)
32
+ end
29
33
  @spec_consumer = spec_consumer
30
34
 
31
35
  unless @spec_consumer
@@ -36,7 +40,7 @@ module Pod
36
40
  # @return [Pathname] the directory which contains the files of the Pod.
37
41
  #
38
42
  def root
39
- path_list.root
43
+ path_list.root if path_list
40
44
  end
41
45
 
42
46
  # @return [Specification] the specification.
@@ -54,7 +58,7 @@ module Pod
54
58
  # @return [String] A string suitable for debugging.
55
59
  #
56
60
  def inspect
57
- "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{path_list.root}>"
61
+ "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>"
58
62
  end
59
63
 
60
64
  #-----------------------------------------------------------------------#
@@ -102,6 +106,40 @@ module Pod
102
106
  paths_for_attribute(:preserve_paths, true)
103
107
  end
104
108
 
109
+ # @return [Array<Pathname>] The paths of the framework bundles that come
110
+ # shipped with the Pod.
111
+ #
112
+ def vendored_frameworks
113
+ paths_for_attribute(:vendored_frameworks, true)
114
+ end
115
+
116
+ # @return [Array<Pathname>] The paths of the library bundles that come
117
+ # shipped with the Pod.
118
+ #
119
+ def vendored_libraries
120
+ paths_for_attribute(:vendored_libraries)
121
+ end
122
+
123
+ # @return [Hash{String => Array<Pathname>}] A hash that describes the
124
+ # resource bundles of the Pod. The keys reppresent the name of
125
+ # the bundle while the values the path of the resources.
126
+ #
127
+ def resource_bundles
128
+ result = {}
129
+ spec_consumer.resource_bundles.each do |name, file_patterns|
130
+ paths = expanded_paths(file_patterns, :include_dirs => true)
131
+ result[name] = paths
132
+ end
133
+ result
134
+ end
135
+
136
+ # @return [Array<Pathname>] The paths of the files which should be
137
+ # included in resources bundles by the Pod.
138
+ #
139
+ def resource_bundle_files
140
+ resource_bundles.values.flatten
141
+ end
142
+
105
143
  # @return [Pathname] The of the prefix header file of the specification.
106
144
  #
107
145
  def prefix_header
@@ -159,8 +197,6 @@ module Pod
159
197
  #
160
198
  # @return [String] the glob pattern.
161
199
  #
162
- # @todo Move to the cocoapods-core so it appears in the docs?
163
- #
164
200
  def glob_for_attribute(attrbute)
165
201
  globs = {
166
202
  :source_files => '*.{h,hpp,hh,m,mm,c,cpp}'.freeze,
@@ -185,8 +221,6 @@ module Pod
185
221
  #
186
222
  # @return [Array<Pathname>] A list of the paths.
187
223
  #
188
- # @todo Implement case insensitive search
189
- #
190
224
  def expanded_paths(patterns, options = {})
191
225
  return [] if patterns.empty?
192
226
  result = []