Update for Xcode 6.1 and Swift 1.1

This commit is contained in:
Matt Coneybeare
2014-10-20 16:00:53 -04:00
parent f9a1750dba
commit 7ff1576d37
5 changed files with 42 additions and 34 deletions

View File

@@ -591,7 +591,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 7.1; IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9; MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = Armchair; PRODUCT_NAME = Armchair;
SDKROOT = macosx; SDKROOT = macosx;
@@ -615,7 +615,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 7.1; IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9; MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";
PRODUCT_NAME = Armchair; PRODUCT_NAME = Armchair;
SDKROOT = macosx; SDKROOT = macosx;

View File

@@ -39,7 +39,7 @@
import Cocoa import Cocoa
// @NSApplicationMain // TODO - Needs Xcode 6.1 beta 2 to compile. Figure out a way to support both for the time being @NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate { class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow! @IBOutlet weak var window: NSWindow!

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6246" systemVersion="14A238x" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6246"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -675,7 +675,7 @@
<window title="Mac Example" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" animationBehavior="default" id="QvC-M9-y7g"> <window title="Mac Example" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES"/> <windowStyleMask key="styleMask" titled="YES"/>
<rect key="contentRect" x="335" y="390" width="400" height="368"/> <rect key="contentRect" x="335" y="390" width="400" height="368"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="EiT-Mj-1SZ"> <view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="400" height="368"/> <rect key="frame" x="0.0" y="0.0" width="400" height="368"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>

View File

@@ -213,12 +213,13 @@ extension ViewController {
} }
@IBAction func openUrbanApps(AnyObject) { @IBAction func openUrbanApps(AnyObject) {
let url = NSURL(string: "http://urbanapps.com") if let url = NSURL(string: "http://urbanapps.com") {
#if os(iOS) #if os(iOS)
UIApplication.sharedApplication().openURL(url) UIApplication.sharedApplication().openURL(url)
#elseif os(OSX) #elseif os(OSX)
NSWorkspace.sharedWorkspace().openURL(url) NSWorkspace.sharedWorkspace().openURL(url)
#else #else
#endif #endif
}
} }
} }

View File

@@ -621,8 +621,7 @@ public enum ArmchairKey: String, Printable {
public var description : String { public var description : String {
get { get {
return self.toRaw() return self.rawValue
// return self.rawValue // Changes to rawValue in Xcode 6.1 beta 2
} }
} }
} }
@@ -920,7 +919,11 @@ public class Manager : ArmchairManager {
var incrementKey = keyForArmchairKeyType(incrementKeyType) var incrementKey = keyForArmchairKeyType(incrementKeyType)
// App's version. Not settable as the other ivars because that would be crazy. // App's version. Not settable as the other ivars because that would be crazy.
var currentVersion: String = NSBundle.mainBundle().infoDictionary[kCFBundleVersionKey] as NSString let currentVersion = NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey) as? NSString
if currentVersion == nil {
assertionFailure("Could not read kCFBundleVersionKey from InfoDictionary")
return
}
// Get the version number that we've been tracking thus far // Get the version number that we've been tracking thus far
var currentVersionKey = keyForArmchairKeyType(ArmchairKey.CurrentVersion) var currentVersionKey = keyForArmchairKeyType(ArmchairKey.CurrentVersion)
@@ -1137,7 +1140,7 @@ public class Manager : ArmchairManager {
})) }))
// get the top most controller (= the StoreKit Controller) and dismiss it // get the top most controller (= the StoreKit Controller) and dismiss it
if let presentingController = UIApplication.sharedApplication().keyWindow.rootViewController { if let presentingController = UIApplication.sharedApplication().keyWindow?.rootViewController {
if let topController = topMostViewController(presentingController) { if let topController = topMostViewController(presentingController) {
topController.presentViewController(alertView, animated: usesAnimation) { topController.presentViewController(alertView, animated: usesAnimation) {
println("presentViewController() completed") println("presentViewController() completed")
@@ -1172,7 +1175,7 @@ public class Manager : ArmchairManager {
alert.informativeText = reviewMessage alert.informativeText = reviewMessage
alert.addButtonWithTitle(rateButtonTitle) alert.addButtonWithTitle(rateButtonTitle)
if showsRemindButton() { if showsRemindButton() {
alert.addButtonWithTitle(remindButtonTitle) alert.addButtonWithTitle(remindButtonTitle!)
} }
alert.addButtonWithTitle(cancelButtonTitle) alert.addButtonWithTitle(cancelButtonTitle)
ratingAlert = alert ratingAlert = alert
@@ -1225,7 +1228,7 @@ public class Manager : ArmchairManager {
modalPanelOpen = false modalPanelOpen = false
// get the top most controller (= the StoreKit Controller) and dismiss it // get the top most controller (= the StoreKit Controller) and dismiss it
if let presentingController = UIApplication.sharedApplication().keyWindow.rootViewController { if let presentingController = UIApplication.sharedApplication().keyWindow?.rootViewController {
if let topController = topMostViewController(presentingController) { if let topController = topMostViewController(presentingController) {
topController.dismissViewControllerAnimated(usesAnimation) { topController.dismissViewControllerAnimated(usesAnimation) {
if let closure = self.didDismissModalViewClosure { if let closure = self.didDismissModalViewClosure {
@@ -1325,8 +1328,9 @@ public class Manager : ArmchairManager {
//Use the standard openUrl method //Use the standard openUrl method
} else { } else {
let url = NSURL(string: reviewURLString()) if let url = NSURL(string: reviewURLString()) {
UIApplication.sharedApplication().openURL(url) UIApplication.sharedApplication().openURL(url)
}
} }
if UIDevice.currentDevice().model.rangeOfString("Simulator") != nil { if UIDevice.currentDevice().model.rangeOfString("Simulator") != nil {
@@ -1337,10 +1341,11 @@ public class Manager : ArmchairManager {
debugLog(" - Or try copy/pasting \(fakeURL) into a browser on your computer.") debugLog(" - Or try copy/pasting \(fakeURL) into a browser on your computer.")
} }
#elseif os(OSX) #elseif os(OSX)
var url = NSURL(string: reviewURLString()) if let url = NSURL(string: reviewURLString()) {
var opened = NSWorkspace.sharedWorkspace().openURL(url) var opened = NSWorkspace.sharedWorkspace().openURL(url)
if !opened { if !opened {
debugLog("Failed to open \(url)") debugLog("Failed to open \(url)")
}
} }
#else #else
#endif #endif
@@ -1592,23 +1597,25 @@ public class Manager : ArmchairManager {
} }
private func getRootViewController() -> UIViewController? { private func getRootViewController() -> UIViewController? {
var window: UIWindow = UIApplication.sharedApplication().keyWindow if let window = UIApplication.sharedApplication().keyWindow {
if window.windowLevel != UIWindowLevelNormal {
var windows: NSArray = UIApplication.sharedApplication().windows if window.windowLevel != UIWindowLevelNormal {
for window in windows { var windows: NSArray = UIApplication.sharedApplication().windows
if window.windowLevel == UIWindowLevelNormal { for window in windows {
break if window.windowLevel == UIWindowLevelNormal {
break
}
} }
} }
}
for subView in window.subviews { for subView in window.subviews {
var nextResponder: UIResponder? = subView.nextResponder() var nextResponder: UIResponder? = subView.nextResponder()
if let responder = nextResponder { if let responder = nextResponder {
if responder.isKindOfClass(UIViewController) { if responder.isKindOfClass(UIViewController) {
return topMostViewController(responder as? UIViewController) return topMostViewController(responder as? UIViewController)
}
} }
} }
} }