cocoapods 0.33.1 → 0.34.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.
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,6 +1,5 @@
1
1
  module Pod
2
2
  class Sandbox
3
-
4
3
  # Resolves the file patterns of a specification against its root directory,
5
4
  # taking into account any exclude pattern and the default extensions to use
6
5
  # for directories.
@@ -8,7 +7,6 @@ module Pod
8
7
  # @note The FileAccessor always returns absolute paths.
9
8
  #
10
9
  class FileAccessor
11
-
12
10
  HEADER_EXTENSIONS = Xcodeproj::Constants::HEADER_FILES_EXTENSIONS
13
11
 
14
12
  # @return [Sandbox::PathList] the directory where the source of the Pod
@@ -33,7 +31,7 @@ module Pod
33
31
  @spec_consumer = spec_consumer
34
32
 
35
33
  unless @spec_consumer
36
- raise Informative, "Attempt to initialize File Accessor without a specification consumer."
34
+ raise Informative, 'Attempt to initialize File Accessor without a specification consumer.'
37
35
  end
38
36
  end
39
37
 
@@ -151,7 +149,7 @@ module Pod
151
149
  # @return [Pathname] The path of the auto-detected README file.
152
150
  #
153
151
  def readme
154
- path_list.glob(%w[ readme{*,.*} ]).first
152
+ path_list.glob(%w( readme{*,.*} )).first
155
153
  end
156
154
 
157
155
  # @return [Pathname] The path of the license file as indicated in the
@@ -161,7 +159,7 @@ module Pod
161
159
  if spec_consumer.spec.root.license[:file]
162
160
  path_list.root + spec_consumer.spec.root.license[:file]
163
161
  else
164
- path_list.glob(%w[ licen{c,s}e{*,.*} ]).first
162
+ path_list.glob(%w( licen{c,s}e{*,.*} )).first
165
163
  end
166
164
  end
167
165
 
@@ -229,9 +227,6 @@ module Pod
229
227
  end
230
228
 
231
229
  #-----------------------------------------------------------------------#
232
-
233
230
  end
234
231
  end
235
232
  end
236
-
237
-
@@ -1,15 +1,13 @@
1
1
  module Pod
2
2
  class Sandbox
3
-
4
3
  # Provides support for managing a header directory. It also keeps track of
5
4
  # the header search paths.
6
5
  #
7
6
  class HeadersStore
8
-
9
7
  # @return [Pathname] the absolute path of this header directory.
10
8
  #
11
9
  def root
12
- @root ||= @sandbox.root + @relative_path
10
+ sandbox.headers_root + @relative_path
13
11
  end
14
12
 
15
13
  # @return [Sandbox] the sandbox where this header directory is stored.
@@ -33,7 +31,8 @@ module Pod
33
31
  # root with the `${PODS_ROOT}` variable.
34
32
  #
35
33
  def search_paths
36
- @search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
34
+ headers_dir = root.relative_path_from(sandbox.root).dirname
35
+ @search_paths.uniq.map { |path| "${PODS_ROOT}/#{headers_dir}/#{path}" }
37
36
  end
38
37
 
39
38
  # Removes the directory as it is regenerated from scratch during each
@@ -58,7 +57,8 @@ module Pod
58
57
  # headers directory.
59
58
  #
60
59
  # @param [Pathname] relative_header_path
61
- # the path of the header file relative to the sandbox.
60
+ # the path of the header file relative to the Pods project
61
+ # (`PODS_ROOT` variable of the xcconfigs).
62
62
  #
63
63
  # @note This method adds the files to the search paths.
64
64
  #
@@ -70,7 +70,7 @@ module Pod
70
70
  namespaced_path.mkpath unless File.exist?(namespaced_path)
71
71
 
72
72
  relative_header_paths.map do |relative_header_path|
73
- absolute_source = (@sandbox.root + relative_header_path)
73
+ absolute_source = (sandbox.root + relative_header_path)
74
74
  source = absolute_source.relative_path_from(namespaced_path)
75
75
  Dir.chdir(namespaced_path) do
76
76
  FileUtils.ln_sf(source, relative_header_path.basename)
@@ -91,7 +91,6 @@ module Pod
91
91
  end
92
92
 
93
93
  #-----------------------------------------------------------------------#
94
-
95
94
  end
96
95
  end
97
96
  end
@@ -1,6 +1,5 @@
1
1
  module Pod
2
2
  class Sandbox
3
-
4
3
  # The PathList class is designed to perform multiple glob matches against
5
4
  # a given directory. Basically, it generates a list of all the children
6
5
  # paths and matches the globs patterns against them, resulting in just one
@@ -11,7 +10,6 @@ module Pod
11
10
  # {#read_file_system}
12
11
  #
13
12
  class PathList
14
-
15
13
  # @return [Pathname] The root of the list whose files and directories
16
14
  # are used to perform the matching operations.
17
15
  #
@@ -46,15 +44,15 @@ module Pod
46
44
  unless root.exist?
47
45
  raise Informative, "Attempt to read non existent folder `#{root}`."
48
46
  end
49
- root_length = root.to_s.length+1
47
+ root_length = root.to_s.length + 1
50
48
  escaped_root = escape_path_for_glob(root)
51
- paths = Dir.glob(escaped_root + "**/*", File::FNM_DOTMATCH)
49
+ paths = Dir.glob(escaped_root + '**/*', File::FNM_DOTMATCH)
52
50
  absolute_dirs = paths.select { |path| File.directory?(path) }
53
51
  relative_dirs = absolute_dirs.map { |p| p[root_length..-1] }
54
52
  absolute_paths = paths.reject { |p| p == "#{root}/." || p == "#{root}/.." }
55
53
  relative_paths = absolute_paths.map { |p| p[root_length..-1] }
56
54
  @files = relative_paths - relative_dirs
57
- @dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/,'') }.reject { |d| d == '.' || d == '..' } .uniq
55
+ @dirs = relative_dirs.map { |d| d.gsub(/\/\.\.?$/, '') }.reject { |d| d == '.' || d == '..' } .uniq
58
56
  end
59
57
 
60
58
  #-----------------------------------------------------------------------#
@@ -67,7 +65,7 @@ module Pod
67
65
  # paths.
68
66
  #
69
67
  def glob(patterns, options = {})
70
- relative_glob(patterns, options).map {|p| root + p }
68
+ relative_glob(patterns, options).map { |p| root + p }
71
69
  end
72
70
 
73
71
  # @return [Array<Pathname>] The list of relative paths that are case
@@ -164,9 +162,9 @@ module Pod
164
162
  end
165
163
 
166
164
  if values_by_set.empty?
167
- [ pattern ]
165
+ [pattern]
168
166
  else
169
- patterns = [ pattern ]
167
+ patterns = [pattern]
170
168
  values_by_set.each do |set, values|
171
169
  patterns = patterns.map do |old_pattern|
172
170
  values.map do |value|
@@ -192,13 +190,12 @@ module Pod
192
190
  result = path.to_s
193
191
  characters_to_escape = ['[', ']', '{', '}', '?', '*']
194
192
  characters_to_escape.each do |character|
195
- result.gsub!(character, "\\#{character}" )
193
+ result.gsub!(character, "\\#{character}")
196
194
  end
197
195
  Pathname.new(result)
198
196
  end
199
197
 
200
198
  #-----------------------------------------------------------------------#
201
-
202
199
  end
203
200
  end
204
201
  end
@@ -1,32 +1,40 @@
1
1
  module Pod
2
-
3
2
  # Manages all the sources known to the running CocoaPods Instance.
4
3
  #
5
4
  class SourcesManager
6
-
7
5
  class << self
8
-
9
6
  include Config::Mixin
10
7
 
11
- # @return [Source::Aggregate] the aggregate of all the sources known to
12
- # this installation of CocoaPods.
8
+ # @return [Source::Aggregate] The aggregate of all the sources with the
9
+ # known Pods.
13
10
  #
14
11
  def aggregate
15
- Source::Aggregate.new(config.repos_dir)
12
+ dirs = config.repos_dir.children.select(&:directory?)
13
+ Source::Aggregate.new(dirs)
14
+ end
15
+
16
+ # @return [Array<Source>] The list of the sources with the given names.
17
+ #
18
+ # @param [Array<#to_s>] names
19
+ # The names of the sources.
20
+ #
21
+ def sources(names)
22
+ dirs = names.map { |name| source_dir(name) }
23
+ dirs.map { |repo| Source.new(repo) }
16
24
  end
17
25
 
18
- # @return [Array<Source>] the list of all the sources known to this
26
+ # @return [Array<Source>] The list of all the sources known to this
19
27
  # installation of CocoaPods.
20
28
  #
21
29
  def all
22
- aggregate.all
30
+ dirs = config.repos_dir.children.select(&:directory?)
31
+ dirs.map { |repo| Source.new(repo) }
23
32
  end
24
33
 
25
- # @return [Array<Specification::Set>] the list of all the specification
26
- # sets know to this installation of CocoaPods.
34
+ # @return [Source] The CocoaPods Master Repo source.
27
35
  #
28
- def all_sets
29
- aggregate.all_sets
36
+ def master
37
+ sources(['master'])
30
38
  end
31
39
 
32
40
  # Search all the sources to match the set for the given dependency.
@@ -71,13 +79,16 @@ module Pod
71
79
  end
72
80
  set_names << name unless texts.grep(query_regexp).empty?
73
81
  end
74
- sets = set_names.sort.map { |name| aggregate.representative_set(name) }
82
+ sets = set_names.sort.map do |name|
83
+ aggregate.representative_set(name)
84
+ end
75
85
  else
76
86
  sets = aggregate.search_by_name(query, false)
77
87
  end
78
88
  if sets.empty?
79
- extra = ", author, summary, or description" if full_text_search
80
- raise Informative, "Unable to find a pod with name#{extra} matching `#{query}`"
89
+ extra = ', author, summary, or description' if full_text_search
90
+ raise Informative, "Unable to find a pod with name#{extra}" \
91
+ "matching `#{query}`"
81
92
  end
82
93
  sets
83
94
  end
@@ -108,7 +119,9 @@ module Pod
108
119
  search_index = aggregate.generate_search_index
109
120
  end
110
121
 
111
- File.open(search_index_path, 'w') {|f| f.write(search_index.to_yaml) }
122
+ File.open(search_index_path, 'w') do |file|
123
+ file.write(search_index.to_yaml)
124
+ end
112
125
  @updated_search_index = search_index
113
126
  end
114
127
  @updated_search_index
@@ -124,10 +137,7 @@ module Pod
124
137
  Config.instance.search_index_file
125
138
  end
126
139
 
127
- public
128
-
129
140
  # @!group Updating Sources
130
- #-----------------------------------------------------------------------#
131
141
 
132
142
  extend Executable
133
143
  executable :git
@@ -141,23 +151,22 @@ module Pod
141
151
  #
142
152
  def update(source_name = nil, show_output = false)
143
153
  if source_name
144
- specified_source = aggregate.all.find { |s| s.name == source_name }
145
- raise Informative, "Unable to find the `#{source_name}` repo." unless specified_source
146
- raise Informative, "The `#{source_name}` repo is not a git repo." unless git_repo?(specified_source.data_provider.repo)
147
- sources = [specified_source]
154
+ sources = [git_source_named(source_name)]
148
155
  else
149
- sources = aggregate.all.select { |source| git_repo?(source.data_provider.repo) && git_remote_reachable?(source.data_provider.repo) }
156
+ sources = git_sources
150
157
  end
151
158
 
152
159
  sources.each do |source|
153
160
  UI.section "Updating spec repo `#{source.name}`" do
154
161
  Dir.chdir(source.data_provider.repo) do
155
162
  begin
156
- output = git!("pull --ff-only")
163
+ output = git!('pull --ff-only')
157
164
  UI.puts output if show_output && !config.verbose?
158
165
  rescue Informative => e
159
- raise Informative, 'An error occurred while performing ' \
160
- "`git pull` on repo `#{source.name}`.\n" + e.message
166
+ UI.warn 'CocoaPods was not able to update the ' \
167
+ "`#{source.name}` repo. If this is an unexpected issue " \
168
+ 'and persists you can inspect it running ' \
169
+ '`pod repo update --verbose`'
161
170
  end
162
171
  end
163
172
  check_version_information(source.data_provider.repo)
@@ -165,18 +174,6 @@ module Pod
165
174
  end
166
175
  end
167
176
 
168
- # Returns whether a git repo's remote is reachable.
169
- #
170
- # @param [Pathname] dir
171
- # The directory where the source is stored.
172
- #
173
- # @return [Bool] Whether the given source's remote is reachable.
174
- #
175
- def git_remote_reachable?(dir)
176
- Dir.chdir(dir) { git('ls-remote') }
177
- $?.success?
178
- end
179
-
180
177
  # Returns whether a source is a GIT repo.
181
178
  #
182
179
  # @param [Pathname] dir
@@ -204,10 +201,10 @@ module Pod
204
201
  versions = version_information(dir)
205
202
  unless repo_compatible?(dir)
206
203
  min, max = versions['min'], versions['max']
207
- version_msg = ( min == max ) ? min : "#{min} - #{max}"
204
+ version_msg = ( min == max) ? min : "#{min} - #{max}"
208
205
  raise Informative, "The `#{dir.basename}` repo requires " \
209
206
  "CocoaPods #{version_msg} (currently using #{Pod::VERSION})\n".red +
210
- "Update CocoaPods, or checkout the appropriate tag in the repo."
207
+ 'Update CocoaPods, or checkout the appropriate tag in the repo.'
211
208
  end
212
209
 
213
210
  needs_sudo = path_writable?(__FILE__)
@@ -269,8 +266,7 @@ module Pod
269
266
  yaml_file = dir + 'CocoaPods-version.yml'
270
267
  return {} unless yaml_file.exist?
271
268
  begin
272
- yaml = Pathname.new(yaml_file).read
273
- YAMLHelper.load(yaml)
269
+ YAMLHelper.load_file(yaml_file)
274
270
  rescue Informative => e
275
271
  raise Informative, "There was an error reading '#{yaml_file}'.\n" \
276
272
  'Please consult http://blog.cocoapods.org/' \
@@ -279,10 +275,7 @@ module Pod
279
275
  end
280
276
  end
281
277
 
282
- public
283
-
284
278
  # @!group Master repo
285
- #-----------------------------------------------------------------------#
286
279
 
287
280
  # @return [Pathname] The path of the master repo.
288
281
  #
@@ -299,15 +292,54 @@ module Pod
299
292
  master_repo_dir.exist? && repo_compatible?(master_repo_dir)
300
293
  end
301
294
 
302
- #-----------------------------------------------------------------------#
303
-
304
295
  private
305
296
 
297
+ # @return [Bool] Whether the given path is writable by the current user.
298
+ #
299
+ # @param [#to_s] path
300
+ # The path.
301
+ #
306
302
  def path_writable?(path)
307
303
  Pathname(path).dirname.writable?
308
304
  end
309
305
 
306
+ # @return [Source] The git source with the given name. If no git source
307
+ # with given name is found it raises.
308
+ #
309
+ # @param [String] name
310
+ # The name of the source.
311
+ #
312
+ def git_source_named(name)
313
+ specified_source = aggregate.sources.find { |s| s.name == name }
314
+ unless specified_source
315
+ raise Informative, "Unable to find the `#{name}` repo."
316
+ end
317
+ unless git_repo?(specified_source.data_provider.repo)
318
+ raise Informative, "The `#{name}` repo is not a git repo."
319
+ end
320
+ specified_source
321
+ end
322
+
323
+ # @return [Source] The list of the git sources.
324
+ #
325
+ def git_sources
326
+ all.select do |source|
327
+ git_repo?(source.data_provider.repo)
328
+ end
329
+ end
330
+
331
+ # @return [Pathname] The path of the source with the given name.
332
+ #
333
+ # @param [String] name
334
+ # The name of the source.
335
+ #
336
+ def source_dir(name)
337
+ if dir = config.repos_dir + name
338
+ dir
339
+ else
340
+ raise Informative, "Unable to find the `#{name}` repo."
341
+ end
342
+ end
310
343
  end
311
344
  end
312
345
  end
313
-
@@ -1,5 +1,4 @@
1
1
  module Pod
2
-
3
2
  # Model class which describes a Pods target.
4
3
  #
5
4
  # The Target class stores and provides the information necessary for
@@ -7,7 +6,6 @@ module Pod
7
6
  # This class is used to represent both the targets and their libraries.
8
7
  #
9
8
  class Target
10
-
11
9
  # @return [PBXNativeTarget] the target definition of the Podfile that
12
10
  # generated this target.
13
11
  #
@@ -73,48 +71,56 @@ module Pod
73
71
  # @return [Pathname] the folder where to store the support files of this
74
72
  # library.
75
73
  #
76
- def support_files_root
77
- @sandbox.library_support_files_dir(name)
74
+ def support_files_dir
75
+ sandbox.target_support_files_dir(name)
78
76
  end
79
77
 
78
+ # @param [String] variant
79
+ # The variant of the xcconfig. Used to differentiate build
80
+ # configurations.
81
+ #
80
82
  # @return [Pathname] the absolute path of the xcconfig file.
81
83
  #
82
- def xcconfig_path
83
- support_files_root + "#{label}.xcconfig"
84
+ def xcconfig_path(variant = nil)
85
+ if variant
86
+ support_files_dir + "#{label}.#{variant.downcase}.xcconfig"
87
+ else
88
+ support_files_dir + "#{label}.xcconfig"
89
+ end
84
90
  end
85
91
 
86
92
  # @return [Pathname] the absolute path of the private xcconfig file.
87
93
  #
88
94
  def xcconfig_private_path
89
- support_files_root + "#{label}-Private.xcconfig"
95
+ support_files_dir + "#{label}-Private.xcconfig"
90
96
  end
91
97
 
92
98
  # @return [Pathname] the absolute path of the header file which contains
93
99
  # the information about the installed pods.
94
100
  #
95
101
  def target_environment_header_path
96
- support_files_root + "#{target_definition.label.to_s}-environment.h"
102
+ name = target_definition.label
103
+ sandbox.target_support_files_dir(name) + "#{name}-environment.h"
97
104
  end
98
105
 
99
106
  # @return [Pathname] the absolute path of the prefix header file.
100
107
  #
101
108
  def prefix_header_path
102
- support_files_root + "#{label}-prefix.pch"
109
+ support_files_dir + "#{label}-prefix.pch"
103
110
  end
104
111
 
105
112
  # @return [Pathname] the absolute path of the bridge support file.
106
113
  #
107
114
  def bridge_support_path
108
- support_files_root + "#{label}.bridgesupport"
115
+ support_files_dir + "#{label}.bridgesupport"
109
116
  end
110
117
 
111
118
  # @return [Pathname] the path of the dummy source generated by CocoaPods
112
119
  #
113
120
  def dummy_source_path
114
- support_files_root + "#{label}-dummy.m"
121
+ support_files_dir + "#{label}-dummy.m"
115
122
  end
116
123
 
117
124
  #-------------------------------------------------------------------------#
118
-
119
125
  end
120
126
  end