diff --git a/lib/motion/project.rb b/lib/motion/project.rb index 365bbc3e..f8e6522c 100644 --- a/lib/motion/project.rb +++ b/lib/motion/project.rb @@ -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\"" : '' diff --git a/lib/motion/project/config.rb b/lib/motion/project/config.rb index c2dd6704..90345bbb 100644 --- a/lib/motion/project/config.rb +++ b/lib/motion/project/config.rb @@ -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) }