pod-builder 2.0.0.beta.25 ā†’ 2.0.0.beta.30

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b20eb1955937c42e11f9e8e261f40a907a50a7225a6a892915963d82b99317
4
- data.tar.gz: 3a2b45e51f95e4573bfc29838181f823fa9c12b754c751cb0506c28c3a09a60c
3
+ metadata.gz: d4cde0acf0b503aaa846162710c25456d306b0ae6e53492b717795e4540f5b9f
4
+ data.tar.gz: ddfc897b5dd2d280a2b5e636706d62c854d01bb34f605b813d70a48ace6fad75
5
5
  SHA512:
6
- metadata.gz: 7ca77c2cce6fdc77c95a6748cbaf1cf08dc6163cf0906ae09a90a05373832d5dc35c4a4b04a57a00776bed873eb5cbee590127749d5d93cd621b85fd88ec5eed
7
- data.tar.gz: 22d3bc57f93f27118788ecd95097eaa9d522032e6a19fd5f9ab673834fb2d3655c5f9387b57cbdd01cf77b3d41ad39e59563151e2680cd5bccea938cacb14b42
6
+ metadata.gz: 5f468d84983dc689b5dceef947da7d3ce586bd2d34be76ec439a236ba45435a6865b54d154233fdae038352ff1582cb68fcfdc520e5a101ed4842d86cde3e973
7
+ data.tar.gz: f45e9377fd79dff65b9c72580a29308172cc3cf3410093c2a6d2a7c9245c7000bc732b4d78473dd58ef14a3712a7cb9697bf87e7cd8331f8b413e0f550c04cc4
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
- #### `update_lldbinit` command
121
+ #### `generate_lldbinit` command
122
122
 
123
- In some situations you may already have source code for your prebuilt frameworks (e.g. committed in your repo). 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. This will update a custom specified `lldbinit` file which will restore the ability to use the debugger and step into the code of your prebuilt dependencies.
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
- The `lldbinit` should not be autoloaded from Xcode (e.g. should not be placed under ~/.lldbinit-Xcode) because it can cause weird issues with debugging. Instead load the file using a shared breakpoint placed at the beginning loading by invoking a
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
- #### `clear_lldbinit` command
129
+ ````
130
+ pid = spawn("pod_builder generate_lldbinit")
131
+ Process.detach(pid)
132
+ ```
129
133
 
130
- Run this command to remove PodBuilder's customizations from the specified `lldbinit`.
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
 
@@ -296,28 +300,6 @@ PodBuilder writes a plist and markdown license files of pods specified in the Po
296
300
  }
297
301
  ```
298
302
 
299
- #### `subspecs_to_split`
300
-
301
- Normally when multiple subspecs are specified in a target a single framework is produced. There are rare cases where you specify different subspecs in different targets: a typical case is subspec specifically designed for app extensions, where you want to use a subspec in the main app and another one in the app extension.
302
-
303
- **Warning**: This will work properly only for static frameworks (_static_framework = true_ specified in the podspec). See [issue](https://github.com/CocoaPods/CocoaPods/issues/5708) and [issue](https://github.com/CocoaPods/CocoaPods/issues/5643)
304
-
305
- ```json
306
- {
307
- "subspecs_to_split": ["Podname1/Subspec1", "Podname1/Subspec2", "Podname2/Subspec1", "Podname2/Subspec1"]
308
- }
309
- ```
310
-
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
303
  #### `use_bundler`
322
304
 
323
305
  If you use bundler to pin the version of CocoaPods in your project set this to true. Default false.
@@ -358,11 +340,6 @@ How to proceed in these cases?
358
340
  3. One-by-one switch your pods back to prebuilt, verifying everytime that your Project still compiles.
359
341
 
360
342
 
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
343
  ### **Do I need to commit compiled frameworks?**
367
344
 
368
345
  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 +351,8 @@ Please open an issue here. You may also add the name of the pod to the [`skip_po
374
351
 
375
352
  # Git LFS
376
353
 
377
- PodBuilder integrates with [Git Large File Storage](https://git-lfs.github.com) to move large files, like the prebuilt frameworks, out of your git repo. This allows to benefit from the compilation speed ups of the precompiled frameworks without impacting on your repo overall size.
354
+ 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
355
 
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
356
 
381
357
  # Try it out!
382
358
 
@@ -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
- + update_lldbinit Generate an lldbinit file with setting target.source-map to debug prebuilt items
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] = false
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
@@ -80,6 +79,9 @@ Options:
80
79
  # opts.on("-a", "--auto-resolve-deps", "Resolve pod dependencies automatically") do |o|
81
80
  # OPTIONS[:auto_resolve_dependencies] = o
82
81
  # end
82
+ opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
83
+ OPTIONS[:no_stdin_available] = o
84
+ end
83
85
  opts.on("-d", "--debug", "Don't clean build folder") do |o|
84
86
  OPTIONS[:debug] = o
85
87
  end
@@ -109,6 +111,9 @@ Options:
109
111
  opts.on("-w", "--allow-warnings", "Allow warnings") do |o|
110
112
  OPTIONS[:allow_warnings] = o
111
113
  end
114
+ opts.on("-s", "--no-stdin", "Never request interaction with sdtin (e.g. in CI environment)") do |o|
115
+ OPTIONS[:no_stdin_available] = o
116
+ end
112
117
  opts.on("-d", "--debug", "Don't clean build folder") do |o|
113
118
  OPTIONS[:debug] = o
114
119
  end
@@ -198,14 +203,6 @@ Options:
198
203
  ]
199
204
  },
200
205
 
201
- "update_lfs" => {
202
- :opts => OptionParser.new do |opts|
203
- end,
204
- :call => [
205
- PodBuilder::Command::GenerateLFS
206
- ]
207
- },
208
-
209
206
  "deintegrate" => {
210
207
  :opts => OptionParser.new do |opts|
211
208
  opts.banner = "
@@ -259,40 +256,27 @@ Usage:
259
256
  ]
260
257
  },
261
258
 
262
- "update_lldbinit" => {
259
+ "generate_lldbinit" => {
263
260
  :opts => OptionParser.new do |opts|
264
261
  opts.banner = "
265
262
  Usage:
266
263
 
267
- $ pod_builder update_lldbinit <LLDBINIT_PATH> <PATH>
264
+ $ pod_builder generate_lldbinit [PATH]
268
265
 
269
- Update LLDBINIT_PATH setting target.source-map in order to be able to step into
270
- and debug prebuilt prebuilt's code.
266
+ Update PodBuilder's custom lldbinit by setting the target.source-map which allows to
267
+ step into and debug prebuilt prebuilt's code. To allow this to work it is required
268
+ to specify a path containing the source code that generated the prebuilt item.
271
269
 
272
- Specify the PATH of the folder containing the source code of prebuilt items. PATH can be relative to PodBuilder's Prebuilt folder.
273
-
274
- "
270
+ You can pass a [PATH] which PodBuilder will use to look for dependencies's source code.
271
+ If omitted it will be implied that the project is organized as a monorepo expecting
272
+ source code dependencies to live in the project repo.
273
+ "
275
274
  end,
276
275
  :call => [
277
276
  PodBuilder::Command::UpdateLldbInit
278
277
  ]
279
278
  },
280
279
 
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
280
  "switch" => {
297
281
  :opts => OptionParser.new do |opts|
298
282
  opts.banner = "
@@ -397,7 +381,7 @@ begin
397
381
  rescue Exception => e
398
382
  error = e.to_s
399
383
 
400
- if error.length < 1000
384
+ if error.length < 1000 || !File.directory?(PodBuilder::Configuration.build_path)
401
385
  puts "#{error.red}\n"
402
386
  puts e.backtrace.join("\n\t").red
403
387
  puts "\n\nCommand failed!".red
@@ -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/update_lldbinit'
16
- require 'pod_builder/command/clear_lldbinit'
14
+ require 'pod_builder/command/generate_lldbinit'
@@ -49,55 +49,50 @@ module PodBuilder
49
49
 
50
50
  restore_file_error = Podfile.restore_file_sanity_check
51
51
 
52
- check_splitted_subspecs_are_static(all_buildable_items)
53
52
  check_pods_exists(argument_pods, all_buildable_items)
54
53
 
55
54
  pods_to_build = resolve_pods_to_build(argument_pods, buildable_items)
56
55
  buildable_items -= pods_to_build
57
56
 
58
57
  # We need to split pods to build in 3 groups
59
- # 1. subspecs: because the resulting .framework path is treated differently when added to Configuration.subspecs_to_split
60
- # 2. pods to build in release
61
- # 3. pods to build in debug
58
+ # 1. pods to build in release
59
+ # 2. pods to build in debug
62
60
 
63
61
  check_not_building_development_pods(pods_to_build)
64
62
 
65
- pods_to_build_subspecs = pods_to_build.select { |x| x.is_subspec && Configuration.subspecs_to_split.include?(x.name) }
66
-
67
63
  # Remove dependencies from pods to build
68
64
  all_dependencies_name = pods_to_build.map(&:dependency_names).flatten.uniq
69
65
  pods_to_build.select! { |x| !all_dependencies_name.include?(x.name) }
70
66
 
71
- pods_to_build -= pods_to_build_subspecs
72
67
  pods_to_build_debug = pods_to_build.select { |x| x.build_configuration == "debug" }
73
68
  pods_to_build_release = pods_to_build - pods_to_build_debug
74
69
 
75
70
  check_dependencies_build_configurations(all_buildable_items)
76
71
 
77
- podfiles_items = pods_to_build_subspecs.map { |x| [x] }
78
- podfiles_items.push(pods_to_build_debug)
79
- podfiles_items.push(pods_to_build_release)
72
+ podfiles_items = [pods_to_build_debug] + [pods_to_build_release]
80
73
 
81
- licenses = []
74
+ install_using_frameworks = Podfile::install_using_frameworks(analyzer)
82
75
 
83
- podfiles_items.select { |x| x.count > 0 }.each do |podfile_items|
76
+ install_result = InstallResult.new
77
+ podfiles_items.reject { |x| x.empty? }.each do |podfile_items|
84
78
  build_configuration = podfile_items.map(&:build_configuration).uniq.first
85
79
 
86
80
  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)
81
+ podfile_content = Podfile.from_podfile_items(podfile_items, analyzer, build_configuration, install_using_frameworks)
88
82
 
89
- licenses += Install.podfile(podfile_content, podfile_items, podfile_items.first.build_configuration)
83
+ install_result += Install.podfile(podfile_content, podfile_items, podfile_items.first.build_configuration)
90
84
 
91
85
  # remove lockfile which gets unexplicably created
92
86
  FileUtils.rm_f(PodBuilder::basepath("Podfile.lock"))
93
87
  end
94
88
 
89
+ install_result.write_prebuilt_info_files
90
+
95
91
  Clean::prebuilt_items(all_buildable_items)
96
92
 
97
- Licenses::write(licenses, all_buildable_items)
93
+ Licenses::write(install_result.licenses, all_buildable_items)
98
94
 
99
- GenerateLFS::call()
100
- Podspec::generate(all_buildable_items, analyzer)
95
+ Podspec::generate(all_buildable_items, analyzer, install_using_frameworks)
101
96
 
102
97
  builded_pods = podfiles_items.flatten
103
98
 
@@ -140,24 +135,6 @@ module PodBuilder
140
135
  end
141
136
  end
142
137
 
143
- def self.check_splitted_subspecs_are_static(all_buildable_items)
144
- non_static_subspecs = all_buildable_items.select { |x| x.is_subspec && x.is_static == false }
145
- non_static_subspecs_names = non_static_subspecs.map(&:name)
146
-
147
- invalid_subspecs = Configuration.subspecs_to_split & non_static_subspecs_names # intersect
148
-
149
- unless invalid_subspecs.count > 0
150
- return
151
- end
152
-
153
- 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
- if OPTIONS[:allow_warnings]
155
- puts "\n\nāš ļø #{warn_message}".yellow
156
- else
157
- raise "\n\nšŸšØļø #{warn_message}".red
158
- end
159
- end
160
-
161
138
  def self.check_dependencies_build_configurations(pods)
162
139
  pods.each do |pod|
163
140
  pod_dependency_names = pod.dependency_names.select { |x| !pod.has_common_spec(x) }
@@ -197,9 +174,9 @@ module PodBuilder
197
174
  if !expected_stripped.all? { |x| stripped_lines.include?(x) }
198
175
  warn_message = "PodBuilder's post install actions missing from application Podfile!\n"
199
176
  if OPTIONS[:allow_warnings]
200
- puts "\n\nāš ļø #{warn_message}".yellow
177
+ puts "\n\n#{warn_message}".yellow
201
178
  else
202
- raise "\n\nšŸšØļø #{warn_message}".red
179
+ raise "\n\n#{warn_message}".red
203
180
  end
204
181
  end
205
182
  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(File.join(PodBuilder::prebuiltpath, "*")).each do |path|
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
@@ -65,7 +65,7 @@ module PodBuilder
65
65
 
66
66
  paths_to_delete.flatten.each do |path|
67
67
  confirm = ask("#{path} unused.\nDelete it? [Y/N] ") { |yn| yn.limit = 1, yn.validate = /[yn]/i }
68
- if confirm.downcase == 'y'
68
+ if confirm.downcase == 'y' || OPTIONS.has_key?(:no_stdin_available)
69
69
  PodBuilder::safe_rm_rf(path)
70
70
  end
71
71
  end
@@ -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