Skip to content

Instantly share code, notes, and snippets.

@zhzhxtrrk
Created May 17, 2013 09:13

Revisions

  1. zhzhxtrrk created this gist May 17, 2013.
    36 changes: 36 additions & 0 deletions sign.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    require 'pathname'
    require 'fileutils'

    if ARGV.size < 3
    puts "Usage: ruby sign.rb App DeveloperId Provision"
    exit
    end

    puts "Working"

    name = ARGV[0]
    ipa = "#{name}.ipa"
    app = "#{name}.app"
    developer_id = ARGV[1]
    provision = ARGV[2]

    target_ipa = Pathname.new(File.dirname(__FILE__)).realpath + "#{name}_resigned.ipa"

    if not File.exists? ipa
    puts "#{ipa} not found"
    end

    begin
    FileUtils.rmtree 'Payload'
    FileUtils.rmtree app

    puts `unzip #{ipa}`
    FileUtils.mv "Payload/#{app}", '.'

    puts `xcrun --sdk iphoneos PackageApplication -s "#{developer_id}" --embed "#{provision}" "#{app}" -o "#{target_ipa}"`

    FileUtils.rmtree 'Payload'
    FileUtils.rmtree app
    rescue
    puts "Error, #{$!}"
    end