cocoapods-square-stable 0.19.3
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1296 -0
- data/LICENSE +20 -0
- data/README.md +94 -0
- data/bin/pod +16 -0
- data/bin/sandbox-pod +120 -0
- data/lib/cocoapods.rb +77 -0
- data/lib/cocoapods/command.rb +116 -0
- data/lib/cocoapods/command/help.rb +23 -0
- data/lib/cocoapods/command/inter_process_communication.rb +178 -0
- data/lib/cocoapods/command/list.rb +77 -0
- data/lib/cocoapods/command/outdated.rb +56 -0
- data/lib/cocoapods/command/podfile_info.rb +91 -0
- data/lib/cocoapods/command/project.rb +88 -0
- data/lib/cocoapods/command/push.rb +172 -0
- data/lib/cocoapods/command/repo.rb +145 -0
- data/lib/cocoapods/command/search.rb +61 -0
- data/lib/cocoapods/command/setup.rb +134 -0
- data/lib/cocoapods/command/spec.rb +590 -0
- data/lib/cocoapods/config.rb +231 -0
- data/lib/cocoapods/downloader.rb +59 -0
- data/lib/cocoapods/executable.rb +118 -0
- data/lib/cocoapods/external_sources.rb +363 -0
- data/lib/cocoapods/file_list.rb +36 -0
- data/lib/cocoapods/gem_version.rb +7 -0
- data/lib/cocoapods/generator/acknowledgements.rb +107 -0
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +40 -0
- data/lib/cocoapods/generator/acknowledgements/plist.rb +64 -0
- data/lib/cocoapods/generator/bridge_support.rb +22 -0
- data/lib/cocoapods/generator/copy_resources_script.rb +54 -0
- data/lib/cocoapods/generator/dummy_source.rb +22 -0
- data/lib/cocoapods/generator/prefix_header.rb +82 -0
- data/lib/cocoapods/generator/target_environment_header.rb +86 -0
- data/lib/cocoapods/generator/xcconfig.rb +185 -0
- data/lib/cocoapods/hooks/installer_representation.rb +134 -0
- data/lib/cocoapods/hooks/library_representation.rb +94 -0
- data/lib/cocoapods/hooks/pod_representation.rb +74 -0
- data/lib/cocoapods/installer.rb +571 -0
- data/lib/cocoapods/installer/analyzer.rb +559 -0
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +253 -0
- data/lib/cocoapods/installer/file_references_installer.rb +179 -0
- data/lib/cocoapods/installer/pod_source_installer.rb +248 -0
- data/lib/cocoapods/installer/target_installer.rb +379 -0
- data/lib/cocoapods/installer/user_project_integrator.rb +180 -0
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +224 -0
- data/lib/cocoapods/library.rb +202 -0
- data/lib/cocoapods/open_uri.rb +24 -0
- data/lib/cocoapods/project.rb +209 -0
- data/lib/cocoapods/resolver.rb +212 -0
- data/lib/cocoapods/sandbox.rb +343 -0
- data/lib/cocoapods/sandbox/file_accessor.rb +217 -0
- data/lib/cocoapods/sandbox/headers_store.rb +96 -0
- data/lib/cocoapods/sandbox/path_list.rb +208 -0
- data/lib/cocoapods/sources_manager.rb +276 -0
- data/lib/cocoapods/user_interface.rb +304 -0
- data/lib/cocoapods/user_interface/error_report.rb +101 -0
- data/lib/cocoapods/validator.rb +350 -0
- metadata +238 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Installer
|
5
|
+
class UserProjectIntegrator
|
6
|
+
|
7
|
+
# This class is responsible for integrating the library generated by a
|
8
|
+
# {TargetDefinition} with its destination project.
|
9
|
+
#
|
10
|
+
class TargetIntegrator
|
11
|
+
|
12
|
+
# @return [Library] the library that should be integrated.
|
13
|
+
#
|
14
|
+
attr_reader :library
|
15
|
+
|
16
|
+
# @param [Library] library @see #target_definition
|
17
|
+
#
|
18
|
+
def initialize(library)
|
19
|
+
@library = library
|
20
|
+
end
|
21
|
+
|
22
|
+
# Integrates the user project targets. Only the targets that do **not**
|
23
|
+
# already have the Pods library in their frameworks build phase are
|
24
|
+
# processed.
|
25
|
+
#
|
26
|
+
# @return [void]
|
27
|
+
#
|
28
|
+
def integrate!
|
29
|
+
return if targets.empty?
|
30
|
+
UI.section(integration_message) do
|
31
|
+
add_xcconfig_base_configuration
|
32
|
+
add_pods_library
|
33
|
+
add_copy_resources_script_phase
|
34
|
+
add_check_manifest_lock_script_phase
|
35
|
+
save_user_project
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Array<PBXNativeTarget>] the list of targets that the Pods
|
40
|
+
# lib that need to be integrated.
|
41
|
+
#
|
42
|
+
# @note A target is considered integrated if it already references
|
43
|
+
#
|
44
|
+
def targets
|
45
|
+
unless @targets
|
46
|
+
target_uuids = library.user_target_uuids
|
47
|
+
targets = target_uuids.map do |uuid|
|
48
|
+
target = user_project.objects_by_uuid[uuid]
|
49
|
+
unless target
|
50
|
+
raise Informative, "[Bug] Unable to find the target with " \
|
51
|
+
"the `#{uuid}` UUID for the `#{library}` library"
|
52
|
+
end
|
53
|
+
target
|
54
|
+
end
|
55
|
+
non_integrated = targets.reject do |target|
|
56
|
+
target.frameworks_build_phase.files.any? do |build_file|
|
57
|
+
file_ref = build_file.file_ref
|
58
|
+
file_ref &&
|
59
|
+
file_ref.isa == 'PBXFileReference' &&
|
60
|
+
file_ref.display_name == library.product_name
|
61
|
+
end
|
62
|
+
end
|
63
|
+
@targets = non_integrated
|
64
|
+
end
|
65
|
+
@targets
|
66
|
+
end
|
67
|
+
|
68
|
+
# Read the project from the disk to ensure that it is up to date as
|
69
|
+
# other TargetIntegrators might have modified it.
|
70
|
+
#
|
71
|
+
def user_project
|
72
|
+
@user_project ||= Xcodeproj::Project.new(library.user_project_path)
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [String] a string representation suitable for debugging.
|
76
|
+
#
|
77
|
+
def inspect
|
78
|
+
"#<#{self.class} for target `#{target_definition.label}'>"
|
79
|
+
end
|
80
|
+
|
81
|
+
#---------------------------------------------------------------------#
|
82
|
+
|
83
|
+
# @!group Integration steps
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
# Adds the `xcconfig` configurations files generated for the current
|
88
|
+
# {TargetDefinition} to the build configurations of the targets that
|
89
|
+
# should be integrated.
|
90
|
+
#
|
91
|
+
# @note It also checks if any build setting of the build
|
92
|
+
# configurations overrides the `xcconfig` file and warns the
|
93
|
+
# user.
|
94
|
+
#
|
95
|
+
# @todo If the xcconfig is already set don't override it and inform
|
96
|
+
# the user.
|
97
|
+
#
|
98
|
+
# @return [void]
|
99
|
+
#
|
100
|
+
def add_xcconfig_base_configuration
|
101
|
+
xcconfig = user_project.new_file(library.xcconfig_relative_path)
|
102
|
+
targets.each do |target|
|
103
|
+
check_overridden_build_settings(library.xcconfig, target)
|
104
|
+
target.build_configurations.each do |config|
|
105
|
+
config.base_configuration_reference = xcconfig
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Adds a file reference to the library of the {TargetDefinition} and
|
111
|
+
# adds it to the frameworks build phase of the targets.
|
112
|
+
#
|
113
|
+
# @return [void]
|
114
|
+
#
|
115
|
+
def add_pods_library
|
116
|
+
frameworks = user_project.frameworks_group
|
117
|
+
pods_library = frameworks.new_static_library(library.label)
|
118
|
+
targets.each do |target|
|
119
|
+
target.frameworks_build_phase.add_file_reference(pods_library)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Adds a shell script build phase responsible to copy the resources
|
124
|
+
# generated by the TargetDefinition to the bundle of the product of the
|
125
|
+
# targets.
|
126
|
+
#
|
127
|
+
# @return [void]
|
128
|
+
#
|
129
|
+
def add_copy_resources_script_phase
|
130
|
+
targets.each do |target|
|
131
|
+
phase = target.new_shell_script_build_phase('Copy Pods Resources')
|
132
|
+
path = library.copy_resources_script_relative_path
|
133
|
+
phase.shell_script = %{"#{path}"\n}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Adds a shell script build phase responsible for checking if the Pods
|
138
|
+
# locked in the Pods/Manifest.lock file are in sync with the Pods defined
|
139
|
+
# in the Podfile.lock.
|
140
|
+
#
|
141
|
+
# @note The build phase is appended to the front because to fail
|
142
|
+
# fast.
|
143
|
+
#
|
144
|
+
# @return [void]
|
145
|
+
#
|
146
|
+
def add_check_manifest_lock_script_phase
|
147
|
+
targets.each do |target|
|
148
|
+
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
|
149
|
+
target.build_phases.unshift(phase)
|
150
|
+
phase.name = 'Check Pods Manifest.lock'
|
151
|
+
phase.shell_script = <<-EOS.strip_heredoc
|
152
|
+
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
|
153
|
+
if [[ $? != 0 ]] ; then
|
154
|
+
cat << EOM
|
155
|
+
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
|
156
|
+
EOM
|
157
|
+
exit 1
|
158
|
+
fi
|
159
|
+
EOS
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Saves the changes to the user project to the disk.
|
164
|
+
#
|
165
|
+
# @return [void]
|
166
|
+
#
|
167
|
+
def save_user_project
|
168
|
+
user_project.save_as(library.user_project_path)
|
169
|
+
end
|
170
|
+
|
171
|
+
#---------------------------------------------------------------------#
|
172
|
+
|
173
|
+
# @!group Private helpers.
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
# Informs the user about any build setting of the target which might
|
178
|
+
# override the given xcconfig file.
|
179
|
+
#
|
180
|
+
# @return [void]
|
181
|
+
#
|
182
|
+
def check_overridden_build_settings(xcconfig, target)
|
183
|
+
return unless xcconfig
|
184
|
+
|
185
|
+
configs_by_overridden_key = {}
|
186
|
+
target.build_configurations.each do |config|
|
187
|
+
xcconfig.attributes.keys.each do |key|
|
188
|
+
target_value = config.build_settings[key]
|
189
|
+
|
190
|
+
if target_value && !target_value.include?('$(inherited)')
|
191
|
+
configs_by_overridden_key[key] ||= []
|
192
|
+
configs_by_overridden_key[key] << config.name
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
configs_by_overridden_key.each do |key, config_names|
|
197
|
+
name = "#{target.name} [#{config_names.join(' - ')}]"
|
198
|
+
actions = [
|
199
|
+
"Use the `$(inherited)` flag, or",
|
200
|
+
"Remove the build settings from the target."
|
201
|
+
]
|
202
|
+
UI.warn("The target `#{name}` overrides the `#{key}` build " \
|
203
|
+
"setting defined in `#{library.xcconfig_relative_path}'.",
|
204
|
+
actions)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# @return [String] the message that should be displayed for the target
|
210
|
+
# integration.
|
211
|
+
#
|
212
|
+
def integration_message
|
213
|
+
"Integrating `#{library.product_name}` into " \
|
214
|
+
"#{'target'.pluralize(targets.size)} " \
|
215
|
+
"`#{targets.map(&:name).to_sentence}` " \
|
216
|
+
"of project #{UI.path library.user_project_path}."
|
217
|
+
end
|
218
|
+
|
219
|
+
#---------------------------------------------------------------------#
|
220
|
+
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,202 @@
|
|
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 folder where the client is stored used for
|
57
|
+
# computing the relative paths. If integrating it should be the
|
58
|
+
# folder where the user project is stored, otherwise it should
|
59
|
+
# be the installation root.
|
60
|
+
#
|
61
|
+
attr_accessor :client_root
|
62
|
+
|
63
|
+
# @return [Pathname] the path of the user project that this library will
|
64
|
+
# integrate as identified by the analyzer.
|
65
|
+
#
|
66
|
+
# @note The project instance is not stored to prevent editing different
|
67
|
+
# instances.
|
68
|
+
#
|
69
|
+
attr_accessor :user_project_path
|
70
|
+
|
71
|
+
# @return [String] the list of the UUIDs of the user targets that will be
|
72
|
+
# integrated by this library as identified by the analizer.
|
73
|
+
#
|
74
|
+
# @note The target instances are not stored to prevent editing different
|
75
|
+
# instances.
|
76
|
+
#
|
77
|
+
attr_accessor :user_target_uuids
|
78
|
+
|
79
|
+
# @return [Hash{String=>Symbol}] A hash representing the user build
|
80
|
+
# configurations where each key corresponds to the name of a
|
81
|
+
# configuration and its value to its type (`:debug` or `:release`).
|
82
|
+
#
|
83
|
+
attr_accessor :user_build_configurations
|
84
|
+
|
85
|
+
# @return [Platform] the platform for this library.
|
86
|
+
#
|
87
|
+
attr_accessor :platform
|
88
|
+
|
89
|
+
# @return [PBXNativeTarget] the target generated in the Pods project for
|
90
|
+
# this library.
|
91
|
+
#
|
92
|
+
attr_accessor :target
|
93
|
+
|
94
|
+
# @return [Xcodeproj::Config] the configuration file of the library
|
95
|
+
#
|
96
|
+
# @note The configuration is generated by the {TargetInstaller} and
|
97
|
+
# used by {UserProjectIntegrator} to check for any overridden
|
98
|
+
# values.
|
99
|
+
#
|
100
|
+
attr_accessor :xcconfig
|
101
|
+
|
102
|
+
# @return [Array<Specification>] the specifications of this library.
|
103
|
+
#
|
104
|
+
attr_accessor :specs
|
105
|
+
|
106
|
+
# @return [Array<Sandbox::FileAccessor>] the file accessors for the
|
107
|
+
# specifications of this library.
|
108
|
+
#
|
109
|
+
attr_accessor :file_accessors
|
110
|
+
|
111
|
+
#-------------------------------------------------------------------------#
|
112
|
+
|
113
|
+
# @!group Support files
|
114
|
+
|
115
|
+
# @return [Pathname] the absolute path of the xcconfig file.
|
116
|
+
#
|
117
|
+
def xcconfig_path
|
118
|
+
support_files_root + "#{label}.xcconfig"
|
119
|
+
end
|
120
|
+
|
121
|
+
# @return [Pathname] the absolute path of the copy resources script.
|
122
|
+
#
|
123
|
+
def copy_resources_script_path
|
124
|
+
support_files_root + "#{label}-resources.sh"
|
125
|
+
end
|
126
|
+
|
127
|
+
# @return [Pathname] the absolute path of the header file which contains
|
128
|
+
# the information about the installed pods.
|
129
|
+
#
|
130
|
+
def target_environment_header_path
|
131
|
+
support_files_root + "#{label}-environment.h"
|
132
|
+
end
|
133
|
+
|
134
|
+
# @return [Pathname] the absolute path of the prefix header file.
|
135
|
+
#
|
136
|
+
def prefix_header_path
|
137
|
+
support_files_root + "#{label}-prefix.pch"
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Pathname] the absolute path of the bridge support file.
|
141
|
+
#
|
142
|
+
def bridge_support_path
|
143
|
+
support_files_root + "#{label}.bridgesupport"
|
144
|
+
end
|
145
|
+
|
146
|
+
# @return [Pathname] the absolute path of acknowledgements file.
|
147
|
+
#
|
148
|
+
# @note The acknowledgements generators add the extension according to
|
149
|
+
# the file type.
|
150
|
+
#
|
151
|
+
def acknowledgements_basepath
|
152
|
+
support_files_root + "#{label}-acknowledgements"
|
153
|
+
end
|
154
|
+
|
155
|
+
# @return [Pathname] the path of the dummy source generated by CocoaPods
|
156
|
+
#
|
157
|
+
def dummy_source_path
|
158
|
+
support_files_root + "#{label}-dummy.m"
|
159
|
+
end
|
160
|
+
|
161
|
+
#--------------------------------------#
|
162
|
+
|
163
|
+
# @return [String] The xcconfig path of the root from the `$(SRCROOT)`
|
164
|
+
# variable of the user's project.
|
165
|
+
#
|
166
|
+
def relative_pods_root
|
167
|
+
"${SRCROOT}/#{support_files_root.relative_path_from(client_root)}"
|
168
|
+
end
|
169
|
+
|
170
|
+
# @return [String] the path of the xcconfig file relative to the root of
|
171
|
+
# the user project.
|
172
|
+
#
|
173
|
+
def xcconfig_relative_path
|
174
|
+
relative_to_srcroot(xcconfig_path).to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
# @return [String] the path of the copy resources script relative to the
|
178
|
+
# root of the user project.
|
179
|
+
#
|
180
|
+
def copy_resources_script_relative_path
|
181
|
+
"${SRCROOT}/#{relative_to_srcroot(copy_resources_script_path)}"
|
182
|
+
end
|
183
|
+
|
184
|
+
#-------------------------------------------------------------------------#
|
185
|
+
|
186
|
+
# @!group Private Helpers
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
# Computes the relative path of a sandboxed file from the `$(SRCROOT)`
|
191
|
+
# variable of the user's project.
|
192
|
+
#
|
193
|
+
# @param [Pathname] path
|
194
|
+
# A relative path from the root of the sandbox.
|
195
|
+
#
|
196
|
+
# @return [String] the computed path.
|
197
|
+
#
|
198
|
+
def relative_to_srcroot(path)
|
199
|
+
path.relative_path_from(client_root).to_s
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
# Allow OpenURI to follow http to https redirects.
|
4
|
+
#
|
5
|
+
module OpenURI
|
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)
|
21
|
+
uri1.scheme.downcase == uri2.scheme.downcase ||
|
22
|
+
(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme)
|
23
|
+
end
|
24
|
+
end
|