Class: IOSDevTools::Sign
- Inherits:
-
Object
- Object
- IOSDevTools::Sign
- Defined in:
- lib/ios_dev_tools/commands/sign.rb
Class Method Summary collapse
Instance Method Summary collapse
- #error_msg(message) ⇒ Object
- #execute ⇒ Object
-
#initialize(options) ⇒ Sign
constructor
A new instance of Sign.
- #verbose_msg(message) ⇒ Object
Constructor Details
#initialize(options) ⇒ Sign
Returns a new instance of Sign.
15 16 17 18 19 20 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 15 def initialize @options= @be_verbose=([:verbose]!=nil) end |
Class Method Details
.create_with_args(cmd_line_arguments) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 8 def self.create_with_args cmd_line_arguments = cmd_line_arguments return Sign.new end |
.display_help ⇒ Object
22 23 24 25 26 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 22 def self.display_help Sign. ["-h"] end |
.parse_options(args) ⇒ Object
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 72 def self.(args) = Hash.new OptionParser.new do |opts| opts. = "Usage: ios_tool sign -i \"iPhone Distribution: Name\" -p path/to/profile -o output/ipa/file [options] inputIpa" opts.separator "" opts.separator "Options:" opts.on("-p", "--profile PATH_TO_PROFILE", "Path to profile") do |profile_location| [:profile_location] = profile_location end opts.on("-b", "--bundle-id [BUNDLE_IDENTIFIER]", "Bundle identifier") do |bundle_id| [:bundle_id] = bundle_id end opts.on("-o", "--output OUTPUT_IPA_FILE", "Output ipa archive") do |output_ipa| [:output_ipa] = output_ipa end opts.on("-i", "--identity IDENTITY", "Identity") do |identity| [:identity] = identity end opts.on("-t", "--temp [TEMP_FOLDER]", "Temporary folder location") do |temp_folder| [:temp_folder] = temp_folder end opts.separator "" opts.separator "Common options:" opts.on("-v", "--verbose", "Run verbosely") do |v| [:verbose] = v end opts.on("--version", "Show version and exit") do |v| puts "Version: #{IOSDevTools::VERSION}" exit end # No argument, shows at tail. This will print an options summary. # Try it and see! opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end.parse!(args) [:input_file]=ARGV[0] mandatory=[[:profile_location],[:identity],[:output_ipa],[:input_file]] expected_number=mandatory.count real_number=mandatory.compact.count if expected_number != real_number # one of mandatory switches is missing # display help and exit ["-h"] end return end |
Instance Method Details
#error_msg(message) ⇒ Object
34 35 36 37 38 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 34 def error_msg puts "\nERROR:\t#{}\n" end |
#execute ⇒ Object
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 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 40 def execute verbose_msg "Passed options:\n#{@options.inspect}" begin provisioning_profile=IOSDevTools::ProvisioningProfile.new @options[:profile_location] application_bundle=IOSDevTools::ApplicationBundle.new @options[:input_file] do |ab| ab.temp_folder=@options[:temp_folder] end rescue => error error_msg error exit 1 end new_bundle_id = @options[:bundle_id] new_bundle_id ||= application_bundle.info_plist.bundle_id if not provisioning_profile.is_compatible_with_bundle_id new_bundle_id error_msg "Provisioning profile identifier [#{provisioning_profile.application_identifier}] is not compatible with bundle identifier [#{new_bundle_id}]\n \ \tMaybe you should use -b switch to overwrite the bundle identifier?" exit 1 end application_bundle.info_plist.bundle_id = new_bundle_id application_bundle.set_provisioning_profile provisioning_profile.profile_location application_bundle.sign_with_identity @options[:identity] application_bundle.package_to_ipa @options[:output_ipa] puts "\nApplication archive created and signed: #{@options[:output_ipa]}" end |
#verbose_msg(message) ⇒ Object
28 29 30 31 32 |
# File 'lib/ios_dev_tools/commands/sign.rb', line 28 def verbose_msg puts if @be_verbose end |