15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/private-dumper.rb', line 15
def self.run!(*args)
if args.size < 2
puts "Usage: "
puts "private-dumper <iOS SDK version> <path to headers output directory>"
puts
puts "Please provide both the iOS SDK version you want to dump (for example 4.2) and the path to the output directory."
puts "Example: private-dumper 4.2 ~/Headers"
puts
puts "NOTE: You need to have class-dump (http://www.codethecode.com/projects/class-dump/) installed and in your $PATH!"
return -1
end
sdk_version = args[0]
sdk_path = "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator#{sdk_version}.sdk/"
if !File.exists?(sdk_path)
puts "The directory #{sdk_path} does not exist. Did you possibly provide an invalid SDK version?"
return -2
end
= args[1]
if !File.exists?()
Dir.mkdir(File.expand_path())
end
if !File.exists?()
puts "The output directory #{} does not exist and could not be created."
return -3
end
["#{sdk_path}System/Library/Frameworks", "#{sdk_path}System/Library/PrivateFrameworks", "#{sdk_path}Developer/Library/Frameworks", "#{sdk_path}Developer/Library/PrivateFrameworks"].each do |frmwk_path|
puts frmwk_path
Dir["#{frmwk_path}/**/*.framework"].sort.each do |frmwk|
frmwk_name = File.basename(frmwk, '.*')
puts "Framework: #{frmwk_name}"
cmd = "#{CLASS_DUMP} -H -o #{}/#{frmwk_name} -s -S #{frmwk}"
if !system(cmd)
puts "Command #{cmd} failed with exit code #{$?.exitstatus}"
else
puts "Fixing imports..."
Dir["#{}/#{frmwk_name}/*.h"].each do ||
lines = []
File.open(, 'r') do ||
.each_line do |line|
if line =~ /#import\s<#{frmwk_name}\/([^\.]*\.h)>/
line = %{#import "#{$1}"}
end
lines << line unless line =~ /#import\s"NSObject\.h"/
end
end
File.open(, 'w') {|| .puts lines.join("\n")}
end
end
end
end
puts "Done."
return 0
end
|