retina mode support

This commit is contained in:
Laurent Sansonetti
2012-05-14 12:54:14 +02:00
parent acd4165352
commit 8b29abe056
2 changed files with 18 additions and 3 deletions

View File

@@ -57,13 +57,18 @@ task :simulator => ['build:simulator'] do
end
# Prepare the device family.
family_int =
family_int, retina =
if family = ENV['device_family']
App.config.device_family_int(family.downcase.intern)
str = family.downcase
retina = str.sub!(/\:retina$/, '') ? true : false
[App.config.device_family_int(str.intern), retina]
else
App.config.device_family_ints[0]
[App.config.device_family_ints[0], false]
end
# Configure the SimulateDevice variable (the only way to specify if we want to run in retina mode or not).
sh "/usr/bin/defaults write com.apple.iphonesimulator \"SimulateDevice\" \"'#{App.config.device_family_string(family_int, retina)}'\""
# Launch the simulator.
xcode = App.config.xcode_dir
env = xcode.match(/^\/Applications/) ? "DYLD_FRAMEWORK_PATH=\"#{xcode}/../Frameworks\":\"#{xcode}/../OtherFrameworks\"" : ''

View File

@@ -381,6 +381,16 @@ EOS
end
end
def device_family_string(family, retina)
device = case family
when :iphone, 1
"iPhone"
when :ipad, 2
"iPad"
end
retina ? device + " (Retina)" : device
end
def device_family_ints
ary = @device_family.is_a?(Array) ? @device_family : [@device_family]
ary.map { |family| device_family_int(family) }