mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-29 05:05:37 +08:00
better support for entitlements
This commit is contained in:
@@ -221,11 +221,14 @@ PLIST
|
||||
File.open(File.join(bundle_path, "embedded.mobileprovision"), 'w') do |io|
|
||||
io.write(File.read(config.provisioning_profile))
|
||||
end
|
||||
|
||||
# Create the entitlements file.
|
||||
entitlements = File.join(config.build_dir, platform, "Entitlements.plist")
|
||||
File.open(entitlements, 'w') { |io| io.write(config.entitlements_data) }
|
||||
|
||||
# Do the codesigning.
|
||||
codesign_allocate = File.join(config.platform_dir(platform), 'Developer/usr/bin/codesign_allocate')
|
||||
entitlement_opt = File.exist?('Entitlements.plist') ? '--entitlements Entitlements.plist' : ''
|
||||
sh "CODESIGN_ALLOCATE=\"#{codesign_allocate}\" /usr/bin/codesign -f -s \"#{config.codesign_certificate}\" --resource-rules=\"#{resource_rules_plist}\" #{entitlement_opt} \"#{bundle_path}\""
|
||||
sh "CODESIGN_ALLOCATE=\"#{codesign_allocate}\" /usr/bin/codesign -f -s \"#{config.codesign_certificate}\" --resource-rules=\"#{resource_rules_plist}\" --entitlements #{entitlements} \"#{bundle_path}\""
|
||||
end
|
||||
end
|
||||
end; end
|
||||
|
||||
@@ -27,7 +27,8 @@ module Motion; module Project
|
||||
variable :files, :platforms_dir, :sdk_version, :frameworks,
|
||||
:delegate_class, :name, :build_dir, :resources_dir, :identifier,
|
||||
:codesign_certificate, :provisioning_profile, :device_family,
|
||||
:interface_orientations, :version, :icons
|
||||
:interface_orientations, :version, :icons, :seed_id,
|
||||
:entitlements
|
||||
|
||||
def initialize(project_dir)
|
||||
@project_dir = project_dir
|
||||
@@ -45,6 +46,7 @@ module Motion; module Project
|
||||
@version = '1.0'
|
||||
@icons = []
|
||||
@vendor_projects = []
|
||||
@entitlements = {}
|
||||
end
|
||||
|
||||
def variables
|
||||
@@ -253,5 +255,23 @@ module Motion; module Project
|
||||
paths[0]
|
||||
end
|
||||
end
|
||||
|
||||
def seed_id
|
||||
@seed_id ||= begin
|
||||
txt = File.read(provisioning_profile)
|
||||
seed_ids = txt.scan(/<key>\s*ApplicationIdentifierPrefix\s*<\/key>\s*<array>(\s*<string>\s*([^<\s]+)\s*<\/string>)+\s*<\/array>/).map { |ary| ary[1] }
|
||||
if seed_ids.size == 0
|
||||
$stderr.puts "Can't find an application seed ID in the provisioning profile"
|
||||
exit 1
|
||||
elsif seed_ids.size > 1
|
||||
$stderr.puts "Found #{seed_ids.size} seed IDs in the provisioning profile, will use the last one: `#{seed_ids.last}'"
|
||||
end
|
||||
seed_ids.last
|
||||
end
|
||||
end
|
||||
|
||||
def entitlements_data
|
||||
Motion::PropertyList.to_s(entitlements)
|
||||
end
|
||||
end
|
||||
end; end
|
||||
|
||||
Reference in New Issue
Block a user