pod-builder-y 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +13 -0
  5. data/README.md +385 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/exe/pod_builder_y +406 -0
  10. data/lib/core_ext/string.rb +5 -0
  11. data/lib/pod_builder/analyze.rb +59 -0
  12. data/lib/pod_builder/analyzer.rb +16 -0
  13. data/lib/pod_builder/command.rb +14 -0
  14. data/lib/pod_builder/command/build.rb +228 -0
  15. data/lib/pod_builder/command/build_all.rb +15 -0
  16. data/lib/pod_builder/command/clean.rb +75 -0
  17. data/lib/pod_builder/command/deintegrate.rb +101 -0
  18. data/lib/pod_builder/command/generate_lldbinit.rb +128 -0
  19. data/lib/pod_builder/command/generate_podspec.rb +22 -0
  20. data/lib/pod_builder/command/info.rb +18 -0
  21. data/lib/pod_builder/command/init.rb +148 -0
  22. data/lib/pod_builder/command/install_sources.rb +79 -0
  23. data/lib/pod_builder/command/none.rb +16 -0
  24. data/lib/pod_builder/command/restore_all.rb +33 -0
  25. data/lib/pod_builder/command/switch.rb +224 -0
  26. data/lib/pod_builder/command/sync_podfile.rb +34 -0
  27. data/lib/pod_builder/command/update.rb +43 -0
  28. data/lib/pod_builder/configuration.rb +300 -0
  29. data/lib/pod_builder/core.rb +222 -0
  30. data/lib/pod_builder/info.rb +90 -0
  31. data/lib/pod_builder/install.rb +505 -0
  32. data/lib/pod_builder/licenses.rb +73 -0
  33. data/lib/pod_builder/podfile.rb +700 -0
  34. data/lib/pod_builder/podfile/pre_actions_swizzles.rb +84 -0
  35. data/lib/pod_builder/podfile_cp.rb +99 -0
  36. data/lib/pod_builder/podfile_item.rb +530 -0
  37. data/lib/pod_builder/podspec.rb +269 -0
  38. data/lib/pod_builder/rome/post_install.rb +446 -0
  39. data/lib/pod_builder/rome/pre_install.rb +6 -0
  40. data/lib/pod_builder/templates/build_podfile.template +70 -0
  41. data/lib/pod_builder/templates/build_podspec.template +19 -0
  42. data/lib/pod_builder/version.rb +4 -0
  43. data/pod-builder.gemspec +37 -0
  44. metadata +240 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5bb97332ef925b1d6f949ffa2e66fdd3fb4ecd44c81c07dfdc8aaedd15442f33
4
+ data.tar.gz: 5c0620d29f08602f64c98e5d57f1c32df47bb68f23fce99ab44002b83d4fc2f3
5
+ SHA512:
6
+ metadata.gz: 8a2c6dc77c4d11e73c95b2603c9dfb5a0054598e4e905aa2a954e35a5d8ea07776d362a0836d93e39308da987efca167fc7e48fe49f206b0b11679b84b50c465
7
+ data.tar.gz: 5ed83f46bfde6eb0650990b8f3b839cfee7d5ffce765636d4f7246e499df9aa68b874566405d32bea694e917cbb132fb993bc9d16eeb37fadce1ae0ffb9142ec
@@ -0,0 +1,19 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ .vscode/
11
+ .DS_Store
12
+ Example/Pods
13
+ Example/PodBuilder/Prebuilt
14
+
15
+ Example/PodBuilder/dSYM
16
+
17
+ Example/PodBuilderExample.xcodeproj/xcuserdata/*.xcuserdatad
18
+ Example/PodBuilderExample.xcworkspace/xcuserdata
19
+ Example/Pods
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby '2.6.3'
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in pod-builder.gemspec
8
+ gemspec
@@ -0,0 +1,13 @@
1
+ Copyright 2018 Subito.it S.r.l (www.subito.it)
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.
@@ -0,0 +1,385 @@
1
+ # What is PodBuilder
2
+
3
+ PodBuilder is a complementary tool to [CocoaPods](https://github.com/CocoaPods/CocoaPods) that allows to prebuild pods into frameworks which can then be included into a project’s repo. Instead of committing pod’s source code you add its compiled counterpart. While there is a size penalty in doing so compilation times will decrease significantly because pod's source files no longer need to be recompiled _very often_ and there's also a lot less for SourceKit to index. Additionally frameworks contain all architecture so they’re ready to be used both on any device and simulator.
4
+
5
+ Depending on the size of the project and number of pods this can translate in a significant reduction of compilation times (for a large project we designed this tool for we saw a 50% faster compile times, but YMMV).
6
+
7
+ # Installation
8
+
9
+ Like CocoaPods PodBuilder is built with Ruby and will be installable with default version of Ruby available on macOS.
10
+
11
+ Unless you're using a Ruby version manager you should generally install using `sudo` as follows
12
+
13
+ $ sudo gem install pod-builder
14
+
15
+ ## Requirements
16
+
17
+ Ruby 2.6.3 or newer. Cocoapods 1.9.0 or newer
18
+
19
+ # Quick start
20
+
21
+ You can the initialize your project to use the tool using the `init` command
22
+
23
+ $ cd path-to-your-repo;
24
+ $ pod_builder init
25
+
26
+ This will add a _PodBuilder_ folder which will contain all files needed and generated by the PodBuilder.
27
+
28
+ To prebuild just one or more specific dependencies run
29
+
30
+ $ pod_builder build Pod1 Pod2
31
+
32
+ To prebuild all dependencies run
33
+
34
+ $ pod_builder build_all
35
+
36
+ This will generate the pod frameworks which can be committed to your repo (using git LFS is highly suggested) for much faster compilation.
37
+
38
+ Should PodBuilder not work the way you expect you can get rid of it by running
39
+
40
+ $ pod_builder deintegrate
41
+
42
+ Which will restore all changes that PodBUilder applied to the project (the PodBuilder folder and the changes to the Podfile).
43
+
44
+ # Usage
45
+
46
+ ## Podfile
47
+
48
+ The workflow is very similar to the one you're used to with CocoaPods. The most significant difference is that PodBuilder relies on 3 Podfiles:
49
+
50
+ ### 1. PodBuilder/Podfile (aka PodBuilder-Podfile)
51
+
52
+ This is your original Podfile and remains your **master Podfile** that you will update as needed. It is used by PodBuilder to determine which versions and dependencies need to be compiled when prebuilding.
53
+
54
+ ### 2. Podfile (aka Application-Podfile)
55
+
56
+ Based on the one above but will replace precompiled frameworks with references to the local PodBuilder podspec. **It is autogenerated and shouldn't be manually changed**
57
+
58
+ ### 3. PodBuilder/Podfile.restore (aka Restore-Podfile)
59
+
60
+ This acts as a sort of lockfile and reflects the current state of what is installed in the application, pinning pods to a particular tag or commit. This will be particularly useful until Swift reaches ABI stability, because when you check out an old revision of your code you won't be able to get your project running unless the Swift frameworks were compiled with a same version of Xcode you're currently using. This file is used internally by PodBuilder and shouldn't be manually changed. **It is autogenerated and shouldn't be manually changed**
61
+
62
+ ## Commands
63
+
64
+ PodBuilder comes with a rich set of commands:
65
+
66
+ - `init`: initializes a project to use PodBuilder
67
+ - `deintegrate`: deintegrates PodBuilder's initialization
68
+ - `build`: prebuilts a specific pod declared in the PodBuilder-Podfile
69
+ - `build_all`: prebuilts all pods declared in the PodBuilder-Podfile
70
+ - `update`: prebuilts all pods that are out-of-sync with the Restore-Podfile
71
+ - `restore_all`: rebuilts all pods declared in the Restore-Podfile file
72
+ - `install_sources`: installs sources of pods to debug into prebuild frameworks
73
+ - `switch`: switch between prebuilt, development or standard pod in the Application-Podfile
74
+ - `clean`: removes unused prebuilt frameworks, dSYMs and source files added by install_sources
75
+ - `sync_podfile`: updates the Application-Podfile with all pods declared in the PodBuilder-Podfile file
76
+ - `info`: outputs json-formatted information reflecting the current status of prebuilt pods
77
+
78
+ Commands can be run from anywhere in your project's repo that is **required to be under git**.
79
+
80
+ #### `init` command
81
+
82
+ This will sets up a project to use PodBuilder.
83
+
84
+ The following will happen:
85
+
86
+ - Create a _PodBuilder_ folder in your repo's root.
87
+ - Copy your original Podfile to _PodBuilder/Podfile_ (PodBuilder-Podfile)
88
+ - Add a _PodBuilder.json_ configuration file
89
+ - Modify the original Podfile (Application-Podfile) with some minor customizations
90
+ - Create/Update your Gemfile adding the `gem 'pod-builder'` entry
91
+
92
+ #### `deintegrate` command
93
+
94
+ This will revert `init`'s changes.
95
+
96
+ #### `build` command
97
+
98
+ Running `pod_builder build [pod name]` will precompile the pod that should be included in the PodBuilder-Podfile.
99
+
100
+ The following will happen:
101
+
102
+ - Create one or more (if there are dependencies) _.framework_ file/s under _PodBuilder/Prebuilt_ along with its corresponding _dSYM_ files (if applicable)
103
+ - Update the Application-Podfile replacing the pod definition with the precompiled ones
104
+ - Update/create the Podfile.restore (Restore-Podfile)
105
+ - Update/create PodBuilder.podspec which is a local podspec for your prebuilt frameworks (more on this later)
106
+
107
+ By default PodBuilder will only rebuild pods when changes are detected in source code. This behaviour can be overridden by passing the `--force` flag.
108
+
109
+ #### `build_all` command
110
+
111
+ As `build` but will prebuild all pods defined in PodBuilder-Podfile.
112
+
113
+ #### `update` command
114
+
115
+ If you decide not to commit the _Prebuilt_ and _dSYM_ folders you can use this command to rebuild all those frameworks that are out-of-sync with the Restore-Podfile or that were built with a different version of the Swift compiler.
116
+
117
+ #### `restore_all` command
118
+
119
+ Will recompile all pods to the versions defined in the Restore-Podfile. You would typically use this when checking out an older revision of your project that might need to rebuild frameworks (e.g. You're using a different version of the Swift compiler) to the exact same version at the time of the commit.
120
+
121
+ #### `install_sources` command
122
+
123
+ Once you prebuild a pod you can no longer debug its origianl code, to overcome this limitation you can use this command which downloads the pod's source code to _PodBuilder/Sources_ and with some [tricks](https://medium.com/@t.camin/debugging-prebuilt-frameworks-c9f52d42600b) restores the ability to use the debugger and step into the code of your prebuilt dependencies. This can be very helpful to catch the exact location of a crash when it occurs (showing something more useful than assembly code). It is however advisable to switch to the original pod when doing any advanced debugging during development of code that involves a pod.
124
+
125
+ #### `generate_lldbinit` command
126
+
127
+ In some situations you may already have source code for your prebuilt frameworks, for example if your project is organized as a monorepo. In this case there is no need to use the `install_sources`, you can run this command passing the folder that contains the source code that you used to generate the prebuilt frameworks.
128
+
129
+ This command will generate a custom lldinit file which will be stored in the _PodBuilder_ folder. Note that this file is added to the .gitignore since it contains absolute path information. Since Xcode 11.5 customly defined lldbinit can be selected in the Run tab in your scheme project ("LLDB Init File"). You should select the generated llbb file path or, if you're using project generation tools such as XcodeGen, you can set it to `${SRCROOT}/../PodBuilder/lldbinit`.
130
+
131
+ The most convenient place to update the lldbinit file is in your Podfile pre_install or post_install actions. It is suggested to add the following lines
132
+
133
+ ```
134
+ pid = spawn("pod_builder generate_lldbinit")
135
+ Process.detach(pid)
136
+ ```
137
+
138
+ To generate lldbinit file. We're generating it asynchronously to avoid unnecessarily slow down `pod install` since this file will be needed only when build and running your application.
139
+
140
+ #### `switch` command
141
+
142
+ Once you prebuild a framework you can change the way it is integrated in your project.
143
+
144
+ Using the switch command you can choose to integrate it:
145
+
146
+ - standard. Reverts to the default one used by CocoaPods
147
+ - development. The _Development Pod_ used by CocoaPods
148
+ - prebuilt. Use the prebuilt pod
149
+
150
+ To support development pods you should specify the path(s) that contain the pods sources in _PodBuilder/PodBuilderDevPodsPaths.json_ as follows
151
+
152
+ ```json
153
+ [
154
+ "~/path_to_pods_1",
155
+ "~/path_to_pods_2",
156
+ ]
157
+ ```
158
+
159
+ PodBuilder will automatically determine the proper path when switching a particular pod.
160
+
161
+ #### `clean` command
162
+
163
+ Deletes all unused files by PodBuilder, including .frameworks, .dSYMs and _Source_ repos.
164
+
165
+ #### `sync_podfile` command
166
+
167
+ Updates the Application with all pods declared in the PodBuilder-Podfile file. This can come in handy when adding a new pod to the PodBuilder-Podfile file you don't won't to prebuild straight away.
168
+
169
+ #### `info` command
170
+
171
+ Outputs json-formatted information reflecting the current status of prebuilt pods.
172
+
173
+ The output hash contains one key for each pod containing the following keys:
174
+
175
+ - `framework_path`: the expected path for the prebuilt framework
176
+ - `restore_info.version`: the expected version for the pod
177
+ - `restore_info.specs`: the expected list of specs for the pod
178
+ - `restore_info.is_static`: true if the expected pod produces a static framework
179
+ - `restore_info.swift_version`: the expected swift compiler version to prebuild pod
180
+ - `prebuilt_info`: some additional information about the the prebuilt framework, if it exists on disk
181
+ - `prebuilt_info.version`: the version of the pod that produced the current prebuilt framework
182
+ - `prebuilt_info.specs`: the specs of the pod that produced the current prebuilt framework (there might be multiple subspec that produce a single .framework)
183
+ - `prebuilt_info.is_static`: true if the current prebuilt framework is static
184
+ - `prebuilt_info.swift_version`: the swift compiler version that produced the current prebuilt framework
185
+
186
+ **Version format**
187
+
188
+ `restore_version` and `prebuilt_info.version` are hashes containing the following keys:
189
+ - `tag`: pods pinned to a specific tag of the CocoaPods official Specs
190
+ - `repo`, `hash`: pods pointing to an external repo + commit
191
+ - `repo`, `branch`: pods pointing to an external repo + branch
192
+ - `repo`, `tag`: pods pointing to an external repo + tag
193
+
194
+
195
+ # Configuration file
196
+
197
+ _PodBuilder.json_ allows some advanced customizations.
198
+
199
+ ## Supported keys
200
+
201
+ #### `spec_overrides`
202
+
203
+ This hash allows to add/replace keys in a podspec specification. This can be useful to solve compilation issue or change compilation behaviour (e.g. compile framework statically by specifying `static_framework = true`) without having to fork the repo.
204
+
205
+ The key is the pod name, the value a hash with the keys of the podspec that need to be overridden.
206
+
207
+ As an example here we're setting `module_name` in Google's Advertising SDK:
208
+
209
+ ```json
210
+ {
211
+ "spec_overrides": {
212
+ "Google-Mobile-Ads-SDK": {
213
+ "module_name": "GoogleMobileAds"
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ### `skip_pods`
220
+
221
+ You may want to skip some pods to be prebuilt, you can do that as follows:
222
+
223
+ ```json
224
+ {
225
+ "skip_pods": [
226
+ "PodA"
227
+ ]
228
+ }
229
+ ```
230
+
231
+
232
+ ### `force_prebuild_pods`
233
+
234
+ You may want to force some pods to be prebuilt, this might be the case for prebuilt ones (pods with a single vendored .framework) which are dependencies of othere pods
235
+
236
+ ```json
237
+ {
238
+ "force_prebuild_pods": [
239
+ "PodA"
240
+ ]
241
+ }
242
+ ```
243
+
244
+
245
+ #### `build_settings`
246
+
247
+ Xcode build settings to use. You can override the default values which are:
248
+
249
+ ```json
250
+ {
251
+ "build_settings": {
252
+ "ENABLE_BITCODE": "NO",
253
+ "GCC_OPTIMIZATION_LEVEL": "s",
254
+ "SWIFT_OPTIMIZATION_LEVEL": "-Osize",
255
+ "SWIFT_COMPILATION_MODE": "wholemodule"
256
+ }
257
+ }
258
+ ```
259
+
260
+ If your project uses bitcode change "ENABLE_BITCODE" to "YES". Please note that all pods that have dependencies to XCTest need to be add a `"ENABLE_BITCODE": "NO"` to the `build_settings_overrides` below.
261
+
262
+ #### `build_settings_overrides`
263
+
264
+ Like `build_settings` but per pod. Pod name can also refer to subspec.
265
+
266
+ ```json
267
+ {
268
+ "build_settings_overrides": {
269
+ "PodA": {
270
+ "SWIFT_OPTIMIZATION_LEVEL": "-O"
271
+ },
272
+ "PodB/Subspec": {
273
+ "APPLICATION_EXTENSION_API_ONLY": "NO"
274
+ }
275
+ }
276
+ }
277
+ ```
278
+
279
+ #### `build_system`
280
+
281
+ Specify which build system to use to compile frameworks. Either `Legacy` (standard build system) or `Latest` (new build system). Default value: `Latest`.
282
+
283
+ #### `build_xcframeworks`
284
+
285
+ Specify if PodBuilder will build .xcframeworks. Will enable `library_evolution_support`. Default value: false
286
+
287
+ #### `library_evolution_support`
288
+
289
+ Specify if Swift frameworks should be compiled with library evolution support (BUILD_LIBRARY_FOR_DISTRIBUTION). Default value: false
290
+
291
+ #### `license_filename`
292
+
293
+ PodBuilder will create two license files a plist and a markdown file which contains the licenses of each pod specified in the PodBuilder-Podfile. Defailt value: `Pods-acknowledgements`(plist|md).
294
+
295
+ #### `project_name`
296
+
297
+ In complex project setups you may end up with the following error: "Found multiple xcodeproj/xcworkspaces...". If that is the case you can specify the name of your main project manually. For example if your application's project is "Example.xcworkspace" set the value for this key to `Example`.
298
+
299
+ #### `allow_building_development_pods`
300
+
301
+ Building development pods is by default not allowed unless you explicitly pass the allow_warnings flag. You can override this behavior by setting this key to true
302
+
303
+ #### `skip_licenses`
304
+
305
+ PodBuilder writes a plist and markdown license files of pods specified in the PodBuilder-Podfile. You can specify pods that should not be included, for example for private pods.
306
+
307
+ ```json
308
+ {
309
+ "skip_licenses": ["Podname1", "Podname2"]
310
+ }
311
+ ```
312
+
313
+ #### `use_bundler`
314
+
315
+ If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
316
+
317
+
318
+ # Behind the scenes
319
+
320
+ PodBuilder leverages CocoaPods code and [cocoapods-rome plugin](https://github.com/CocoaPods/Prebuilt) to compile pods into frameworks. Every compiled framework will be boxed (by adding it as a `vendored_framework`) as a subspec of a local podspec. When needed additional settings will be automatically ported from the original podspec, like for example xcconfig settings.
321
+
322
+ # FAQ
323
+
324
+ ### **I get an _'`PodWithError` does not specify a Swift version and none of the targets (`DummyTarget`)'_ when building**
325
+
326
+ The podspec of the Pod you're trying to build doesn't specify the swift_version which is required in recent versions of CocoaPods. Either contact the author/mantainer of the Pod asking it to fix the podspec or add a `spec_overrides` in _PodBuilder.json_.
327
+
328
+ ```json
329
+ "spec_overrides": {
330
+ "PodWithError": {
331
+ "swift_version": "5.3"
332
+ }
333
+ }
334
+ ```
335
+
336
+ ### **After prebuilding my project no longer compiles**
337
+
338
+ A common problem you may encounter is with Objective-C imports. You should verify that you're properly importing all the headers of your pods with the angle bracket notation `#import <FrameworkName/HeaderFile.h>` instead of directly importing `#import "HeaderFile.h"`.
339
+
340
+ How to proceed in these cases?
341
+ 1. Rebuild all frameworks with PodBuilder
342
+ 2. Switch all your pods (use switch command or manually edit your Application-Podfile) back to the standard integration
343
+ 3. One-by-one switch your pods back to prebuilt, verifying everytime that your Project still compiles.
344
+
345
+
346
+ ### **Do I need to commit compiled frameworks?**
347
+
348
+ No. If the size of compiled frameworks in your repo is a concern (and for whatever reason you can't use [Git-LFS](#git-lfs)) you can choose add the _Prebuilt_ and _dSYM_ folder to .gitignore and run `pod_builder update` to rebuild all frameworks that need to be recompiled.
349
+
350
+
351
+ ### **I get an _'attempt to read non existent folder `/private/tmp/pod_builder/Pods/ podname'_ when building**
352
+
353
+ Please open an issue here. You may also add the name of the pod to the [`skip_pods`](#skip_pods) key in the configuration file and try rebuilding again.
354
+
355
+ # Git LFS
356
+
357
+ We high encourage to use PodBuilder in combination with Git LFS. Tacking PodBuilder/Prebuilt/**/*.framework/* and PodBuilder/Prebuilt/**/*.a and PodBuilder/dSYM/**/* will ensure that your repo size stays under control with all the benefits of having prebuilt dependencies ready to use.
358
+
359
+
360
+ # Try it out!
361
+
362
+ Under _Example_ there's a sample project with a Podfile adding [Alamofire](https://github.com/Alamofire/Alamofire) you can use to try PodBuilder out.
363
+
364
+ $ pod_builder init
365
+ $ pod_builder build_all
366
+
367
+ This will initialize the project to use PodBuilder and prebuild Alamofire, open the project in Xcode and compile.
368
+
369
+ # Contributing
370
+
371
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Subito-it/PodBuilder.
372
+
373
+
374
+ # Caveats
375
+
376
+ Code isn't probably the cleanest I ever wrote but given the usefulness of the tool I decided to publish it nevertheless.
377
+
378
+
379
+ # Authors
380
+
381
+ [Tomas Camin](https://github.com/tcamin) ([@tomascamin](https://twitter.com/tomascamin))
382
+
383
+ # License
384
+
385
+ The gem is available under the Apache License, Version 2.0. See the LICENSE file for more info.
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task :default => :spec
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require 'pod_builder/core'
5
+ require 'pod_builder/version'
6
+ require 'pod_builder/command'
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require "pry"
13
+ # Pry.start
14
+
15
+ require "irb"
16
+ IRB.start(__FILE__)