cocoapods-xcremotecache 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9c8ea806c777060721ce8e440f64f46f99e14012aea29e4b5f096839e11d81ea
4
+ data.tar.gz: 0a6ede5267ecdd314ac879a7bca8840f2d94b79a245f8b6002c9279c7a004862
5
+ SHA512:
6
+ metadata.gz: c0949ce7b8617db61a2859cd787f3ab196a5f3048eed68b666ea69995ad491ea39e12fdf4b06b1c1a85a3c81eaec573c25ea996273203ae6691d5d24d6257e9c
7
+ data.tar.gz: 162f1467dfcc90185b6a97509ccf09f250ff2f758d86832a538e1415c03a0a9654d3e1037dca29c5ddf734203d6f81e8d9cab23966e80af710550ba424caf3e8
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-xcremotecache.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # cocoapods-xcremotecache
2
+
3
+ The CocoaPods plugin that integrates XCRemoteCache with the project.
4
+
5
+ ## Installation
6
+
7
+ Build & install the plugin
8
+
9
+ ```bash
10
+ gem build cocoapods-xcremotecache.gemspec
11
+ gem install cocoapods-xcremotecache-{CurrentGemVersion}.gem # e.g. gem install cocoapods-xcremotecache-0.0.1.gem
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ 1. Add plugin reference to your project `Podfile`:
17
+ ```
18
+ plugin 'cocoapods-xcremotecache'
19
+ ```
20
+ 2. Configure XCRemoteCache at the top of your `Podfile` definition:
21
+ ```ruby
22
+ xcremotecache({
23
+ 'cache_addresses' => ['http://localhost:8080/cache/pods'],
24
+ 'primary_repo' => 'https://your.primary.repo.git',
25
+ 'mode' => 'consumer'
26
+ })
27
+ ```
28
+ 3. (Optional) Unzip all XCRemoteCache binaries to the `xcrc_location` directory (defaults to `XCRC` placed next to the `Podfile`). If you don't provide all binaries in the location, the plugin will try to download the latest XCRemoteCache artifact from the public GitHub page.
29
+ 4. Call `pod install` and verify that `[XCRC] XCRemoteCache enabled` has been printed to the console.
30
+
31
+ ### Configuration parameters
32
+
33
+ An object that is passed to the `xcremotecache` can contain all properties supported natively in the XCRemoteCache. In addition to that, there are extra parameters that are unique to the `cocoapods-xcremotecache`:
34
+
35
+ | Parameter | Description | Default | Required |
36
+ | ------------- | ------------- | ------------- | ------------- |
37
+ | `enabled` | A Boolean value that enables XCRemoteCache integration to the project | `true` | ⬜️ |
38
+ | `xcrc_location` | The location of all XCRemoteCache binaries | `{podfile_dir}/XCRC` | ⬜️ |
39
+ | `exclude_targets` | Comma-separated list of targets that shouldn't use XCRemoteCache | `[]`| ⬜️ |
40
+ | `exclude_build_configurations` | Comma-separated list of configurations that shouldn't use XCRemoteCache | `[]`| ⬜️ |
41
+ | `final_target` | A target name that is build at the end of the build chain. Relevant only for a 'producer' mode to mark a given sha as ready to use from cache | `Debug` | ⬜️ |
42
+ | `check_build_configuration` | A build configuration for which the remote cache availability is performed. Relevant only for a 'consumer' mode | `Debug` | ⬜️ |
43
+ | `check_platform` | A platform for which the remote cache availability is performed. Relevant only for a 'consumer' mode | `iphonesimulator` | ⬜️
44
+ | `modify_lldb_init` | Controls if the pod integration should modify `~/.lldbinit` | `true` | ⬜️ |
45
+ | `xccc_file` | The path where should be placed the `xccc` binary (in the pod installation phase) | `{podfile_dir}/.rc/xccc` | ⬜️ |
46
+ | `remote_commit_file` | The path of the file with the remote commit sha (in the pod installation phase) | `{podfile_dir}/.rc/arc.rc`| ⬜️ |
47
+
48
+ ## Uninstalling
49
+
50
+ To fully uninstall the plugin, call:
51
+
52
+ ```bash
53
+ gem uninstall cocoapods-xcremotecache
54
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-xcremotecache/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-xcremotecache'
8
+ spec.version = CocoapodsXcremotecache::VERSION
9
+ spec.authors = ['Bartosz Polaczyk', 'Mark Vasiv']
10
+ spec.email = ['bartoszp@spotify.com', 'mvasiv@spotify.com']
11
+ spec.description = %q{CocoaPods plugin that enables XCRemoteCache with the project.}
12
+ spec.summary = %q{A simple plugin that attaches to the post_install hook and modifies the generated project to use XCRemoteCache. Supports both producing anc consuming parts.}
13
+ spec.homepage = 'https://github.com/spotify/XCRemoteCache'
14
+ spec.license = 'Apache-2.0'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+ end
@@ -0,0 +1,377 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cocoapods'
16
+ require 'cocoapods/resolver'
17
+ require 'open-uri'
18
+ require 'yaml'
19
+ require 'json'
20
+
21
+
22
+ module CocoapodsXCRemoteCacheModifier
23
+ # Registers for CocoaPods plugin hooks
24
+ module Hooks
25
+ BIN_DIR = '.rc'
26
+ FAKE_SRCROOT = "/#{'x' * 10 }"
27
+ LLDB_INIT_COMMENT="#RemoteCacheCustomSourceMap"
28
+ LLDB_INIT_PATH = "#{ENV['HOME']}/.lldbinit"
29
+
30
+ CUSTOM_CONFIGURATION_KEYS = [
31
+ 'enabled',
32
+ 'xcrc_location',
33
+ 'exclude_targets',
34
+ 'exclude_build_configurations',
35
+ 'final_target',
36
+ 'check_build_configuration',
37
+ 'check_platform',
38
+ 'modify_lldb_init'
39
+ ]
40
+
41
+ class XCRemoteCache
42
+ @@configuration = nil
43
+
44
+ def self.configure(c)
45
+ @@configuration = c
46
+ end
47
+
48
+ def self.set_configuration_default_values(user_proj_directory)
49
+ default_values = {
50
+ 'mode' => 'consumer',
51
+ 'enabled' => true,
52
+ 'xcrc_location' => "#{user_proj_directory}/XCRC",
53
+ 'exclude_build_configurations' => [],
54
+ 'check_build_configuration' => 'Debug',
55
+ 'check_platform' => 'iphonesimulator',
56
+ 'modify_lldb_init' => true,
57
+ 'xccc_file' => "#{user_proj_directory}/#{BIN_DIR}/xccc",
58
+ 'remote_commit_file' => "#{user_proj_directory}/#{BIN_DIR}/arc.rc",
59
+ 'exclude_targets' => [],
60
+ }
61
+ @@configuration.merge! default_values.select { |k, v| !@@configuration.key?(k) }
62
+ end
63
+
64
+ def self.validate_configuration()
65
+ required_values = [
66
+ 'cache_addresses',
67
+ 'primary_repo',
68
+ 'check_build_configuration',
69
+ 'check_platform'
70
+ ]
71
+
72
+ missing_configuration_values = required_values.select { |v| !@@configuration.key?(v) }
73
+ unless missing_configuration_values.empty?
74
+ throw "XCRemoteCache not fully configured. Make sure all required fields are provided. Missing fields are: #{missing_configuration_values.join(', ')}."
75
+ end
76
+
77
+ mode = @@configuration['mode']
78
+ unless mode == 'consumer' || mode == 'producer'
79
+ throw "Incorrect 'mode' value. Allowed values are ['consumer', 'producer'], but you provided '#{mode}'. A typo?"
80
+ end
81
+
82
+ unless mode == 'consumer' || @@configuration.key?('final_target')
83
+ throw "Missing 'final_target' value in the Pod configuration."
84
+ end
85
+ end
86
+
87
+ def self.generate_rcinfo()
88
+ @@configuration.select { |key, value| !CUSTOM_CONFIGURATION_KEYS.include?(key) }
89
+ end
90
+
91
+ def self.enable_xcremotecache(target, user_proj_directory, xc_location, xc_cc_path, mode, exclude_build_configurations, check_build_configuration, check_platform, final_target)
92
+ target.build_configurations.each do |config|
93
+ # apply only for relevant Configurations
94
+ next if exclude_build_configurations.include?(config.name)
95
+ if mode == 'consumer'
96
+ config.build_settings['CC'] = [xc_cc_path]
97
+ end
98
+ config.build_settings['SWIFT_EXEC'] = ["#{xc_location}/xcswiftc"]
99
+ config.build_settings['LIBTOOL'] = ["#{xc_location}/xclibtool"]
100
+ config.build_settings['LD'] = ["#{xc_location}/xcld"]
101
+
102
+ config.build_settings['XCREMOTE_CACHE_FAKE_SRCROOT'] = FAKE_SRCROOT
103
+ add_cflags!(config.build_settings, '-fdebug-prefix-map', "#{user_proj_directory}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
104
+ add_swiftflags!(config.build_settings, '-debug-prefix-map', "#{user_proj_directory}=$(XCREMOTE_CACHE_FAKE_SRCROOT)")
105
+ end
106
+
107
+
108
+ # User project is not generated from scratch (contrary to `Pods`), delete all previous XCRemoteCache phases
109
+ target.build_phases.delete_if {|phase|
110
+ # Some phases (e.g. PBXSourcesBuildPhase) don't have strict name check respond_to?
111
+ if phase.respond_to?(:name)
112
+ phase.name != nil && phase.name.start_with?("[XCRC]")
113
+ end
114
+ }
115
+
116
+ # Prebuild
117
+ if mode == 'consumer'
118
+ prebuild_script = target.new_shell_script_build_phase("[XCRC] Prebuild")
119
+ prebuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
120
+ prebuild_script.input_paths = ["#{xc_location}/xcprebuild"]
121
+ prebuild_script.output_paths = [
122
+ "$(TARGET_TEMP_DIR)/rc.enabled",
123
+ "$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)"
124
+ ]
125
+ prebuild_script.dependency_file = "$(TARGET_TEMP_DIR)/prebuild.d"
126
+
127
+ # Move prebuild (last element) to the first position (to make it real 'prebuild')
128
+ target.build_phases.rotate!(-1)
129
+ end
130
+
131
+ # Postbuild
132
+ postbuild_script = target.new_shell_script_build_phase("[XCRC] Postbuild")
133
+ postbuild_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\""
134
+ postbuild_script.input_paths = ["#{xc_location}/xcpostbuild"]
135
+ postbuild_script.output_paths = [
136
+ "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(PLATFORM_PREFERRED_ARCH).swiftmodule.md5",
137
+ "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5"
138
+ ]
139
+ postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d"
140
+
141
+ # Mark a sha as ready for a given platform and configuration when building the final_target
142
+ if mode == 'producer' && target.name == final_target
143
+ mark_script = target.new_shell_script_build_phase("[XCRC] Mark")
144
+ mark_script.shell_script = "\"$SCRIPT_INPUT_FILE_0\" mark --configuration $CONFIGURATION --platform $PLATFORM_NAME"
145
+ mark_script.input_paths = ["#{xc_location}/xcprepare"]
146
+ end
147
+ end
148
+
149
+ def self.disable_xcremotecache_for_target(target)
150
+ target.build_configurations.each do |config|
151
+ config.build_settings.delete('CC') if config.build_settings.key?('CC')
152
+ config.build_settings.delete('SWIFT_EXEC') if config.build_settings.key?('SWIFT_EXEC')
153
+ config.build_settings.delete('LIBTOOL') if config.build_settings.key?('LIBTOOL')
154
+ config.build_settings.delete('LD') if config.build_settings.key?('LD')
155
+ # Add Fake src root for ObjC & Swift
156
+ config.build_settings.delete('XCREMOTE_CACHE_FAKE_SRCROOT')
157
+ remove_cflags!(config.build_settings, '-fdebug-prefix-map')
158
+ remove_swiftflags!(config.build_settings, '-debug-prefix-map')
159
+ end
160
+
161
+ # User project is not generated from scratch (contrary to `Pods`), delete all previous XCRemoteCache phases
162
+ target.build_phases.delete_if {|phase|
163
+ # Some phases (e.g. PBXSourcesBuildPhase) don't have strict name check respond_to?
164
+ if phase.respond_to?(:name)
165
+ phase.name != nil && phase.name.start_with?("[XCRC]")
166
+ end
167
+ }
168
+ end
169
+
170
+ # Writes XCRemoteCache info in the specified directory location
171
+ def self.save_rcinfo(info, directory)
172
+ File.open(File.join(directory, '.rcinfo'), 'w') { |file| file.write info.to_yaml }
173
+ end
174
+
175
+ def self.download_xcrc_if_needed(local_location)
176
+ required_binaries = ['xcld', 'xclibtool', 'xcpostbuild', 'xcprebuild', 'xcprepare', 'xcswiftc']
177
+ binaries_exist = required_binaries.reduce(true) do |exists, filename|
178
+ file_path = File.join(local_location, filename)
179
+ exists = exists && File.exist?(file_path)
180
+ end
181
+
182
+ # Don't download XCRemoteCache if provided directory already contains it
183
+ return if binaries_exist
184
+
185
+ Dir.mkdir(local_location) unless File.exist?(local_location)
186
+ local_package_location = File.join(local_location, 'package.zip')
187
+
188
+ download_latest_xcrc_release(local_package_location)
189
+
190
+ if !system("unzip #{local_package_location} -d #{local_location}")
191
+ throw "Unzipping XCRemoteCache failed"
192
+ end
193
+ end
194
+
195
+ def self.download_latest_xcrc_release(local_package_location)
196
+ release_url = 'https://api.github.com/repos/spotify/XCRemoteCache/releases/latest'
197
+ asset_url = nil
198
+
199
+ open(release_url, :http_basic_authentication => credentials) do |f|
200
+ asset_url = JSON.parse(f.read)['assets'][0]['url']
201
+ end
202
+
203
+ if asset_url.nil?
204
+ throw "Downloading XCRemoteCache failed"
205
+ end
206
+
207
+ open(asset_url, :http_basic_authentication => credentials, "accept" => 'application/octet-stream') do |f|
208
+ File.open(local_package_location, "wb") do |file|
209
+ file.puts f.read
210
+ end
211
+ end
212
+ end
213
+
214
+ def self.add_cflags!(options, key, value)
215
+ return if options.fetch('OTHER_CFLAGS',[]).include?(' ' + value)
216
+ options['OTHER_CFLAGS'] = remove_cflags!(options, key) << " #{key}=#{value}"
217
+ end
218
+
219
+ def self.remove_cflags!(options, key)
220
+ cflags_arr = options.fetch('OTHER_CFLAGS', ['$(inherited)'])
221
+ cflags_arr = [cflags_arr] if cflags_arr.kind_of? String
222
+ options['OTHER_CFLAGS'] = cflags_arr.delete_if {|flag| flag.start_with?(" #{key}=") }
223
+ options['OTHER_CFLAGS']
224
+ end
225
+
226
+ def self.add_swiftflags!(options, key, value)
227
+ return if options.fetch('OTHER_SWIFT_FLAGS','').include?(value)
228
+ options['OTHER_SWIFT_FLAGS'] = remove_swiftflags!(options, key) + " #{key} #{value}"
229
+ end
230
+
231
+ def self.remove_swiftflags!(options, key)
232
+ options['OTHER_SWIFT_FLAGS'] = options.fetch('OTHER_SWIFT_FLAGS', '$(inherited)').gsub(/\s+#{Regexp.escape(key)}\s+\S+/, '')
233
+ options['OTHER_SWIFT_FLAGS']
234
+ end
235
+
236
+ # Uninstall the XCRemoteCache
237
+ def self.disable_xcremotecache(user_project)
238
+ user_project.targets.each do |target|
239
+ disable_xcremotecache_for_target(target)
240
+ end
241
+ user_project.save()
242
+
243
+ # Remove .lldbinit rewrite
244
+ save_lldbinit_rewrite(nil) unless !@@configuration['modify_lldb_init']
245
+ end
246
+
247
+ # Returns the content (array of lines) of the lldbinit with stripped XCRemoteCache rewrite
248
+ def self.clean_lldbinit_content(lldbinit_path)
249
+ all_lines = []
250
+ File.open(lldbinit_path) { |file|
251
+ while(line = file.gets) != nil
252
+ line = line.strip
253
+ if line == LLDB_INIT_COMMENT
254
+ # skip current and next lines
255
+ file.gets
256
+ next
257
+ end
258
+ all_lines << line
259
+ end
260
+ }
261
+ all_lines
262
+ end
263
+
264
+ # Append source rewrite command to the lldbinit content
265
+ def self.add_lldbinit_rewrite(lines_content, user_proj_directory)
266
+ all_lines = lines_content.clone
267
+ all_lines << LLDB_INIT_COMMENT
268
+ all_lines << "settings set target.source-map #{FAKE_SRCROOT} #{user_proj_directory}"
269
+ all_lines << ""
270
+ all_lines
271
+ end
272
+
273
+ def self.save_lldbinit_rewrite(user_proj_directory)
274
+ lldbinit_lines = clean_lldbinit_content(LLDB_INIT_PATH)
275
+ lldbinit_lines = add_lldbinit_rewrite(lldbinit_lines, user_proj_directory) unless user_proj_directory.nil?
276
+ File.write(LLDB_INIT_PATH, lldbinit_lines.join("\n"), mode: "w")
277
+ end
278
+
279
+ Pod::HooksManager.register('cocoapods-xcremotecache', :post_install) do |installer_context|
280
+ if @@configuration.nil?
281
+ Pod::UI.puts "[XCRC] Warning! XCRemoteCache not configured. Call xcremotecache({...}) in Podfile to enable XCRemoteCache"
282
+ next
283
+ end
284
+
285
+ user_project = installer_context.umbrella_targets[0].user_project
286
+
287
+ begin
288
+ user_proj_directory = File.dirname(user_project.path)
289
+ set_configuration_default_values(user_proj_directory)
290
+
291
+ unless @@configuration['enabled']
292
+ Pod::UI.puts "[XCRC] XCRemoteCache disabled"
293
+ disable_xcremotecache(user_project)
294
+ next
295
+ end
296
+
297
+ validate_configuration()
298
+
299
+ mode = @@configuration['mode']
300
+ xccc_location = @@configuration['xccc_file']
301
+ remote_commit_file = @@configuration['remote_commit_file']
302
+ xcrc_location = @@configuration['xcrc_location']
303
+ exclude_targets = @@configuration['exclude_targets'] || []
304
+ exclude_build_configurations = @@configuration['exclude_build_configurations'] || []
305
+ final_target = @@configuration['final_target']
306
+ check_build_configuration = @@configuration['check_build_configuration']
307
+ check_platform = @@configuration['check_platform']
308
+
309
+ # Download XCRC
310
+ download_xcrc_if_needed(xcrc_location)
311
+
312
+ # Save .rcinfo
313
+ save_rcinfo(generate_rcinfo(), user_proj_directory)
314
+
315
+ # Create directory for xccc & arc.rc location
316
+ Dir.mkdir(BIN_DIR) unless File.exist?(BIN_DIR)
317
+
318
+ # Remove previous xccc & arc.rc
319
+ File.delete(remote_commit_file) if File.exist?(remote_commit_file)
320
+ File.delete(xccc_location) if File.exist?(xccc_location)
321
+
322
+ # Prepare XCRC
323
+ begin
324
+ prepare_result = YAML.load`#{xcrc_location}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}`
325
+ unless prepare_result['result'] || mode != 'consumer'
326
+ # Uninstall the XCRemoteCache for the consumer mode
327
+ disable_xcremotecache(user_project)
328
+ Pod::UI.puts "[XCRC] XCRemoteCache disabled - no artifacts available"
329
+ next
330
+ end
331
+ rescue => error
332
+ disable_xcremotecache(user_project)
333
+ Pod::UI.puts "[XCRC] XCRemoteCache failed with an error: #{error}."
334
+ next
335
+ end
336
+
337
+ # Attach XCRemoteCache to Pods targets
338
+ installer_context.pods_project.targets.each do |target|
339
+ next if target.name.start_with?("Pods-")
340
+ next if target.name.end_with?("Tests")
341
+ next if exclude_targets.include?(target.name)
342
+ enable_xcremotecache(target, user_proj_directory, xcrc_location, xccc_location, mode, exclude_build_configurations, check_build_configuration, check_platform, final_target)
343
+ end
344
+
345
+ # Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location
346
+ pods_proj_directory = installer_context.sandbox_root
347
+
348
+ # Manual .rcinfo generation (in YAML format)
349
+ save_rcinfo({'extra_configuration_file' => "#{user_proj_directory}/.rcinfo"}, pods_proj_directory)
350
+
351
+ installer_context.pods_project.save()
352
+
353
+ # Attach XCRC to the app targets
354
+ user_project.targets.each do |target|
355
+ next if exclude_targets.include?(target.name)
356
+ enable_xcremotecache(target, user_proj_directory, xcrc_location, xccc_location, mode, exclude_build_configurations, check_build_configuration, check_platform, final_target)
357
+ end
358
+
359
+ # Set Target sourcemap
360
+ if @@configuration['modify_lldb_init']
361
+ save_lldbinit_rewrite(user_proj_directory)
362
+ else
363
+ Pod::UI.puts "[XCRC] lldbinit modification is disabled. Debugging may behave weirdly"
364
+ Pod::UI.puts "[XCRC] put \"settings set target.source-map #{FAKE_SRCROOT} \#{your_project_directory}\" to your \".lldbinit\" "
365
+ end
366
+
367
+ user_project.save()
368
+ Pod::UI.puts "[XCRC] XCRemoteCache enabled"
369
+ rescue Exception => e
370
+ Pod::UI.puts "[XCRC] XCRemoteCache disabled with error: #{e}"
371
+ puts e.full_message(highlight: true, order: :top)
372
+ disable_xcremotecache(user_project)
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
@@ -0,0 +1,26 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cocoapods'
16
+
17
+ module Pod
18
+ class Podfile
19
+ module DSL
20
+
21
+ def xcremotecache(configuration)
22
+ CocoapodsXCRemoteCacheModifier::Hooks::XCRemoteCache.configure(configuration)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Pod
16
+ class Command
17
+ # This is an example of a cocoapods plugin adding a top-level subcommand
18
+ # to the 'pod' command.
19
+ #
20
+ # You can also create subcommands of existing or new commands. Say you
21
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
22
+ # (e.g. `pod list deprecated`), there are a few things that would need
23
+ # to change.
24
+ #
25
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
26
+ # the class to exist in the the Pod::Command::List namespace
27
+ # - change this class to extend from `List` instead of `Command`. This
28
+ # tells the plugin system that it is a subcommand of `list`.
29
+ # - edit `lib/cocoapods_plugins.rb` to require this file
30
+ #
31
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
32
+ # in the `plugins.json` file, once your plugin is released.
33
+ #
34
+ class Xcremotecache < Command
35
+ self.summary = 'Plugin to integrate CocoaPods with XCRemoteCache.'
36
+
37
+ self.description = <<-DESC
38
+ Configuring a project to use XCRemoteCache (along the Pods targets).
39
+ DESC
40
+
41
+ def initialize(argv)
42
+ @name = argv.shift_argument
43
+ super
44
+ end
45
+
46
+ def validate!
47
+ super
48
+ help! 'A Pod name is required.' unless @name
49
+ end
50
+
51
+ def run
52
+ UI.puts "Add your implementation for the cocoapods-xcremotecache plugin in #{__FILE__}"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cocoapods-xcremotecache/command/xcremotecache'
16
+ require 'cocoapods-xcremotecache/command/hooks'
17
+ require 'cocoapods-xcremotecache/command/podfile'
@@ -0,0 +1,17 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module CocoapodsXcremotecache
16
+ VERSION = "0.0.1"
17
+ end
@@ -0,0 +1,15 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cocoapods-xcremotecache/gem_version'
@@ -0,0 +1,15 @@
1
+ # Copyright 2021 Spotify AB
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'cocoapods-xcremotecache/command'
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-xcremotecache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Polaczyk
8
+ - Mark Vasiv
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-11-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: CocoaPods plugin that enables XCRemoteCache with the project.
15
+ email:
16
+ - bartoszp@spotify.com
17
+ - mvasiv@spotify.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - cocoapods-xcremotecache.gemspec
26
+ - lib/cocoapods-xcremotecache.rb
27
+ - lib/cocoapods-xcremotecache/command.rb
28
+ - lib/cocoapods-xcremotecache/command/hooks.rb
29
+ - lib/cocoapods-xcremotecache/command/podfile.rb
30
+ - lib/cocoapods-xcremotecache/command/xcremotecache.rb
31
+ - lib/cocoapods-xcremotecache/gem_version.rb
32
+ - lib/cocoapods_plugin.rb
33
+ homepage: https://github.com/spotify/XCRemoteCache
34
+ licenses:
35
+ - Apache-2.0
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.2.3
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: A simple plugin that attaches to the post_install hook and modifies the generated
56
+ project to use XCRemoteCache. Supports both producing anc consuming parts.
57
+ test_files: []