Skip to content
Browse files

Use SdkDetector to choose the latest SDK available if none is specified

  • Loading branch information...
1 parent 1de343c commit bba12544d5a0122e5a97898c205f84e87655d1d6 @moredip committed
View
2 bin/sim_launcher
@@ -3,7 +3,7 @@
require 'rubygems'
require 'sinatra'
-require 'sim_launcher/simulator'
+require 'sim_launcher'
# SimLauncher starts on port 8881 by default. To specify a custom port just pass it as the first command line argument.
set :port, (ARGV[0] || 8881)
View
1 lib/sim_launcher.rb
@@ -1,3 +1,4 @@
require 'sim_launcher/client'
require 'sim_launcher/direct_client'
require 'sim_launcher/simulator'
+require 'sim_launcher/sdk_detector'
View
4 lib/sim_launcher/client.rb
@@ -13,11 +13,11 @@ def initialize( app_path, sdk, family )
self.server_uri = DEFAULT_SERVER_URI
end
- def self.for_ipad_app( app_path, sdk = '4.2' )
+ def self.for_ipad_app( app_path, sdk = nil )
self.new( app_path, sdk, 'ipad' )
end
- def self.for_iphone_app( app_path, sdk = '4.2' )
+ def self.for_iphone_app( app_path, sdk = nil )
self.new( app_path, sdk, 'iphone' )
end
View
4 lib/sim_launcher/direct_client.rb
@@ -6,11 +6,11 @@ def initialize( app_path, sdk, family )
@family = family
end
- def self.for_ipad_app( app_path, sdk = '4.2' )
+ def self.for_ipad_app( app_path, sdk = nil )
self.new( app_path, sdk, 'ipad' )
end
- def self.for_iphone_app( app_path, sdk = '4.2' )
+ def self.for_iphone_app( app_path, sdk = nil )
self.new( app_path, sdk, 'iphone' )
end
View
16 lib/sim_launcher/sdk_detector.rb
@@ -0,0 +1,16 @@
+require 'singleton'
+
+module SimLauncher
+ class SdkDetector
+ include Singleton
+
+ def latest_sdk_version
+ unless @latest_sdk_version
+ latest_iphone_sdk = `xcodebuild -showsdks | grep -o "iphonesimulator.*$"`.split.sort.last
+ @latest_sdk_version = latest_iphone_sdk[/iphonesimulator(.*)/,1]
+ end
+ @latest_sdk_version
+ end
+
+ end
+end
View
4 lib/sim_launcher/simulator.rb
@@ -14,12 +14,12 @@ def launch_ios_app(app_path, sdk_version, device_family)
end
def launch_ipad_app( app_path, sdk )
- sdk ||= '3.2'
+ sdk ||= SdkDetector.instance.latest_sdk_version
launch_ios_app( app_path, sdk, 'ipad' )
end
def launch_iphone_app( app_path, sdk )
- sdk ||= '4.0'
+ sdk ||= SdkDetector.instance.latest_sdk_version
launch_ios_app( app_path, sdk, 'iphone' )
end
View
2 lib/sim_launcher/version.rb
@@ -1,3 +1,3 @@
module SimLauncher
- VERSION = "0.3.0"
+ VERSION = "0.3.1"
end

0 comments on commit bba1254

Please sign in to comment.
Something went wrong with that request. Please try again.