Module: Codeobscure
- Defined in:
- lib/codeobscure.rb,
lib/codeobscure/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.obscure ⇒ Object
waiting for add optionparse and add class obscure.
- .root ⇒ Object
Class Method Details
.obscure ⇒ Object
waiting for add optionparse and add class obscure
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/codeobscure.rb', line 17 def self.obscure = {} OptionParser.new do |opts| opts. = "Usage: obscure code for object-c project" opts.on("-o", "--obscure XcodeprojPath", "obscure code") do |v| [:obscure] = v end opts.on("-l", "--load path1,path2,path3",Array,"load filt symbols from path") do |v| [:load] = v end opts.on("-r", "--reset", "reset loaded symbols") do |v| [:reset] = true end opts.on("-f", "--fetch type1,type2,type3", "fetch and replace type,default type is [c,p,f].c for class,p for property,f for function") do |v| [:fetch] = v end end.parse! if [:reset] `rm -f #{root_dir}/filtSymbols` `cp #{root_dir}/filtSymbols_standard #{root_dir}/filtSymbols` end #only load, execute load only #only obscure, execute obscure only #load and obscure at same time,load firt,then obscure.That's mean you can get rid of some directoies. load_pathes = [:load] if load_pathes load_pathes.each do |load_path| if File.exist? load_path FiltSymbols.loadFiltSymbols load_path puts "加载完毕!".colorize(:green) else puts "指定的目录不存在:#{path}".colorize(:red) end end end fetch_types = ["p","c","f"] if [:fetch].length > 0 fetch_types = [:fetch] end if [:obscure] xpj_path = [:obscure] if File.exist? xpj_path root_dir = xpj_path.split("/")[0...-1].join "/" FuncList.genFuncList root_dir , "all", true, fetch_types header_file = Obscure.run root_dir project = Xcodeproj::Project.open xpj_path project_name = xpj_path.split("/").last main_group = project.main_group if !main_group.find_file_by_path("codeObfuscation.h") main_group.new_reference header_file end project.targets.each do |target| if target.name = project_name build_configs = target.build_configurations build_configs.each do |build_config| build_settings = build_config.build_settings prefix_key = "GCC_PREFIX_HEADER" prefix_header = build_settings[prefix_key] if prefix_header.nil? || prefix_header.empty? build_config.build_settings[prefix_key] = "./codeObfuscation.h" elsif prefix_header.include? "codeObfuscation.h" puts "#{target.name}:#{build_config}配置文件已配置完成".colorize(:green) else puts "请在#{prefix_header.class.name}中#import \"codeObfuscation.h\"".colorize(:green) end end end end project.save puts "配置完成!".colorize(:green) puts "请直接运行项目,如果项目中出现类似: `+[LoremIpsum PyTJvHwWNmeaaVzp:]: unrecognized selector sent to class`。在codeObfuscation.h中查询PyTJvHwWNmeaaVzp并删除它!".colorize(:yellow) else puts "指定的目录不存在:#{path}".colorize(:red) end end end |
.root ⇒ Object
12 13 14 |
# File 'lib/codeobscure.rb', line 12 def self.root File.dirname __dir__ end |