cocoapods 0.16.4 → 0.17.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +108 -0
  3. data/README.md +3 -3
  4. data/bin/pod +1 -1
  5. data/lib/cocoapods.rb +31 -31
  6. data/lib/cocoapods/command.rb +62 -107
  7. data/lib/cocoapods/command/inter_process_communication.rb +103 -0
  8. data/lib/cocoapods/command/list.rb +45 -44
  9. data/lib/cocoapods/command/outdated.rb +28 -25
  10. data/lib/cocoapods/command/project.rb +90 -0
  11. data/lib/cocoapods/command/push.rb +50 -32
  12. data/lib/cocoapods/command/repo.rb +125 -155
  13. data/lib/cocoapods/command/search.rb +23 -12
  14. data/lib/cocoapods/command/setup.rb +103 -64
  15. data/lib/cocoapods/command/spec.rb +329 -90
  16. data/lib/cocoapods/config.rb +197 -44
  17. data/lib/cocoapods/downloader.rb +47 -34
  18. data/lib/cocoapods/executable.rb +98 -41
  19. data/lib/cocoapods/external_sources.rb +325 -0
  20. data/lib/cocoapods/file_list.rb +8 -1
  21. data/lib/cocoapods/gem_version.rb +7 -0
  22. data/lib/cocoapods/generator/acknowledgements.rb +71 -7
  23. data/lib/cocoapods/generator/acknowledgements/markdown.rb +10 -9
  24. data/lib/cocoapods/generator/acknowledgements/plist.rb +9 -8
  25. data/lib/cocoapods/generator/copy_resources_script.rb +2 -2
  26. data/lib/cocoapods/generator/documentation.rb +153 -37
  27. data/lib/cocoapods/generator/prefix_header.rb +82 -0
  28. data/lib/cocoapods/generator/target_header.rb +58 -0
  29. data/lib/cocoapods/generator/xcconfig.rb +130 -0
  30. data/lib/cocoapods/hooks/installer_representation.rb +123 -0
  31. data/lib/cocoapods/hooks/library_representation.rb +79 -0
  32. data/lib/cocoapods/hooks/pod_representation.rb +74 -0
  33. data/lib/cocoapods/installer.rb +398 -147
  34. data/lib/cocoapods/installer/analyzer.rb +556 -0
  35. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +253 -0
  36. data/lib/cocoapods/installer/file_references_installer.rb +179 -0
  37. data/lib/cocoapods/installer/pod_source_installer.rb +289 -0
  38. data/lib/cocoapods/installer/target_installer.rb +307 -112
  39. data/lib/cocoapods/installer/user_project_integrator.rb +140 -176
  40. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +193 -0
  41. data/lib/cocoapods/library.rb +195 -0
  42. data/lib/cocoapods/open_uri.rb +16 -14
  43. data/lib/cocoapods/project.rb +175 -52
  44. data/lib/cocoapods/resolver.rb +151 -164
  45. data/lib/cocoapods/sandbox.rb +276 -54
  46. data/lib/cocoapods/sandbox/file_accessor.rb +210 -0
  47. data/lib/cocoapods/sandbox/headers_store.rb +96 -0
  48. data/lib/cocoapods/sandbox/path_list.rb +178 -0
  49. data/lib/cocoapods/sources_manager.rb +218 -0
  50. data/lib/cocoapods/user_interface.rb +82 -18
  51. data/lib/cocoapods/{command → user_interface}/error_report.rb +5 -5
  52. data/lib/cocoapods/validator.rb +379 -0
  53. metadata +74 -55
  54. data/lib/cocoapods/command/install.rb +0 -55
  55. data/lib/cocoapods/command/linter.rb +0 -317
  56. data/lib/cocoapods/command/update.rb +0 -25
  57. data/lib/cocoapods/dependency.rb +0 -285
  58. data/lib/cocoapods/downloader/git.rb +0 -276
  59. data/lib/cocoapods/downloader/http.rb +0 -99
  60. data/lib/cocoapods/downloader/mercurial.rb +0 -26
  61. data/lib/cocoapods/downloader/subversion.rb +0 -42
  62. data/lib/cocoapods/local_pod.rb +0 -620
  63. data/lib/cocoapods/lockfile.rb +0 -274
  64. data/lib/cocoapods/platform.rb +0 -127
  65. data/lib/cocoapods/podfile.rb +0 -551
  66. data/lib/cocoapods/source.rb +0 -223
  67. data/lib/cocoapods/specification.rb +0 -579
  68. data/lib/cocoapods/specification/set.rb +0 -175
  69. data/lib/cocoapods/specification/statistics.rb +0 -112
  70. data/lib/cocoapods/user_interface/ui_pod.rb +0 -130
  71. data/lib/cocoapods/version.rb +0 -26
@@ -0,0 +1,195 @@
1
+ module Pod
2
+
3
+ # Model class which describes a Pods library.
4
+ #
5
+ # The Library class stores and provides the information necessary for
6
+ # working with a library in the Pods project and in the user projects
7
+ # through the installation process.
8
+ #
9
+ class Library
10
+
11
+ # @return [PBXNativeTarget] the target definition of the Podfile that
12
+ # generated this library.
13
+ #
14
+ attr_reader :target_definition
15
+
16
+ # @param [TargetDefinition] target_definition @see target_definition
17
+ # @param [PBXNativeTarget] target @see target
18
+ #
19
+ def initialize(target_definition)
20
+ @target_definition = target_definition
21
+ end
22
+
23
+ # @return [String] the label for the library.
24
+ #
25
+ def label
26
+ target_definition.label.to_s
27
+ end
28
+
29
+ # @return [String] the name of the library.
30
+ #
31
+ def name
32
+ target_definition.label.to_s
33
+ end
34
+
35
+ # @return [String] the name of the library.
36
+ #
37
+ def product_name
38
+ "lib#{target_definition.label}.a"
39
+ end
40
+
41
+ # @return [String] A string suitable for debugging.
42
+ #
43
+ def inspect
44
+ "<#{self.class} name=#{name} platform=#{platform}>"
45
+ end
46
+
47
+ #-------------------------------------------------------------------------#
48
+
49
+ # @!group Information storage
50
+
51
+ # @return [Pathname] the folder where to store the support files of this
52
+ # library.
53
+ #
54
+ attr_accessor :support_files_root
55
+
56
+ # @return [Pathname] the path of the user project that this library will
57
+ # integrate as identified by the analyzer.
58
+ #
59
+ # @note The project instance is not stored to prevent editing different
60
+ # instances.
61
+ #
62
+ attr_accessor :user_project_path
63
+
64
+ # @return [String] the list of the UUIDs of the user targets that will be
65
+ # integrated by this library as identified by the analizer.
66
+ #
67
+ # @note The target instances are not stored to prevent editing different
68
+ # instances.
69
+ #
70
+ attr_accessor :user_target_uuids
71
+
72
+ # @return [Hash{String=>Symbol}] A hash representing the user build
73
+ # configurations where each key corresponds to the name of a
74
+ # configuration and its value to its type (`:debug` or `:release`).
75
+ #
76
+ attr_accessor :user_build_configurations
77
+
78
+ # @return [Platform] the platform for this library.
79
+ #
80
+ attr_accessor :platform
81
+
82
+ # @return [PBXNativeTarget] the target generated in the Pods project for
83
+ # this library.
84
+ #
85
+ attr_accessor :target
86
+
87
+ # @return [Xcodeproj::Config] the configuration file of the library
88
+ #
89
+ # @note The configuration is generated by the {TargetInstaller} and
90
+ # used by {UserProjectIntegrator} to check for any overridden
91
+ # values.
92
+ #
93
+ attr_accessor :xcconfig
94
+
95
+ # @return [Array<Specification>] the specifications of this library.
96
+ #
97
+ attr_accessor :specs
98
+
99
+ # @return [Array<Sandbox::FileAccessor>] the file accessors for the
100
+ # specifications of this library.
101
+ #
102
+ attr_accessor :file_accessors
103
+
104
+ #-------------------------------------------------------------------------#
105
+
106
+ # @!group Support files
107
+
108
+ # @return [Pathname] the absolute path of the xcconfig file.
109
+ #
110
+ def xcconfig_path
111
+ support_files_root + "#{label}.xcconfig"
112
+ end
113
+
114
+ # @return [Pathname] the absolute path of the copy resources script.
115
+ #
116
+ def copy_resources_script_path
117
+ support_files_root + "#{label}-resources.sh"
118
+ end
119
+
120
+ # @return [Pathname] the absolute path of the header file which contains
121
+ # the information about the installed pods.
122
+ #
123
+ def target_header_path
124
+ support_files_root + "#{label}-header.h"
125
+ end
126
+
127
+ # @return [Pathname] the absolute path of the prefix header file.
128
+ #
129
+ def prefix_header_path
130
+ support_files_root + "#{label}-prefix.pch"
131
+ end
132
+
133
+ # @return [Pathname] the absolute path of the bridge support file.
134
+ #
135
+ def bridge_support_path
136
+ support_files_root + "#{label}.bridgesupport"
137
+ end
138
+
139
+ # @return [Pathname] the absolute path of acknowledgements file.
140
+ #
141
+ # @note The acknowledgements generators add the extension according to
142
+ # the file type.
143
+ #
144
+ def acknowledgements_basepath
145
+ support_files_root + "#{label}-acknowledgements"
146
+ end
147
+
148
+ # @return [Pathname] the path of the dummy source generated by CocoaPods
149
+ #
150
+ def dummy_source_path
151
+ support_files_root + "#{label}-dummy.m"
152
+ end
153
+
154
+ #--------------------------------------#
155
+
156
+ # @return [String] The xcconfig path of the root from the `$(SRCROOT)`
157
+ # variable of the user's project.
158
+ #
159
+ def relative_pods_root
160
+ "${SRCROOT}/#{support_files_root.relative_path_from(user_project_path.dirname)}"
161
+ end
162
+
163
+ # @return [String] the path of the xcconfig file relative to the root of
164
+ # the user project.
165
+ #
166
+ def xcconfig_relative_path
167
+ relative_to_srcroot(xcconfig_path).to_s
168
+ end
169
+
170
+ # @return [String] the path of the copy resources script relative to the
171
+ # root of the user project.
172
+ #
173
+ def copy_resources_script_relative_path
174
+ "${SRCROOT}/#{relative_to_srcroot(copy_resources_script_path)}"
175
+ end
176
+
177
+ #-------------------------------------------------------------------------#
178
+
179
+ # @!group Private Helpers
180
+
181
+ private
182
+
183
+ # Computes the relative path of a sandboxed file from the `$(SRCROOT)`
184
+ # variable of the user's project.
185
+ #
186
+ # @param [Pathname] path
187
+ # A relative path from the root of the sandbox.
188
+ #
189
+ # @return [String] the computed path.
190
+ #
191
+ def relative_to_srcroot(path)
192
+ path.relative_path_from(user_project_path.dirname).to_s
193
+ end
194
+ end
195
+ end
@@ -1,21 +1,23 @@
1
1
  require 'open-uri'
2
2
 
3
- # Inspiration from: https://gist.github.com/1271420
3
+ # Allow OpenURI to follow http to https redirects.
4
4
  #
5
- # Allow open-uri to follow http to https redirects.
6
- # Relevant issue:
7
- # http://redmine.ruby-lang.org/issues/3719
8
- # Source here:
9
- # https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
10
-
11
5
  module OpenURI
12
- def OpenURI.redirectable?(uri1, uri2) # :nodoc:
13
- # This test is intended to forbid a redirection from http://... to
14
- # file:///etc/passwd, file:///dev/zero, etc. CVE-2011-1521
15
- # https to http redirect is also forbidden intentionally.
16
- # It avoids sending secure cookie or referer by non-secure HTTP protocol.
17
- # (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3)
18
- # However this is ad hoc. It should be extensible/configurable.
6
+
7
+ # Whether {#open} should follow a redirect.
8
+ #
9
+ # Inspiration from: https://gist.github.com/1271420
10
+ # Relevant issue: http://redmine.ruby-lang.org/issues/3719
11
+ # Source here: https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
12
+ #
13
+ # This test is intended to forbid a redirection from http://... to
14
+ # file:///etc/passwd, file:///dev/zero, etc. CVE-2011-1521
15
+ # https to http redirect is also forbidden intentionally.
16
+ # It avoids sending secure cookie or referrer by non-secure HTTP protocol.
17
+ # (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3)
18
+ # However this is ad hoc. It should be extensible/configurable.
19
+ #
20
+ def OpenURI.redirectable?(uri1, uri2)
19
21
  uri1.scheme.downcase == uri2.scheme.downcase ||
20
22
  (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme)
21
23
  end
@@ -1,86 +1,209 @@
1
1
  require 'xcodeproj'
2
2
 
3
- # Xcodeproj::Project::Object::PBXCopyFilesBuildPhase.instance_eval do
4
- # def self.new_pod_dir(project, pod_name, path)
5
- # new(project, nil, {
6
- # "dstPath" => "Pods/#{path}",
7
- # "name" => "Copy #{pod_name} Public Headers",
8
- # })
9
- # end
10
- # end
11
-
12
3
  module Pod
4
+
5
+ # The Pods project.
6
+ #
7
+ # Model class which provides helpers for working with the Pods project
8
+ # through the installation process.
9
+ #
13
10
  class Project < Xcodeproj::Project
14
11
 
15
- attr_reader :support_files_group
12
+ # @return [Pathname] the path of the xcodeproj file which stores the
13
+ # project.
14
+ #
15
+ attr_reader :path
16
16
 
17
- def initialize(*)
18
- super
19
- new_group('Pods')
17
+ # @param [Sandbox] sandbox @see #sandbox
18
+ #
19
+ def initialize(path = nil)
20
+ super(nil) # Recreate the project from scratch for now.
21
+ @path = path
20
22
  @support_files_group = new_group('Targets Support Files')
21
- @user_build_configurations = []
23
+
24
+ @refs_by_absolute_path = {}
22
25
  end
23
26
 
24
- def user_build_configurations=(user_build_configurations)
25
- @user_build_configurations = user_build_configurations
26
- # The configurations at the top level only need to exist, they don't hold
27
- # any build settings themselves, that's left to `add_pod_target`.
28
- user_build_configurations.each do |name, _|
29
- unless build_configurations.map(&:name).include?(name)
30
- bc = new(XCBuildConfiguration)
31
- bc.name = name
32
- build_configurations << bc
33
- end
27
+ # @return [Pathname] the path of the xcodeproj file which stores the
28
+ # project.
29
+ #
30
+ attr_reader :path
31
+
32
+ # @return [Pathname] the directory where the project is stored.
33
+ #
34
+ def root
35
+ @root ||= path.dirname
36
+ end
37
+
38
+ # @return [Pathname] Returns the relative path from the project root.
39
+ #
40
+ # @param [Pathname] path
41
+ # The path that needs to be converted to the relative format.
42
+ #
43
+ # @note If the two absolute paths don't share the same root directory an
44
+ # extra `../` is added to the result of
45
+ # {Pathname#relative_path_from}.
46
+ #
47
+ # @example
48
+ #
49
+ # path = Pathname.new('/Users/dir')
50
+ # @sandbox.root #=> Pathname('/tmp/CocoaPods/Lint/Pods')
51
+ #
52
+ # @sandbox.relativize(path) #=> '../../../../Users/dir'
53
+ # @sandbox.relativize(path) #=> '../../../../../Users/dir'
54
+ #
55
+ def relativize(path)
56
+ unless path.absolute?
57
+ raise StandardError, "[Bug] Attempt to add relative path `#{path}` to the Pods project"
34
58
  end
59
+
60
+ result = path.relative_path_from(root)
61
+ unless root.to_s.split('/')[1] == path.to_s.split('/')[1]
62
+ result = Pathname.new('../') + result
63
+ end
64
+ result
65
+ end
66
+
67
+ # @return [String] a string representation suited for debugging.
68
+ #
69
+ def inspect
70
+ "#<#{self.class}> path:#{path}"
35
71
  end
36
72
 
37
- # Shortcut access to the `Pods' PBXGroup.
73
+ #-------------------------------------------------------------------------#
74
+
75
+ public
76
+
77
+ # @!group Groups
78
+
79
+ # @return [PBXGroup] the group where the support files for the Pod
80
+ # libraries should be added.
81
+ #
82
+ attr_reader :support_files_group
83
+
84
+ # Returns the `Pods` group, creating it if needed.
85
+ #
86
+ # @return [PBXGroup] the group.
87
+ #
38
88
  def pods
39
- @pods ||= self['Pods'] || new_group('Pods')
89
+ @pods ||= new_group('Pods')
40
90
  end
41
91
 
42
- # Shortcut access to the `Local Pods' PBXGroup.
92
+ # Returns the `Local Pods` group, creating it if needed. This group is used
93
+ # to contain locally sourced pods.
94
+ #
95
+ # @return [PBXGroup] the group.
96
+ #
43
97
  def local_pods
44
- @local_pods ||= self['Local Pods'] || new_group('Local Pods')
98
+ @local_pods ||= new_group('Local Pods')
99
+ end
100
+
101
+ # Returns the `Local Pods` group, creating it if needed. This group is used
102
+ # to contain locally sourced pods.
103
+ #
104
+ # @return [PBXGroup] the group.
105
+ #
106
+ def resources
107
+ @resources ||= new_group('Resources')
45
108
  end
46
109
 
47
- # Adds a group as child to the `Pods' group namespacing subspecs.
48
- def add_spec_group(name, parent_group)
49
- current_group = parent_group
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
+ #
119
+ # @return [PBXGroup] the group for the spec with the given name.
120
+ #
121
+ def add_spec_group(spec_name, root_group)
122
+ current_group = root_group
50
123
  group = nil
51
- name.split('/').each do |name|
124
+ spec_name.split('/').each do |name|
52
125
  group = current_group[name] || current_group.new_group(name)
53
126
  current_group = group
54
127
  end
55
128
  group
56
129
  end
57
130
 
58
- def add_pod_target(name, platform)
59
- target = new_target(:static_library, name, platform.name)
60
-
61
- settings = {}
62
- if platform.requires_legacy_ios_archs?
63
- settings['ARCHS'] = "armv6 armv7"
64
- end
131
+ #-------------------------------------------------------------------------#
65
132
 
66
- if platform.deployment_target
67
- settings[platform.deployment_target_setting_name] = platform.deployment_target.to_s
68
- end
133
+ public
69
134
 
70
- target.build_settings('Debug').merge!(settings)
71
- target.build_settings('Release').merge!(settings)
135
+ # @!group File references
72
136
 
73
- @user_build_configurations.each do |name, type|
74
- unless target.build_configurations.map(&:name).include?(name)
75
- bc = new(XCBuildConfiguration)
76
- bc.name = name
77
- target.build_configurations << bc
78
- # Copy the settings from either the Debug or the Release configuration.
79
- bc.build_settings = target.build_settings(type.to_s.capitalize).merge(settings)
137
+ # Adds a file reference for each one of the given files in the specified
138
+ # group, namespaced by specification unless a file reference for the given
139
+ # path already exits.
140
+ #
141
+ # @note With this set-up different subspecs might not reference the same
142
+ # file (i.e. the first will win). Not sure thought if this is a
143
+ # limitation or a feature.
144
+ #
145
+ # @param [Array<Pathname,String>] paths
146
+ # The files for which the file reference is needed.
147
+ #
148
+ # @param [String] spec_name
149
+ # The full name of the specification.
150
+ #
151
+ # @param [PBXGroup] parent_group
152
+ # The group where the file references should be added.
153
+ #
154
+ # @return [void]
155
+ #
156
+ def add_file_references(absolute_path, spec_name, parent_group)
157
+ group = add_spec_group(spec_name, parent_group)
158
+ absolute_path.each do |file|
159
+ existing = file_reference(file)
160
+ unless existing
161
+ file = Pathname.new(file)
162
+ ref = group.new_file(relativize(file))
163
+ @refs_by_absolute_path[file] = ref
80
164
  end
81
165
  end
166
+ end
82
167
 
83
- target
168
+ # Returns the file reference for the given absolute file path.
169
+ #
170
+ # @param [Pathname,String] absolute_path
171
+ # The absolute path of the file whose reference is needed.
172
+ #
173
+ # @return [PBXFileReference] The file reference.
174
+ # @return [Nil] If no file reference could be found.
175
+ #
176
+ def file_reference(absolute_path)
177
+ absolute_path = Pathname.new(absolute_path)
178
+ refs_by_absolute_path[absolute_path]
84
179
  end
180
+
181
+ # Adds a file reference to the podfile.
182
+ #
183
+ # @param [Pathname,String] podfile_path
184
+ # the path of the podfile
185
+ #
186
+ # @return [PBXFileReference] the file reference.
187
+ #
188
+ def add_podfile(podfile_path)
189
+ podfile_path = Pathname.new(podfile_path)
190
+ podfile_ref = new_file(relativize(podfile_path))
191
+ podfile_ref.xc_language_specification_identifier = 'xcode.lang.ruby'
192
+ podfile_ref
193
+ end
194
+
195
+ #-------------------------------------------------------------------------#
196
+
197
+ private
198
+
199
+ # @!group Private helpers
200
+
201
+ # @return [Hash{Pathname => PBXFileReference}] The file references grouped
202
+ # by absolute path.
203
+ #
204
+ attr_reader :refs_by_absolute_path
205
+
206
+ #-------------------------------------------------------------------------#
207
+
85
208
  end
86
209
  end