Skip to content

Commit

Permalink
Swift 4 + some project cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tripplet committed Dec 28, 2017
1 parent 36f0a9c commit 2cbc26f
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 45 deletions.
46 changes: 29 additions & 17 deletions SendToKodi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
CD8E97E11C556DB900E6E652 /* SendToKodi.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8E97E01C556DB900E6E652 /* SendToKodi.swift */; };
CD8E97E21C556E2300E6E652 /* SendToKodi.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8E97E01C556DB900E6E652 /* SendToKodi.swift */; };
CDB061431C498C5200E6E652 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB061421C498C5200E6E652 /* AppDelegate.swift */; };
CDB061451C498C5300E6E652 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CDB061441C498C5300E6E652 /* Assets.xcassets */; };
CDB061481C498C5300E6E652 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = CDB061461C498C5300E6E652 /* MainMenu.xib */; };
CDB061571C498D0900E6E652 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = CDB061561C498D0900E6E652 /* icon.icns */; };
CDB0615A1C498D0900E6E652 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB061591C498D0900E6E652 /* ShareViewController.swift */; };
CDB0615D1C498D0900E6E652 /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CDB0615B1C498D0900E6E652 /* ShareViewController.xib */; };
CDB061611C498D0900E6E652 /* SendToKodiAction.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = CDB061531C498D0900E6E652 /* SendToKodiAction.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
CDF0EB891FF536FB0029401E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CDF0EB881FF536FB0029401E /* Assets.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -46,16 +45,15 @@
CD8E97E01C556DB900E6E652 /* SendToKodi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendToKodi.swift; sourceTree = "<group>"; };
CDB0613F1C498C5200E6E652 /* SendToKodi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SendToKodi.app; sourceTree = BUILT_PRODUCTS_DIR; };
CDB061421C498C5200E6E652 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CDB061441C498C5300E6E652 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
CDB061471C498C5300E6E652 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
CDB061491C498C5300E6E652 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CDB061531C498D0900E6E652 /* SendToKodiAction.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SendToKodiAction.appex; sourceTree = BUILT_PRODUCTS_DIR; };
CDB061561C498D0900E6E652 /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = icon.icns; sourceTree = "<group>"; };
CDB061581C498D0900E6E652 /* SendToKodiAction.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SendToKodiAction.entitlements; sourceTree = "<group>"; };
CDB061591C498D0900E6E652 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
CDB0615C1C498D0900E6E652 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ShareViewController.xib; sourceTree = "<group>"; };
CDB0615E1C498D0900E6E652 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CDB061661C49ABA300E6E652 /* SendToKodi.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SendToKodi.entitlements; sourceTree = "<group>"; };
CDF0EB881FF536FB0029401E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -109,7 +107,7 @@
CDB061421C498C5200E6E652 /* AppDelegate.swift */,
CDB061461C498C5300E6E652 /* MainMenu.xib */,
CDB061661C49ABA300E6E652 /* SendToKodi.entitlements */,
CDB061441C498C5300E6E652 /* Assets.xcassets */,
CDF0EB881FF536FB0029401E /* Assets.xcassets */,
CDB061491C498C5300E6E652 /* Info.plist */,
);
path = SendToKodi;
Expand All @@ -129,7 +127,6 @@
CDB061551C498D0900E6E652 /* Supporting Files */ = {
isa = PBXGroup;
children = (
CDB061561C498D0900E6E652 /* icon.icns */,
CDB061581C498D0900E6E652 /* SendToKodiAction.entitlements */,
);
name = "Supporting Files";
Expand All @@ -146,7 +143,6 @@
CDB0613C1C498C5200E6E652 /* Frameworks */,
CDB0613D1C498C5200E6E652 /* Resources */,
CDB061651C498D0900E6E652 /* Embed App Extensions */,
CDD5AFE61C4AD06F00E6E652 /* ShellScript */,
);
buildRules = (
);
Expand All @@ -165,6 +161,7 @@
CDB0614F1C498D0900E6E652 /* Sources */,
CDB061501C498D0900E6E652 /* Frameworks */,
CDB061511C498D0900E6E652 /* Resources */,
CDF0EB8A1FF539760029401E /* ShellScript */,
);
buildRules = (
);
Expand All @@ -182,12 +179,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = "Tobias Tangemann";
TargetAttributes = {
CDB0613E1C498C5200E6E652 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0820;
LastSwiftMigration = 0920;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
Expand All @@ -199,7 +196,7 @@
};
CDB061521C498D0900E6E652 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0820;
LastSwiftMigration = 0920;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
Expand Down Expand Up @@ -232,7 +229,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CDB061451C498C5300E6E652 /* Assets.xcassets in Resources */,
CDF0EB891FF536FB0029401E /* Assets.xcassets in Resources */,
CDB061481C498C5300E6E652 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -242,14 +239,13 @@
buildActionMask = 2147483647;
files = (
CDB0615D1C498D0900E6E652 /* ShareViewController.xib in Resources */,
CDB061571C498D0900E6E652 /* icon.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
CDD5AFE61C4AD06F00E6E652 /* ShellScript */ = {
CDF0EB8A1FF539760029401E /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down Expand Up @@ -321,14 +317,20 @@
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;
Expand Down Expand Up @@ -367,14 +369,20 @@
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;
Expand Down Expand Up @@ -409,7 +417,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tangemann.SendToKodi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -424,7 +433,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tangemann.SendToKodi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -439,7 +449,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tangemann.SendToKodi.SendToKodiAction;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -454,7 +465,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tangemann.SendToKodi.SendToKodiAction;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0920"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down Expand Up @@ -41,6 +41,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -60,6 +61,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions SendToKodi/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let mirroredDefaults = UserDefaults(suiteName: USER_DEFAULTS_SUITE)!

func applicationDidFinishLaunching(_ aNotification: Notification) {
NSApplication.shared().servicesProvider = self
NSApplication.shared.servicesProvider = self

// Save all user default into app group user defaults, so they can be accessed from the extension
NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.handleUserDefaultsChanged(_:)),
name: UserDefaults.didChangeNotification,
object: UserDefaults.standard)
}

func handleUserDefaultsChanged(_ aNotification: Notification) {
@objc func handleUserDefaultsChanged(_ aNotification: Notification) {
mirroredDefaults.setValue(UserDefaults.standard.string(forKey: "kodi_hostname")!, forKey: "kodi_hostname")
mirroredDefaults.synchronize()
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 12 additions & 10 deletions SendToKodi/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,61 @@
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "AppIcon16x16.png",
"filename" : "16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "AppIcon16x16@2x.png",
"filename" : "32.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "AppIcon32x32.png",
"filename" : "32.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "64.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "AppIcon128x128.png",
"filename" : "128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "AppIcon128x128@2x.png",
"filename" : "256.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "AppIcon256x256.png",
"filename" : "256.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "AppIcon256x256@2x.png",
"filename" : "512.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "AppIcon512x512.png",
"filename" : "512.png",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "1024.png",
"scale" : "2x"
}
],
Expand Down
6 changes: 0 additions & 6 deletions SendToKodi/Assets.xcassets/Contents.json

This file was deleted.

14 changes: 6 additions & 8 deletions SendToKodiAction/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import Cocoa

class ShareViewController: NSViewController {
@IBOutlet weak var progress: NSProgressIndicator!

override var nibName: String? { return "ShareViewController" }


override func loadView() {
super.loadView()

Expand Down Expand Up @@ -46,18 +44,18 @@ class ShareViewController: NSViewController {
vid = queryItems?.filter({$0.name == "v"}).first?.value
}
else if url.description.contains("youtu.be/") {
vid = url.path.substring(from: url.path.characters.index(url.path.startIndex, offsetBy: 1))
vid = String(url.path[url.path.index(url.path.startIndex, offsetBy: 1)...])
}

if let vid = vid {
return ("{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": " +
"{\"item\": {\"file\" : \"plugin://plugin.video.youtube/?action=play_video&videoid=\(vid)\" }}, \"id\" : \"1\"}")
.data(using: String.Encoding.utf8)
"{\"item\": {\"file\" : \"plugin://plugin.video.youtube/?action=play_video&videoid=\(vid)\" }}, \"id\" : \"1\"}")
.data(using: String.Encoding.utf8)
}
else {
return ("{\"jsonrpc\": \"2.0\", \"method\": \"Player.open\", \"params\": " +
"{\"item\": {\"file\": \"\(url.description)\"}}, \"id\": 1}")
.data(using: String.Encoding.utf8)
"{\"item\": {\"file\": \"\(url.description)\"}}, \"id\": 1}")
.data(using: String.Encoding.utf8)
}
}

Expand Down
Binary file removed SendToKodiAction/icon.icns
Binary file not shown.

0 comments on commit 2cbc26f

Please sign in to comment.