Class: CodeSigner

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CodeSigner

Returns a new instance of CodeSigner.



3
4
5
6
7
8
9
10
11
# File 'lib/ipa_utilities/code_signer.rb', line 3

def initialize(options)
  @ipa_path = check_file_exist(options[:ipa_path], "Cannot find file at '%s'",)
  @profile = check_file_exist(options[:profile], "Cannot find file at '%s'") if options[:profile]

  @output_path = options[:output_path] || "~/Desktop/resigned.ipa"

  @identity = check_non_nil(options[:identity], "Identity cannot be nil")
  @bundle_id = options[:bundle_id]
end

Class Method Details

.signature_valid?(ipa) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/ipa_utilities/code_signer.rb', line 13

def self.signature_valid?(ipa)
  system("codesign -v #{ipa.app_path} 2>&1")
  $?.exitstatus == 0
end

Instance Method Details

#resignObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ipa_utilities/code_signer.rb', line 18

def resign
  ipa = IpaParser.new(@ipa_path)
  @app_path = ipa.app_path

  delete_old_signature
  embed_profile
  update_bundle_id(ipa.info_plist)

  cmd = "codesign -s '#{@identity}' '#{ipa.app_path}' -f"
  puts cmd if $verbose
  system(cmd)
  ipa.zip(@output_path)
  ipa.cleanup
end

#update_bundle_id(info_plist) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ipa_utilities/code_signer.rb', line 33

def update_bundle_id(info_plist)
  return unless @bundle_id

  puts "Applying new bundle id '#{@bundle_id.green}'"
  info_plist.bundle_id = @bundle_id
  info_plist.save
end