pod-builder 2.0.0.beta.22 ā 2.0.0.beta.27
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 +4 -4
- data/README.md +10 -22
- data/exe/pod_builder +12 -34
- data/lib/pod_builder/command.rb +1 -3
- data/lib/pod_builder/command/build.rb +62 -15
- data/lib/pod_builder/command/clean.rb +14 -1
- data/lib/pod_builder/command/generate_lldbinit.rb +151 -0
- data/lib/pod_builder/command/generate_podspec.rb +3 -1
- data/lib/pod_builder/command/init.rb +26 -12
- data/lib/pod_builder/command/install_sources.rb +2 -2
- data/lib/pod_builder/configuration.rb +22 -22
- data/lib/pod_builder/core.rb +17 -7
- data/lib/pod_builder/install.rb +291 -120
- data/lib/pod_builder/podfile.rb +23 -7
- data/lib/pod_builder/podfile_cp.rb +11 -5
- data/lib/pod_builder/podfile_item.rb +33 -39
- data/lib/pod_builder/podspec.rb +82 -29
- data/lib/pod_builder/rome/post_install.rb +169 -42
- data/lib/pod_builder/templates/build_podfile.template +1 -1
- data/lib/pod_builder/version.rb +1 -1
- metadata +3 -5
- data/lib/pod_builder/command/clear_lldbinit.rb +0 -48
- data/lib/pod_builder/command/generate_lfs.rb +0 -70
- data/lib/pod_builder/command/update_lldbinit.rb +0 -162
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44ff676a26caedcecf597f47315839aa7b6785d34f77c61d72fba8125473fdac
|
4
|
+
data.tar.gz: 761a04159150170ee9f826d05e0664d18b679252820c582f4ddb5fef925feb18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84fed9f6fdbeed8adc3b79c7dab9d037d67c066437be938823a0feb3257c1dce27fe74800cfb5f8672c06a568f02a766325840ca54acc471eea40acd54c05c2b
|
7
|
+
data.tar.gz: 92ce97f49e9dd1a10604a7b6cafe30c47d9c202afad83aef212eab025a756c8ec70d99eb8bcff90b14ae0d4a18bdac0eb9e0f9f80e309e69b94e93619dd20f13
|
data/README.md
CHANGED
@@ -118,16 +118,20 @@ Will recompile all pods to the versions defined in the Restore-Podfile. You woul
|
|
118
118
|
|
119
119
|
When using PodBuilder you loose ability to directly access to the source code of a pod. 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.
|
120
120
|
|
121
|
-
#### `
|
121
|
+
#### `generate_lldbinit` command
|
122
122
|
|
123
|
-
In some situations you may already have source code for your prebuilt frameworks
|
123
|
+
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.
|
124
124
|
|
125
|
-
|
125
|
+
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`.
|
126
126
|
|
127
|
+
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
|
127
128
|
|
128
|
-
|
129
|
+
````
|
130
|
+
pid = spawn("pod_builder generate_lldbinit")
|
131
|
+
Process.detach(pid)
|
132
|
+
```
|
129
133
|
|
130
|
-
|
134
|
+
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.
|
131
135
|
|
132
136
|
#### `switch` command
|
133
137
|
|
@@ -308,16 +312,6 @@ Normally when multiple subspecs are specified in a target a single framework is
|
|
308
312
|
}
|
309
313
|
```
|
310
314
|
|
311
|
-
#### `lfs_update_gitattributes`Ā
|
312
|
-
|
313
|
-
Adds a _.gitattributes_ to _PodBuilder/Prebuilt_ and _PodBuilder/dSYM_ to exclude large files. If `lfs_include_pods_folder` is true it will add a the same _.gitattributes_ to the application's _Pods_ folder as well.
|
314
|
-
|
315
|
-
|
316
|
-
#### `lfs_include_pods_folder`
|
317
|
-
|
318
|
-
See [`lfs_update_gitattributes`](#lfs_update_gitattributes).
|
319
|
-
|
320
|
-
|
321
315
|
#### `use_bundler`
|
322
316
|
|
323
317
|
If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
|
@@ -358,11 +352,6 @@ How to proceed in these cases?
|
|
358
352
|
3. One-by-one switch your pods back to prebuilt, verifying everytime that your Project still compiles.
|
359
353
|
|
360
354
|
|
361
|
-
### **Build failed with longish output to the stdout, what should I do next?**
|
362
|
-
|
363
|
-
Relaunch the build command passing `-d`, this won't delete the temporary _/tmp/pod_builder_ folder on failure. Open _/tmp/pod_builder/Pods/Pods.xcproject_, make the Pods-DummyTarget target visible by clicking on _Show_ under _Product->Scheme->Manage shemes..._ and build from within Xcode. This will help you understand what went wrong. Remeber to verify that you're building the _Release_ build configuration.
|
364
|
-
|
365
|
-
|
366
355
|
### **Do I need to commit compiled frameworks?**
|
367
356
|
|
368
357
|
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.
|
@@ -374,9 +363,8 @@ Please open an issue here. You may also add the name of the pod to the [`skip_po
|
|
374
363
|
|
375
364
|
# Git LFS
|
376
365
|
|
377
|
-
PodBuilder
|
366
|
+
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.
|
378
367
|
|
379
|
-
When [`lfs_update_gitattributes = true`](#lfs_update_gitattributes) PodBuilder will automatically update the _.gitattributes_ with the files generated by PodBuilder when building pods.
|
380
368
|
|
381
369
|
# Try it out!
|
382
370
|
|
data/exe/pod_builder
CHANGED
@@ -39,8 +39,7 @@ Command:
|
|
39
39
|
+ update Rebuild items that are outdated
|
40
40
|
+ restore_all Rebuild all pods declared in the Restore-Podfile
|
41
41
|
+ install_sources Install sources of pods to debug into prebuilt items
|
42
|
-
+
|
43
|
-
+ clear_lldbinit Clear an lldbinit file from PodBuilder's customizations
|
42
|
+
+ generate_lldbinit Generate an lldbinit file with setting target.source-map to debug prebuilt items
|
44
43
|
+ switch Switch between prebuilt/development/standard pod in the Application-Podfile
|
45
44
|
+ clean Remove prebuild items, dSYMs and source files added by `install_sources` command that are no longer in the PodBuilder-Podfile
|
46
45
|
+ sync_podfile Update your Application-Podfile with all pods declared in the PodBuilder-Podfile
|
@@ -72,7 +71,7 @@ Options:
|
|
72
71
|
OPTIONS[:update_repos] = false
|
73
72
|
end
|
74
73
|
opts.on("-f", "--force", "Rebuild items even when no code change is detected") do |o|
|
75
|
-
OPTIONS[:force_rebuild] =
|
74
|
+
OPTIONS[:force_rebuild] = true
|
76
75
|
end
|
77
76
|
opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
|
78
77
|
OPTIONS[:allow_warnings] = o
|
@@ -198,14 +197,6 @@ Options:
|
|
198
197
|
]
|
199
198
|
},
|
200
199
|
|
201
|
-
"update_lfs" => {
|
202
|
-
:opts => OptionParser.new do |opts|
|
203
|
-
end,
|
204
|
-
:call => [
|
205
|
-
PodBuilder::Command::GenerateLFS
|
206
|
-
]
|
207
|
-
},
|
208
|
-
|
209
200
|
"deintegrate" => {
|
210
201
|
:opts => OptionParser.new do |opts|
|
211
202
|
opts.banner = "
|
@@ -259,40 +250,27 @@ Usage:
|
|
259
250
|
]
|
260
251
|
},
|
261
252
|
|
262
|
-
"
|
253
|
+
"generate_lldbinit" => {
|
263
254
|
:opts => OptionParser.new do |opts|
|
264
255
|
opts.banner = "
|
265
256
|
Usage:
|
266
257
|
|
267
|
-
$ pod_builder
|
268
|
-
|
269
|
-
Update LLDBINIT_PATH setting target.source-map in order to be able to step into
|
270
|
-
and debug prebuilt prebuilt's code.
|
258
|
+
$ pod_builder generate_lldbinit [PATH]
|
271
259
|
|
272
|
-
|
260
|
+
Update PodBuilder's custom lldbinit by setting the target.source-map which allows to
|
261
|
+
step into and debug prebuilt prebuilt's code. To allow this to work it is required
|
262
|
+
to specify a path containing the source code that generated the prebuilt item.
|
273
263
|
|
274
|
-
|
264
|
+
You can pass a [PATH] which PodBuilder will use to look for dependencies's source code.
|
265
|
+
If omitted it will be implied that the project is organized as a monorepo expecting
|
266
|
+
source code dependencies to live in the project repo.
|
267
|
+
"
|
275
268
|
end,
|
276
269
|
:call => [
|
277
270
|
PodBuilder::Command::UpdateLldbInit
|
278
271
|
]
|
279
272
|
},
|
280
273
|
|
281
|
-
"clear_lldbinit" => {
|
282
|
-
:opts => OptionParser.new do |opts|
|
283
|
-
opts.banner = "
|
284
|
-
Usage:
|
285
|
-
|
286
|
-
$ pod_builder clear_lldbinit <LLDBINIT_PATH>
|
287
|
-
|
288
|
-
Clear LLDBINIT_PATH setting target.source-map PodBuilder's customizations
|
289
|
-
"
|
290
|
-
end,
|
291
|
-
:call => [
|
292
|
-
PodBuilder::Command::ClearLldbInit
|
293
|
-
]
|
294
|
-
},
|
295
|
-
|
296
274
|
"switch" => {
|
297
275
|
:opts => OptionParser.new do |opts|
|
298
276
|
opts.banner = "
|
@@ -397,7 +375,7 @@ begin
|
|
397
375
|
rescue Exception => e
|
398
376
|
error = e.to_s
|
399
377
|
|
400
|
-
if error.length < 1000
|
378
|
+
if error.length < 1000 || !File.directory?(PodBuilder::Configuration.build_path)
|
401
379
|
puts "#{error.red}\n"
|
402
380
|
puts e.backtrace.join("\n\t").red
|
403
381
|
puts "\n\nCommand failed!".red
|
data/lib/pod_builder/command.rb
CHANGED
@@ -9,8 +9,6 @@ require 'pod_builder/command/deintegrate'
|
|
9
9
|
require 'pod_builder/command/generate_podspec'
|
10
10
|
require 'pod_builder/command/install_sources'
|
11
11
|
require 'pod_builder/command/switch'
|
12
|
-
require 'pod_builder/command/generate_lfs'
|
13
12
|
require 'pod_builder/command/sync_podfile'
|
14
13
|
require 'pod_builder/command/info'
|
15
|
-
require 'pod_builder/command/
|
16
|
-
require 'pod_builder/command/clear_lldbinit'
|
14
|
+
require 'pod_builder/command/generate_lldbinit'
|
@@ -49,7 +49,7 @@ module PodBuilder
|
|
49
49
|
|
50
50
|
restore_file_error = Podfile.restore_file_sanity_check
|
51
51
|
|
52
|
-
|
52
|
+
check_splitted_subspecs_are_buildable(all_buildable_items, installer)
|
53
53
|
check_pods_exists(argument_pods, all_buildable_items)
|
54
54
|
|
55
55
|
pods_to_build = resolve_pods_to_build(argument_pods, buildable_items)
|
@@ -62,42 +62,44 @@ module PodBuilder
|
|
62
62
|
|
63
63
|
check_not_building_development_pods(pods_to_build)
|
64
64
|
|
65
|
-
pods_to_build_subspecs = pods_to_build
|
65
|
+
pods_to_build_subspecs = splitted_pods_to_build(pods_to_build, installer)
|
66
66
|
|
67
67
|
# Remove dependencies from pods to build
|
68
68
|
all_dependencies_name = pods_to_build.map(&:dependency_names).flatten.uniq
|
69
69
|
pods_to_build.select! { |x| !all_dependencies_name.include?(x.name) }
|
70
70
|
|
71
|
-
pods_to_build -= pods_to_build_subspecs
|
71
|
+
pods_to_build -= pods_to_build_subspecs.flatten
|
72
72
|
pods_to_build_debug = pods_to_build.select { |x| x.build_configuration == "debug" }
|
73
73
|
pods_to_build_release = pods_to_build - pods_to_build_debug
|
74
74
|
|
75
75
|
check_dependencies_build_configurations(all_buildable_items)
|
76
76
|
|
77
|
-
podfiles_items = pods_to_build_subspecs
|
77
|
+
podfiles_items = pods_to_build_subspecs
|
78
78
|
podfiles_items.push(pods_to_build_debug)
|
79
79
|
podfiles_items.push(pods_to_build_release)
|
80
80
|
|
81
|
-
|
81
|
+
install_using_frameworks = Podfile::install_using_frameworks(analyzer)
|
82
82
|
|
83
|
-
|
83
|
+
install_result = InstallResult.new
|
84
|
+
podfiles_items.reject { |x| x.empty? }.each do |podfile_items|
|
84
85
|
build_configuration = podfile_items.map(&:build_configuration).uniq.first
|
85
86
|
|
86
87
|
podfile_items = podfile_items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten.uniq
|
87
|
-
podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration)
|
88
|
+
podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks)
|
88
89
|
|
89
|
-
|
90
|
+
install_result += Install.podfile(podfile_content, podfile_items, podfile_items.first.build_configuration)
|
90
91
|
|
91
92
|
# remove lockfile which gets unexplicably created
|
92
93
|
FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
|
93
94
|
end
|
94
95
|
|
96
|
+
install_result.write_prebuilt_info_files
|
97
|
+
|
95
98
|
Clean::prebuilt_items(all_buildable_items)
|
96
99
|
|
97
|
-
Licenses::write(licenses, all_buildable_items)
|
100
|
+
Licenses::write(install_result.licenses, all_buildable_items)
|
98
101
|
|
99
|
-
|
100
|
-
Podspec::generate(all_buildable_items, analyzer)
|
102
|
+
Podspec::generate(all_buildable_items, analyzer, install_using_frameworks)
|
101
103
|
|
102
104
|
builded_pods = podfiles_items.flatten
|
103
105
|
|
@@ -123,6 +125,20 @@ module PodBuilder
|
|
123
125
|
|
124
126
|
private
|
125
127
|
|
128
|
+
def self.splitted_pods_to_build(pods_to_build, installer)
|
129
|
+
specs_by_target = installer.analysis_result.specs_by_target
|
130
|
+
|
131
|
+
pods_to_build_subspecs = pods_to_build.select { |x| x.is_subspec && Configuration.subspecs_to_split.include?(x.name) }
|
132
|
+
|
133
|
+
pods = []
|
134
|
+
specs_by_target.each do |target, specs|
|
135
|
+
grouped = pods_to_build_subspecs.group_by { |t| specs.map(&:name).include?(t.name) }
|
136
|
+
pods.push(grouped[true])
|
137
|
+
end
|
138
|
+
|
139
|
+
return pods.compact
|
140
|
+
end
|
141
|
+
|
126
142
|
def self.check_not_building_subspecs(pods_to_build)
|
127
143
|
pods_to_build.each do |pod_to_build|
|
128
144
|
if pod_to_build.include?("/")
|
@@ -140,6 +156,37 @@ module PodBuilder
|
|
140
156
|
end
|
141
157
|
end
|
142
158
|
|
159
|
+
def self.check_splitted_subspecs_are_buildable(all_buildable_items, installer)
|
160
|
+
check_splitted_subspecs_are_static(all_buildable_items)
|
161
|
+
check_splitted_subspecs_have_valid_dependencies(all_buildable_items)
|
162
|
+
check_splitted_subspecs_not_in_multiple_targets(all_buildable_items, installer)
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.check_splitted_subspecs_have_valid_dependencies(all_buildable_items)
|
166
|
+
splitted_items = all_buildable_items.select { |t| Configuration.subspecs_to_split.include?(t.name) }
|
167
|
+
splitted_items.each do |splitted_item|
|
168
|
+
common_deps = splitted_item.dependency_names.select { |t| t.start_with?(splitted_item.root_name) }
|
169
|
+
|
170
|
+
if common_deps.count > 0
|
171
|
+
raise "\n\nSubspecs included in 'subspecs_to_split' cannot have dependencies to other subspecs within the spec.\n\n#{splitted_item.name} has dependencies to: '#{common_deps.join(', ')}'\n\n".red
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.check_splitted_subspecs_not_in_multiple_targets(all_buildable_items, installer)
|
177
|
+
specs_by_target = installer.analysis_result.specs_by_target
|
178
|
+
|
179
|
+
flat_item_names = specs_by_target.values.flatten.map(&:name)
|
180
|
+
|
181
|
+
splitted_items = all_buildable_items.select { |t| Configuration.subspecs_to_split.include?(t.name) }
|
182
|
+
|
183
|
+
splitted_items.each do |splitted_item|
|
184
|
+
if flat_item_names.count(splitted_item.name) > 1
|
185
|
+
raise "\n\n'#{splitted_item.name}' is included in 'subspecs_to_split' but it is used in multiple targets. This is unsupported.\nIf possible duplicate the subspec '#{splitted_item.name}' in the podspec using different names for each target.\n".red
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
143
190
|
def self.check_splitted_subspecs_are_static(all_buildable_items)
|
144
191
|
non_static_subspecs = all_buildable_items.select { |x| x.is_subspec && x.is_static == false }
|
145
192
|
non_static_subspecs_names = non_static_subspecs.map(&:name)
|
@@ -152,9 +199,9 @@ module PodBuilder
|
|
152
199
|
|
153
200
|
warn_message = "The following pods `#{invalid_subspecs.join(" ")}` are non static binaries which are being splitted over different targets. Beware that this is an unsafe setup as per https://github.com/CocoaPods/CocoaPods/issues/5708 and https://github.com/CocoaPods/CocoaPods/issues/5643\n\nYou can ignore this error by passing the `--allow-warnings` flag to the build command\n"
|
154
201
|
if OPTIONS[:allow_warnings]
|
155
|
-
puts "\n\n
|
202
|
+
puts "\n\n#{warn_message}".yellow
|
156
203
|
else
|
157
|
-
raise "\n\n
|
204
|
+
raise "\n\n#{warn_message}".red
|
158
205
|
end
|
159
206
|
end
|
160
207
|
|
@@ -197,9 +244,9 @@ module PodBuilder
|
|
197
244
|
if !expected_stripped.all? { |x| stripped_lines.include?(x) }
|
198
245
|
warn_message = "PodBuilder's post install actions missing from application Podfile!\n"
|
199
246
|
if OPTIONS[:allow_warnings]
|
200
|
-
puts "\n\n
|
247
|
+
puts "\n\n#{warn_message}".yellow
|
201
248
|
else
|
202
|
-
raise "\n\n
|
249
|
+
raise "\n\n#{warn_message}".red
|
203
250
|
end
|
204
251
|
end
|
205
252
|
end
|
@@ -23,7 +23,7 @@ module PodBuilder
|
|
23
23
|
puts "Cleaning prebuilt folder".yellow
|
24
24
|
|
25
25
|
root_names = buildable_items.map(&:root_name).uniq
|
26
|
-
Dir.glob(
|
26
|
+
Dir.glob(PodBuilder::prebuiltpath("*")).each do |path|
|
27
27
|
basename = File.basename(path)
|
28
28
|
unless root_names.include?(basename)
|
29
29
|
puts "Cleanining up `#{basename}`, no longer found among dependencies".blue
|
@@ -31,6 +31,19 @@ module PodBuilder
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
splitted_specs = buildable_items.select { |t| Configuration.subspecs_to_split.include?(t.name) }
|
35
|
+
splitted_specs.each do |splitted_spec|
|
36
|
+
root_name = splitted_spec.root_name
|
37
|
+
|
38
|
+
Dir.glob(PodBuilder::prebuiltpath("#{root_name}/Subspecs/*")).each do |path|
|
39
|
+
basename = File.basename(path)
|
40
|
+
unless splitted_specs.map(&:podspec_name).include?(basename)
|
41
|
+
puts "Cleanining up `#{root_name}/#{basename}`, no longer found among dependencies".blue
|
42
|
+
PodBuilder::safe_rm_rf(path)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
puts "Cleaning dSYM folder".yellow
|
35
48
|
module_names = buildable_items.map(&:module_name).uniq
|
36
49
|
Dir.glob(File.join(PodBuilder::dsympath, "**/*.dSYM")).each do |path|
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'pod_builder/core'
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
module PodBuilder
|
5
|
+
module Command
|
6
|
+
class UpdateLldbInit
|
7
|
+
def self.call
|
8
|
+
Configuration.check_inited
|
9
|
+
if Configuration.build_using_repo_paths
|
10
|
+
raise "\n\nlldb shenanigans not supported when 'build_using_repo_paths' is enabled".red
|
11
|
+
end
|
12
|
+
|
13
|
+
arguments = ARGV.dup
|
14
|
+
|
15
|
+
if arguments.count > 0
|
16
|
+
source_path = arguments[0]
|
17
|
+
if !is_absolute_path(source_path)
|
18
|
+
source_path = PodBuilder::basepath(source_path)
|
19
|
+
end
|
20
|
+
source_path = File.expand_path(source_path)
|
21
|
+
|
22
|
+
raise "\n\nSpecified path does not exists" unless File.directory?(source_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
base_path = PodBuilder::basepath
|
26
|
+
|
27
|
+
app_podfile_content = File.read(PodBuilder::project_path("Podfile"))
|
28
|
+
podfile_hash = Digest::MD5.hexdigest(app_podfile_content)
|
29
|
+
|
30
|
+
lldbinit_path = File.expand_path(PodBuilder::basepath(Configuration.lldbinit_name))
|
31
|
+
lldbinit_content = File.exist?(lldbinit_path) ? File.read(lldbinit_path) : ""
|
32
|
+
|
33
|
+
if lldbinit_content.include?("# <pb_md5:#{base_path}:#{podfile_hash}")
|
34
|
+
puts "\n\nš already in sync!\n".green
|
35
|
+
return 0
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "Extracting debug information".yellow
|
39
|
+
|
40
|
+
unless source_path.nil?
|
41
|
+
podspec_paths = Dir.glob("#{source_path}/**/*.podspec") + Dir.glob("#{source_path}/**/*.podspec.json")
|
42
|
+
podspec_contents = podspec_paths.map { |t| File.read(t).gsub(/\s+/, "").gsub("\"", "'") }
|
43
|
+
end
|
44
|
+
|
45
|
+
source_map_lines = []
|
46
|
+
Dir.glob("#{PodBuilder::prebuiltpath}/**/#{Configuration.prebuilt_info_filename}").each do |path|
|
47
|
+
data = JSON.parse(File.read(path))
|
48
|
+
next if data.fetch("is_prebuilt", true)
|
49
|
+
|
50
|
+
# It would be much nicer if PodBuilder.json already contained this info in a custom key
|
51
|
+
pod_name_matches = data["entry"].match(/pod '(.*?)'/)
|
52
|
+
next unless pod_name_matches&.size == 2
|
53
|
+
|
54
|
+
podspec_name = pod_name_matches[1]
|
55
|
+
podspec_path = "#{File.dirname(path)}/#{podspec_name}.podspec"
|
56
|
+
|
57
|
+
next unless File.exist?(podspec_path)
|
58
|
+
|
59
|
+
build_source_path_matches = data["entry"].match(/:path => '(.*?)'/)
|
60
|
+
if build_source_path_matches&.size == 2
|
61
|
+
build_source_path = build_source_path_matches[1]
|
62
|
+
|
63
|
+
if !is_absolute_path(build_source_path[0])
|
64
|
+
build_source_path = PodBuilder::basepath(build_source_path)
|
65
|
+
end
|
66
|
+
build_source_path = File.expand_path(build_source_path)
|
67
|
+
elsif source_path.nil?
|
68
|
+
next
|
69
|
+
else
|
70
|
+
# Find source code for podspec_name
|
71
|
+
podspec_path = find_podspec_path_for(podspec_name, podspec_paths, podspec_contents)
|
72
|
+
next if podspec_path.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
original_compile_path = data["original_compile_path"] + "/Pods/#{podspec_name}"
|
76
|
+
if is_prebuilt_pod(podspec_path, app_podfile_content)
|
77
|
+
unless source_map_lines.include?("settings append target.source-map '#{original_compile_path}'")
|
78
|
+
source_map_lines.push("# <pb:#{base_path}>\n", "settings append target.source-map '#{original_compile_path}' '#{build_source_path}'\n")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
rewrite_lldinit(lldbinit_path, source_map_lines, base_path, podfile_hash)
|
84
|
+
|
85
|
+
puts "\n\nš done!\n".green
|
86
|
+
return 0
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def self.is_absolute_path(path)
|
92
|
+
return ["~", "/"].any? { |t| t.start_with?(t) }
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.is_prebuilt_pod(podspec_path, app_podfile_content)
|
96
|
+
development_path = Pathname.new(podspec_path).relative_path_from(Pathname.new(PodBuilder::project_path)).parent.to_s
|
97
|
+
|
98
|
+
return app_podfile_content.include?(":path => '#{development_path}'")
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.rewrite_lldinit(lldbinit_path, source_map_lines, base_path, podfile_hash)
|
102
|
+
puts "Writing #{lldbinit_path}".yellow
|
103
|
+
|
104
|
+
FileUtils.touch(lldbinit_path)
|
105
|
+
raise "\n\nDestination file should be a file".red unless File.exist?(lldbinit_path)
|
106
|
+
|
107
|
+
lldbinit_lines = []
|
108
|
+
skipNext = false
|
109
|
+
File.read(lldbinit_path).each_line do |line|
|
110
|
+
if line.include?("# <pb:#{base_path}>") || line.include?("# <pb>")
|
111
|
+
skipNext = true
|
112
|
+
next
|
113
|
+
elsif skipNext
|
114
|
+
skipNext = false
|
115
|
+
next
|
116
|
+
elsif line != "\n"
|
117
|
+
if line.include?("settings set target.source-map")
|
118
|
+
raise "\n\n#{lldbinit_destination_path} already includes a manual `settings set target.source-map`. This is unsupported and you'll have to manually remove that entry\n".red
|
119
|
+
end
|
120
|
+
lldbinit_lines.push(line)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
source_map_lines.insert(0, "# <pb>\n")
|
125
|
+
source_map_lines.insert(1, "settings clear target.source-map\n")
|
126
|
+
source_map_lines.insert(2, "# <pb:#{base_path}>\n")
|
127
|
+
source_map_lines.insert(3, "# <pb_md5:#{base_path}:#{podfile_hash}>\n")
|
128
|
+
|
129
|
+
lldbinit_lines += source_map_lines
|
130
|
+
|
131
|
+
File.write(lldbinit_path, lldbinit_lines.join())
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.find_podspec_path_for(name, podspec_paths, podspec_contents)
|
135
|
+
if (path = podspec_paths.detect { |t| File.basename(t, ".podspec") == name.gsub("_", "-") })
|
136
|
+
return path
|
137
|
+
elsif (path_index = podspec_contents.find_index { |t| t.include?(".module_name='#{name}'") })
|
138
|
+
return podspec_paths[path_index]
|
139
|
+
elsif (path_index = podspec_contents.find_index { |t| t.include?(".name='#{name}") }) # kind of optimistic,, but a last resort
|
140
|
+
return podspec_paths[path_index]
|
141
|
+
elsif (path_index = podspec_contents.find_index { |t| t.include?("'module_name':'#{name}'") }) # [json podspec]
|
142
|
+
return podspec_paths[path_index]
|
143
|
+
elsif (path_index = podspec_contents.find_index { |t| t.include?("'name':'#{name}") }) # [json podspec] kind of optimistic,, but a last resort
|
144
|
+
return podspec_paths[path_index]
|
145
|
+
else
|
146
|
+
return nil
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|