Class: XcodeUnsigner

Inherits:
Object
  • Object
show all
Extended by:
CLI
Defined in:
lib/xcode_unsigner.rb

Class Method Summary collapse

Methods included from CLI

chown_if_required, codesign_exists?, dry_run?, no_colors?, non_interactive?, restore_xcode?, separator, unsign_xcode?, update_plugins?

Class Method Details

.noticeObject



85
86
87
88
89
90
91
92
93
94
# File 'lib/xcode_unsigner.rb', line 85

def self.notice
  puts [
    '取消Xcode的签名将会跳过插件的签名验证,从而允许加载插件'.colorize(:yellow),
    '然而,未签名的Xcode会产生一定的安全风险,Apple和你的系统都会不信任未签名的Xcode'\
    '请不要使用未签名的Xcode进行打包操作,正常开发没有问题'.colorize(:red),
    "这个工具会产生签名文件的备份,以便于之后你可以用下面的命令安装reuse_xcode_plugins和恢复签名\n",
    '$ gem install reuse_xcode_plugins'.colorize(:light_blue),
    '$ reuse_xcode_plugins --restore'.colorize(:light_blue)
  ]
end

.restore_xcodeObject



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
# File 'lib/xcode_unsigner.rb', line 42

def self.restore_xcode
  process '正在查找安装的 Xcode...'
  xcodes = Xcode.find_xcodes
                .select { |xcode| xcode.version.to_f >= 8 }
                .select(&:restorable?)

  separator

  if xcodes.empty?
    error "没有发现任何可恢复签名的 Xcode 8+."
    return
  end

  selection = Ask.list "选择你想要恢复签名的 Xcode(按上下键改变箭头)", xcodes
  return unless selection

  xcode = xcodes[selection]

  separator

  process '正在恢复签名...'

  success = true

  if xcode.binary_restorable? && !xcode.restore_binary!
    error "未能恢复 #{xcode.path} 的签名\n"\
          '请联系mPaaS开发者'
    success = false
  end

  if xcode.xcodebuild_restorable? && !xcode.restore_xcodebuild!
    error "未能恢复 xcodebuild 的签名\n"\
          '请联系mPaaS开发者'
    success = false
  end

  success '完成! 🎉' if success
end

.unsign_xcodeObject



6
7
8
9
10
11
12
13
14
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
# File 'lib/xcode_unsigner.rb', line 6

def self.unsign_xcode
  process '正在查找安装的 Xcode...'
  xcodes = Xcode.find_xcodes
                .select { |xcode| xcode.version.to_f >= 8 }
                .select(&:signed?)

  separator

  if xcodes.empty?
    error "没有发现任何有签名的 Xcode 8+."
    return
  end

  notice
  separator

  selection = Ask.list "选择你想要去掉签名的 Xcode(按上下键改变箭头)", xcodes
  return unless selection

  xcode = xcodes[selection]

  # unsign_xcodebuild = Ask.confirm "Unsign xcodebuild too?"
  unsign_xcodebuild = true

  separator

  process '正在去除签名...'
  if xcode.unsign_binary! &&
     (!unsign_xcodebuild || (unsign_xcodebuild && xcode.unsign_xcodebuild!))
    success '完成! 🎉'
  else
    error "未能取消 #{xcode.path} 的签名\n"\
          '请联系mPaaS开发者'
  end
end

.update_pluginsObject



81
82
83
# File 'lib/xcode_unsigner.rb', line 81

def self.update_plugins

end