Skip to content

Commit

Permalink
Updated for Swift 4 and Xcode 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Pascarella committed Dec 7, 2017
1 parent 4922556 commit ef57bc6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
**/xcuserdata/*
**/xcshareddata/*

release.sh
release.plist

42 changes: 30 additions & 12 deletions IP Menu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 48;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -160,21 +160,21 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0910;
TargetAttributes = {
FFF7133E1B975643001612E9 = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0820;
LastSwiftMigration = 0910;
};
FFF7134E1B975643001612E9 = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0820;
LastSwiftMigration = 0910;
TestTargetID = FFF7133E1B975643001612E9;
};
};
};
buildConfigurationList = FFF7133A1B975643001612E9 /* Build configuration list for PBXProject "IP Menu" */;
compatibilityVersion = "Xcode 3.2";
compatibilityVersion = "Xcode 8.0";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -260,18 +260,24 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -296,6 +302,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -307,18 +314,24 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
Expand All @@ -335,6 +348,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -348,7 +362,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.disrvptor.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "IP Menu-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
Expand All @@ -364,8 +379,9 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.disrvptor.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "IP Menu-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
USER_HEADER_SEARCH_PATHS = "";
};
name = Release;
Expand All @@ -387,7 +403,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.disrvptor.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/IP Menu.app/Contents/MacOS/IP Menu";
};
name = Debug;
Expand All @@ -405,7 +422,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.disrvptor.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/IP Menu.app/Contents/MacOS/IP Menu";
};
name = Release;
Expand Down
14 changes: 7 additions & 7 deletions IP Menu/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
internal var defaultIF: String?;

func applicationDidFinishLaunching(_ aNotification: Notification) {
statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength);
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength);

// TODO: Figure out ho to modify this for dev/test vs production
ConsoleLog.setCurrentLevel(ConsoleLog.Level.Info);
Expand All @@ -42,11 +42,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationWillTerminate(_ aNotification: Notification) {
timer = nil;
NSStatusBar.system().removeStatusItem(statusItem!);
NSStatusBar.system.removeStatusItem(statusItem!);
statusItem = nil;
}

func updateIPAddress() {
@objc func updateIPAddress() {
let _addresses = NetworkUtils.getIFAddresses();
// Disable this for now because it looks like it may be causing the OS to deadlock
//var _defaultIF: String? = "en0";
Expand Down Expand Up @@ -83,13 +83,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
menu.addItem(NSMenuItem(title: "Refresh", action: #selector(AppDelegate.updateIPAddress), keyEquivalent: ""));

let item:NSMenuItem = NSMenuItem(title: "Launch at startup", action: #selector(AppDelegate.toggleLaunchAtStartup), keyEquivalent: "");
item.state = state;
item.state = NSControl.StateValue(rawValue: state);
menu.addItem(item);

menu.addItem(NSMenuItem(title: "About IP Menu", action: #selector(AppDelegate.about), keyEquivalent: ""));
menu.addItem(NSMenuItem.separator());
//menu.addItem(NSMenuItem(title: "Quit IP Menu", action: #selector(NSInputServiceProvider.Quit), keyEquivalent: "q"));
menu.addItem(NSMenuItem(title: "Quit IP Menu", action: #selector(NSApplication.shared().terminate), keyEquivalent: "q"));
menu.addItem(NSMenuItem(title: "Quit IP Menu", action: #selector(NSApplication.shared.terminate), keyEquivalent: "q"));
statusItem!.menu = menu;
}

Expand Down Expand Up @@ -166,7 +166,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return true;
}

func about() {
@objc func about() {
let alert = NSAlert();
alert.messageText = "IP Menu v\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String)";
alert.informativeText = "Developed by @disrvptor (https://github.com/disrvptor/IPMenu)";
Expand Down Expand Up @@ -212,7 +212,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return (nil, nil)
}

func toggleLaunchAtStartup() {
@objc func toggleLaunchAtStartup() {
let itemReferences = itemReferencesInLoginItems()
let shouldBeToggled = (itemReferences.existingReference == nil)
let loginItemsRef = LSSharedFileListCreate(
Expand Down
2 changes: 1 addition & 1 deletion IP Menu/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<string>1.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
3 changes: 2 additions & 1 deletion IP Menu/NetworkUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class NetworkUtils {
for line in lines! {
//let line2 = line.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet());
if let range = line.range(of: "interface: ") {
return line.substring(from: range.upperBound);
//return line.substring(from: range.upperBound);
return String(line[range.upperBound...]);
}
}

Expand Down

0 comments on commit ef57bc6

Please sign in to comment.