From dd4873fa73d52c3fdb0ebb4b8527232d4eebf3e7 Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Wed, 4 Jan 2012 11:20:26 +0100 Subject: [PATCH] make sure deployment_target can't be nil --- lib/motion/project/config.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/motion/project/config.rb b/lib/motion/project/config.rb index 3164a114..bc56a00b 100644 --- a/lib/motion/project/config.rb +++ b/lib/motion/project/config.rb @@ -226,7 +226,7 @@ module Motion; module Project end def deployment_target - @deployment_target ||= @sdk_version + @deployment_target ||= sdk_version end def sdk(platform) @@ -352,19 +352,20 @@ module Motion; module Project end end + def read_provisioned_profile_array(key) + text = File.read(provisioning_profile) + text.force_encoding('binary') if RUBY_VERSION >= '1.9.0' + text.scan(/\s*#{key}\s*<\/key>\s*(.*?)\s*<\/array>/m)[0][0].scan(/(.*?)<\/string>/).map { |str| str[0].strip } + end + private :read_provisioned_profile_array + def provisioned_devices - @provisioned_devices ||= begin - text = File.read(provisioning_profile) - text.force_encoding('binary') if RUBY_VERSION >= '1.9.0' - text.scan(/\s*ProvisionedDevices\s*<\/key>\s*(\s*\s*([^<\s]+)\s*<\/string>)+\s*<\/array>/).map { |ary| ary[1] } - end + @provisioned_devices ||= read_provisioned_profile_array('ProvisionedDevices') end def seed_id @seed_id ||= begin - text = File.read(provisioning_profile) - text.force_encoding('binary') if RUBY_VERSION >= '1.9.0' - seed_ids = text.scan(/\s*ApplicationIdentifierPrefix\s*<\/key>\s*(\s*\s*([^<\s]+)\s*<\/string>)+\s*<\/array>/).map { |ary| ary[1] } + seed_ids = read_provisioned_profile_array('ApplicationIdentifierPrefix') if seed_ids.size == 0 App.fail "Can't find an application seed ID in the provisioning profile `#{provisioning_profile}'" elsif seed_ids.size > 1