Class: Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/signer.rb

Instance Method Summary collapse

Constructor Details

#initializeSigner

Returns a new instance of Signer.



5
6
7
# File 'lib/signer.rb', line 5

def initialize
  @codesign_identity = "-"
end

Instance Method Details

#codeSignDylib(dylib) ⇒ Object

sign the dynamic library

Parameters:

  • dylib

    the dylib’s path

Returns:

  • true or false



43
44
45
46
# File 'lib/signer.rb', line 43

def codeSignDylib(dylib)
  command = "export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate; /usr/bin/codesign --force -s '#{@codesign_identity}' '#{dylib}'"
  system(command)
end

#parse_codesign_identity(exe_path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/signer.rb', line 21

def parse_codesign_identity(exe_path)
  codesign_identity = "-"
  stdout, stdeerr, status = Open3.capture3("codesign -vv -d #{exe_path}")
  array = stdeerr.split("\n")
  array.each do |item|
    if item.include?("Authority=")
      start = "Authority="
      codesign_identity = item[start.length, item.length]
      break
    end
  end


  @codesign_identity = codesign_identity
end

#pre_codesign(build_log_dir, is_real_device) ⇒ Object

pre codesign



10
11
12
13
14
15
16
17
18
19
# File 'lib/signer.rb', line 10

def pre_codesign(build_log_dir, is_real_device)
  build_folder = is_real_device ? "Debug-iphoneos" : "Debug-iphonesimulator"
  exe_path = build_log_dir.split("/")[0..-3].join("/") + "/Build/Products/#{build_folder}"
  exe_path = "#{exe_path}/*.app"
  exe_path = Dir[exe_path].sort!{ |x,y| File.mtime(y) <=> File.mtime(x) }[0]
  if File.exist?(exe_path)
    parse_codesign_identity(exe_path)
  end
  true
end