pod-builder 0.9.9 ā†’ 1.0.0

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: a5d7b7bb753baab42ba1ebf90cff6c4f46160a0e0161336a0d9c035ce2a0d7b2
4
- data.tar.gz: 431039e01adb554df23b8832be48f3908994b39945d5242881e780824f3be3a9
3
+ metadata.gz: 5281c507a89f44af31e4f826d10c45cfd5c68e7b62ed3b3c66d840181909f95d
4
+ data.tar.gz: 139f7835eedc3030378a5fa53fd7cd80fec8739fc5c0bccec9e654fc8199d711
5
5
  SHA512:
6
- metadata.gz: 438e67d0ed933e30f4556bbf9ab8c60a4a6af038a973bfdc735cc3fb6a45ee1805a0ad8d3dcaa0794c0e28cc2b165ca1aa55025abd90b9e3c2e5112f0e402d46
7
- data.tar.gz: 63aec152527fc2c7592b136350e84c950350449fe307192593169a03d3990c102f5198948c411d5d2f207c5520cf1fa3c971ecee2ae569b84678adc9755b22b9
6
+ metadata.gz: e7468475cbaf61dd82f5360b41678377b12aac63f6637e794777a1064dcbcaf194ad56ad966eeaf19d0f79be28475f52c9314b6fa9773bd52d7dc944d8587cdd
7
+ data.tar.gz: f8522731ffaa190fe6024dc7675d2a2231c064189557cfb352e3ef363c975213379c54d02b9385fd5605fdfde33b4bb6dca108517edfa8bc88ef9767761c9f55
data/README.md CHANGED
@@ -94,7 +94,11 @@ Will recompile all pods to the versions defined in the Restore-Podfile. You woul
94
94
 
95
95
  #### `install_sources` command
96
96
 
97
- 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 _Frameworks/Sources_ and with some [tricks](https://medium.com/@t.camin/debugging-prebuilt-frameworks-c9f52d42600b) restores the ability to step into the pods code. 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.
97
+ 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 _Frameworks/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.
98
+
99
+ #### `update_lldbinit` command
100
+
101
+ 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 the `~/.lldbinit-Xcode` file which will restore the ability to use the debugger and step into the code of your prebuilt dependencies.
98
102
 
99
103
  #### `switch` command
100
104
 
data/exe/pod_builder CHANGED
@@ -31,7 +31,8 @@ Command:
31
31
  + build_all Build all pods declared in the PodBuilder-Podfile
32
32
  + update Rebuild frameworks that are outdated
33
33
  + restore_all Rebuild all pods declared in the Restore-Podfile
34
- + install_sources Install sources of pods to debug into prebuild frameworks
34
+ + install_sources Install sources of pods to debug into prebuilt frameworks
35
+ + update_lldbinit Update ~/.lldbinit-Xcode setting target.source-map to debug prebuilt frameworks
35
36
  + switch Switch between prebuilt/development/standard pod in the Application-Podfile
36
37
  + clean Remove prebuild frameworks, dSYMs and source files added by `install_sources` command that are no longer in the PodBuilder-Podfile
37
38
  + sync_podfile Update your Application-Podfile with all pods declared in the PodBuilder-Podfile
@@ -233,8 +234,7 @@ Usage:
233
234
  $ pod_builder install_sources
234
235
 
235
236
  Install source of prebuilt pods to be able to step into and debug framework's code.
236
-
237
- Options:
237
+
238
238
  "
239
239
  end,
240
240
  :call => [
@@ -242,6 +242,25 @@ Options:
242
242
  ]
243
243
  },
244
244
 
245
+ "update_lldbinit" => {
246
+ :opts => OptionParser.new do |opts|
247
+ opts.banner = "
248
+ Usage:
249
+
250
+ $ pod_builder install_sources PATH
251
+
252
+ Update ~/.lldbinit-Xcode setting target.source-map in order to be able to step into
253
+ and debug framework's code.
254
+
255
+ Specify the PATH of the folder containing the source code of prebuilt frameworks. PATH can be relative to PodBuilder's Framework folder.
256
+
257
+ "
258
+ end,
259
+ :call => [
260
+ PodBuilder::Command::UpdateLldbInit
261
+ ]
262
+ },
263
+
245
264
  "switch" => {
246
265
  :opts => OptionParser.new do |opts|
247
266
  opts.banner = "
@@ -12,3 +12,4 @@ require 'pod_builder/command/switch'
12
12
  require 'pod_builder/command/generate_lfs'
13
13
  require 'pod_builder/command/sync_podfile'
14
14
  require 'pod_builder/command/info'
15
+ require 'pod_builder/command/update_lldbinit'
@@ -25,7 +25,8 @@ module PodBuilder
25
25
 
26
26
  Command::Clean::clean_sources()
27
27
 
28
- rewrite_lldinit
28
+ ARGV << PodBuilder::basepath("Sources")
29
+ Command::UpdateLldbInit::call(options)
29
30
 
30
31
  puts "\n\nšŸŽ‰ done!\n".green
31
32
  return 0
@@ -66,32 +67,6 @@ module PodBuilder
66
67
 
67
68
  return nil
68
69
  end
69
-
70
- def self.rewrite_lldinit
71
- puts "Writing ~/.lldbinit-Xcode".yellow
72
-
73
- lldbinit_path = File.expand_path('~/.lldbinit-Xcode')
74
- FileUtils.touch(lldbinit_path)
75
-
76
- lldbinit_lines = []
77
- File.read(lldbinit_path).each_line do |line|
78
- if lldbinit_lines.include?(line.strip()) ||
79
- line.start_with?("settings set target.source-map") ||
80
- line.strip() == "" then
81
- next
82
- end
83
-
84
- lldbinit_lines.push(line)
85
- end
86
-
87
- build_path = "#{PodBuilder::Configuration.build_path}/Pods"
88
- source_path = PodBuilder::basepath("Sources")
89
-
90
- lldbinit_lines.push("settings set target.source-map '#{build_path}' '#{source_path}'")
91
- lldbinit_lines.push("")
92
-
93
- File.write(lldbinit_path, lldbinit_lines.join("\n"))
94
- end
95
70
  end
96
71
  end
97
72
  end
@@ -0,0 +1,137 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class UpdateLldbInit
6
+ def self.call(options)
7
+ Configuration.check_inited
8
+ PodBuilder::prepare_basepath
9
+
10
+ argument_pods = ARGV.dup
11
+
12
+ unless argument_pods.count > 0
13
+ return -1
14
+ end
15
+ unless argument_pods.count == 1
16
+ raise "\n\nSpecify a single PATH to the folder containing the prebuilt framework's source code\n\n".red
17
+ end
18
+
19
+ base_path = PodBuilder::basepath("")
20
+ path = argument_pods[0]
21
+
22
+ is_absolute = ["~", "/"].include?(path[0])
23
+ if !is_absolute
24
+ path = Pathname.new(File.join(base_path, path))
25
+ end
26
+
27
+ path = File.expand_path(path)
28
+
29
+ framework_paths = Dir.glob("#{base_path}/**/*.framework")
30
+
31
+ unless framework_paths.count > 0
32
+ raise "\n\nNo prebuilt frameworks found in `#{path}`\n\n".red
33
+ end
34
+
35
+ puts "Extracting debug information".yellow
36
+
37
+ podspec_paths = Dir.glob("#{path}/**/*.podspec") + Dir.glob("#{path}/**/*.podspec.json")
38
+ podspec_contents = podspec_paths.map { |t| File.read(t).gsub(/\s+/, "").gsub("\"", "'") }
39
+
40
+ replace_paths = []
41
+
42
+ framework_paths.each do |framework_path|
43
+ name = File.basename(framework_path, File.extname(framework_path))
44
+ executable_path = File.join(framework_path, name)
45
+
46
+ dwarf_dump_lib = `dwarfdump --debug-info #{executable_path} | grep '#{Configuration.build_base_path}' | head -n 1`.strip()
47
+
48
+ if (matches = dwarf_dump_lib.match(/#{Configuration.build_base_path}(.*)\/Pods/)) && matches.size == 2
49
+ original_compile_path = "#{Configuration.build_base_path}#{matches[1]}/Pods/#{name}"
50
+
51
+ if podspec_path = find_podspec_path_for(name, podspec_paths, podspec_contents)
52
+ replace_paths.push("#{original_compile_path},#{File.dirname(podspec_path)}")
53
+ else
54
+ puts "Failed to find podspec for #{name}".blue
55
+ end
56
+ else
57
+ # Look for path in dSYM
58
+ dsym_paths = Dir.glob("#{base_path}/**/iphonesimulator/#{name}.framework.dSYM")
59
+ dsym_paths.each do |dsym_path|
60
+ name = File.basename(dsym_path, ".framework.dSYM")
61
+ dsym_dwarf_path = File.join(dsym_path, "Contents/Resources/DWARF")
62
+ dsym_dwarf_path = File.join(dsym_dwarf_path, name)
63
+
64
+ dwarf_dump_lib = `dwarfdump --debug-info #{dsym_dwarf_path} | grep '#{Configuration.build_base_path}' | head -n 1`.strip()
65
+
66
+ if (matches = dwarf_dump_lib.match(/#{Configuration.build_base_path}(.*)\/Pods/)) && matches.size == 2
67
+ original_compile_path = "#{Configuration.build_base_path}#{matches[1]}/Pods/#{name}"
68
+
69
+ if podspec_path = find_podspec_path_for(name, podspec_paths, podspec_contents)
70
+ replace_paths.push("#{original_compile_path},#{File.dirname(podspec_path)}")
71
+ else
72
+ puts "Failed to find podspec for #{name}".blue
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ replace_paths.uniq!
80
+
81
+ source_map_lines = replace_paths.flat_map { |t| ["# <pb>", "settings append target.source-map '#{t.split(",").first}' '#{t.split(",").last}'"] }
82
+ if source_map_lines.count > 1
83
+ # first occurrance should be a set
84
+ source_map_lines[1] = source_map_lines[1].gsub("settings append target.source-map", "settings set target.source-map")
85
+ end
86
+ rewrite_lldinit(source_map_lines)
87
+
88
+ puts "\n\nšŸŽ‰ done!\n".green
89
+ return 0
90
+ end
91
+
92
+ def self.find_podspec_path_for(name, podspec_paths, podspec_contents)
93
+ if (path = podspec_paths.detect { |t| File.basename(t, ".podspec") == name.gsub("_", "-") })
94
+ return path
95
+ elsif (path_index = podspec_contents.find_index { |t| t.include?(".module_name='#{name}'") })
96
+ return podspec_paths[path_index]
97
+ elsif (path_index = podspec_contents.find_index { |t| t.include?(".name='#{name}") }) # kind of optimistic,, but a last resort
98
+ return podspec_paths[path_index]
99
+ elsif (path_index = podspec_contents.find_index { |t| t.include?("'module_name':'#{name}'") }) # [json podspec]
100
+ return podspec_paths[path_index]
101
+ elsif (path_index = podspec_contents.find_index { |t| t.include?("'name':'#{name}") }) # [json podspec] kind of optimistic,, but a last resort
102
+ return podspec_paths[path_index]
103
+ else
104
+ return nil
105
+ end
106
+ end
107
+
108
+ def self.rewrite_lldinit(source_map_lines)
109
+ puts "Writing ~/.lldbinit-Xcode".yellow
110
+
111
+ lldbinit_path = File.expand_path('~/.lldbinit-Xcode')
112
+ FileUtils.touch(lldbinit_path)
113
+
114
+ lldbinit_lines = []
115
+ skipNext = false
116
+ File.read(lldbinit_path).each_line do |line|
117
+ if line.include?("# <pb>")
118
+ skipNext = true
119
+ next
120
+ elsif skipNext
121
+ skipNext = false
122
+ next
123
+ elsif line != "\n"
124
+ if line.include?("settings set target.source-map")
125
+ raise "\n\n~/.lldbinit-Xcode already includes a manual `settings set target.source-map`. This is unsupported and you'll have to manually remove that entry\n"
126
+ end
127
+ lldbinit_lines.push(line)
128
+ end
129
+ end
130
+
131
+ lldbinit_lines += source_map_lines
132
+
133
+ File.write(lldbinit_path, lldbinit_lines.join("\n"))
134
+ end
135
+ end
136
+ end
137
+ end
@@ -36,6 +36,7 @@ module PodBuilder
36
36
  attr_accessor :license_filename
37
37
  attr_accessor :subspecs_to_split
38
38
  attr_accessor :development_pods_paths
39
+ attr_accessor :build_base_path
39
40
  attr_accessor :build_path
40
41
  attr_accessor :configuration_filename
41
42
  attr_accessor :dev_pods_configuration_filename
@@ -60,7 +61,8 @@ module PodBuilder
60
61
  @license_filename = "Pods-acknowledgements"
61
62
  @subspecs_to_split = []
62
63
  @development_pods_paths = []
63
- @build_path = "/tmp/pod_builder_#{(Time.now.to_f * 1000).to_i}".freeze
64
+ @build_base_path = "/tmp/pod_builder_".freeze
65
+ @build_path = "#{build_base_path}#{(Time.now.to_f * 1000).to_i}".freeze
64
66
  @configuration_filename = "PodBuilder.json".freeze
65
67
  @dev_pods_configuration_filename = "PodBuilderDevPodsPaths.json".freeze
66
68
  @lfs_min_file_size = MIN_LFS_SIZE_KB
@@ -1,4 +1,4 @@
1
1
  module PodBuilder
2
- VERSION = "0.9.9"
2
+ VERSION = "1.0.0"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pod-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Camin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-16 00:00:00.000000000 Z
11
+ date: 2020-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -254,6 +254,7 @@ files:
254
254
  - lib/pod_builder/command/switch.rb
255
255
  - lib/pod_builder/command/sync_podfile.rb
256
256
  - lib/pod_builder/command/update.rb
257
+ - lib/pod_builder/command/update_lldbinit.rb
257
258
  - lib/pod_builder/configuration.rb
258
259
  - lib/pod_builder/core.rb
259
260
  - lib/pod_builder/info.rb