From 3ca5e0888d0f9b27c8608f207e47971aa48c067c Mon Sep 17 00:00:00 2001 From: hensm Date: Thu, 12 Sep 2019 12:06:41 +0100 Subject: [PATCH] Convert native receiver app to build with xcode --- .../AppDelegate.swift | 54 --- app/NativeMacReceiverSelector/main.swift | 10 - .../models/Receiver.swift | 23 -- app/bin/build.js | 28 +- app/bin/lib/paths.js | 2 +- app/selector/mac/.gitignore | 4 + .../project.pbxproj | 372 ++++++++++++++++++ .../mac/fx_cast_selector/AppDelegate.swift | 18 + .../AppIcon.appiconset/Contents.json | 58 +++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/Main.storyboard | 206 ++++++++++ app/selector/mac/fx_cast_selector/Info.plist | 32 ++ .../fx_cast_selector}/InitDataProvider.swift | 0 .../mac/fx_cast_selector}/ReceiverView.swift | 15 +- .../fx_cast_selector}/ViewController.swift | 193 +++------ .../fx_cast_selector/WindowController.swift | 25 ++ .../fx_cast_selector.entitlements | 10 + .../fx_cast_selector}/models/InitData.swift | 8 +- .../fx_cast_selector}/models/MediaType.swift | 3 - .../fx_cast_selector/models/Receiver.swift | 23 ++ .../models/ReceiverSelection.swift | 0 .../mac/fx_cast_selector}/util.swift | 0 app/src/bridge/index.ts | 5 +- 23 files changed, 844 insertions(+), 251 deletions(-) delete mode 100644 app/NativeMacReceiverSelector/AppDelegate.swift delete mode 100644 app/NativeMacReceiverSelector/main.swift delete mode 100644 app/NativeMacReceiverSelector/models/Receiver.swift create mode 100644 app/selector/mac/.gitignore create mode 100644 app/selector/mac/fx_cast_selector.xcodeproj/project.pbxproj create mode 100644 app/selector/mac/fx_cast_selector/AppDelegate.swift create mode 100644 app/selector/mac/fx_cast_selector/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 app/selector/mac/fx_cast_selector/Assets.xcassets/Contents.json create mode 100644 app/selector/mac/fx_cast_selector/Base.lproj/Main.storyboard create mode 100644 app/selector/mac/fx_cast_selector/Info.plist rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/InitDataProvider.swift (100%) rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/ReceiverView.swift (92%) rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/ViewController.swift (58%) create mode 100644 app/selector/mac/fx_cast_selector/WindowController.swift create mode 100644 app/selector/mac/fx_cast_selector/fx_cast_selector.entitlements rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/models/InitData.swift (92%) rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/models/MediaType.swift (84%) create mode 100644 app/selector/mac/fx_cast_selector/models/Receiver.swift rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/models/ReceiverSelection.swift (100%) rename app/{NativeMacReceiverSelector => selector/mac/fx_cast_selector}/util.swift (100%) diff --git a/app/NativeMacReceiverSelector/AppDelegate.swift b/app/NativeMacReceiverSelector/AppDelegate.swift deleted file mode 100644 index 3334a13..0000000 --- a/app/NativeMacReceiverSelector/AppDelegate.swift +++ /dev/null @@ -1,54 +0,0 @@ -import Cocoa - - -class AppDelegate : NSObject, NSApplicationDelegate { - var mainWindow: NSWindow? - var mainWindowController: NSWindowController? - var mainWindowViewController: ViewController? - - - func applicationDidFinishLaunching (_ aNotification: Notification) { - let window = NSWindow( - contentRect: NSZeroRect - , styleMask: [ .titled, .closable ] - , backing: .buffered - , defer: false) - - window.titleVisibility = .hidden - window.isMovableByWindowBackground = true - window.orderFrontRegardless() - - if let screen = NSScreen.main { - let windowX = InitDataProvider.shared.data.windowPositionX - let windowY = Int(screen.frame.height - CGFloat( - InitDataProvider.shared.data.windowPositionY)) - - window.setFrameTopLeftPoint(NSPoint(x: windowX, y: windowY)) - } - - - let windowController = NSWindowController(window: window) - windowController.showWindow(window) - - let viewController = ViewController() - window.contentViewController = viewController - window.makeKeyAndOrderFront(self) - - self.mainWindow = window - self.mainWindowController = windowController - self.mainWindowViewController = viewController - - NSApp.activate(ignoringOtherApps: true) - } - - func applicationDidResignActive (_ aNotification: Notification) { - if InitDataProvider.shared.data.closeIfFocusLost { - self.mainWindow?.performClose(aNotification) - } - } - - func applicationShouldTerminateAfterLastWindowClosed ( - _ app: NSApplication) -> Bool { - return true - } -} diff --git a/app/NativeMacReceiverSelector/main.swift b/app/NativeMacReceiverSelector/main.swift deleted file mode 100644 index 934759f..0000000 --- a/app/NativeMacReceiverSelector/main.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Cocoa - - -let app = NSApplication.shared - -let delegate = AppDelegate() -app.delegate = delegate - -app.setActivationPolicy(.regular) -app.run() diff --git a/app/NativeMacReceiverSelector/models/Receiver.swift b/app/NativeMacReceiverSelector/models/Receiver.swift deleted file mode 100644 index 9c2b55e..0000000 --- a/app/NativeMacReceiverSelector/models/Receiver.swift +++ /dev/null @@ -1,23 +0,0 @@ -struct Receiver : Codable { - struct Status: Codable { - let application: Application - let volume: Volume - } - - struct Application: Codable { - let displayName: String - let isIdleScreen: Bool - let statusText: String - } - - struct Volume: Codable { - let level: Double - let muted: Bool - } - - let friendlyName: String - let host: String - let id: String - let port: Int - let status: Status -} diff --git a/app/bin/build.js b/app/bin/build.js index 6cfe3a6..2949597 100644 --- a/app/bin/build.js +++ b/app/bin/build.js @@ -189,25 +189,23 @@ async function build () { // Build NativeMacReceiverSelector if (isBuildingForMacOnMac) { - const sourceFiles = glob.sync("**/*.swift", { - cwd: path.join(__dirname, "../NativeMacReceiverSelector") - , absolute: true - }); - - const formattedSourceFiles = sourceFiles - .map(fileName => `"${fileName}"`) - .join(" "); + const selectorPath = path.join(__dirname, "../selector/mac/"); + const derivedDataPath = path.join(__dirname, "../selector/mac/build/"); let buildCommand = ` - swiftc -o "${path.join(BUILD_PATH, selectorExecutableName)}" \ - ${formattedSourceFiles}`; - - // Build with optimizations if packaging - if (argv.package) { - buildCommand += " -Osize"; - } + xcodebuild -project ${selectorPath}/fx_cast_selector.xcodeproj \ + -configuration Release \ + -scheme fx_cast_selector \ + -derivedDataPath ${derivedDataPath} \ + build`; spawnSync(buildCommand, spawnOptions); + + const selectorBundlePath = path.join(derivedDataPath + , "Build/Products/Release/", selectorExecutableName); + + fs.moveSync(selectorBundlePath, path.join(BUILD_PATH, selectorExecutableName)); + fs.removeSync(derivedDataPath); } diff --git a/app/bin/lib/paths.js b/app/bin/lib/paths.js index 465ec37..bbf4863 100644 --- a/app/bin/lib/paths.js +++ b/app/bin/lib/paths.js @@ -34,7 +34,7 @@ exports.manifestPath = { } }; -exports.selectorExecutableName = "selector"; +exports.selectorExecutableName = "fx_cast_selector.app"; exports.pkgPlatform = { win32: "win" diff --git a/app/selector/mac/.gitignore b/app/selector/mac/.gitignore new file mode 100644 index 0000000..0817d00 --- /dev/null +++ b/app/selector/mac/.gitignore @@ -0,0 +1,4 @@ +# Ignore contents of xcodeproj, besides main project file +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +build/ diff --git a/app/selector/mac/fx_cast_selector.xcodeproj/project.pbxproj b/app/selector/mac/fx_cast_selector.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a6c2077 --- /dev/null +++ b/app/selector/mac/fx_cast_selector.xcodeproj/project.pbxproj @@ -0,0 +1,372 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + C9667DF32329C6900008D030 /* ReceiverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9667DF22329C68F0008D030 /* ReceiverView.swift */; }; + C9667DF52329C6A10008D030 /* util.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9667DF42329C6A10008D030 /* util.swift */; }; + C9EF71522314055C00EBDE93 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF71512314055C00EBDE93 /* AppDelegate.swift */; }; + C9EF71542314055C00EBDE93 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF71532314055C00EBDE93 /* ViewController.swift */; }; + C9EF71562314055E00EBDE93 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9EF71552314055E00EBDE93 /* Assets.xcassets */; }; + C9EF71592314055E00EBDE93 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9EF71572314055E00EBDE93 /* Main.storyboard */; }; + C9EF71622314062500EBDE93 /* InitDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF71612314062500EBDE93 /* InitDataProvider.swift */; }; + C9EF71682314075900EBDE93 /* InitData.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF71672314075900EBDE93 /* InitData.swift */; }; + C9EF716A2314077E00EBDE93 /* MediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF71692314077E00EBDE93 /* MediaType.swift */; }; + C9EF716C2314079600EBDE93 /* Receiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF716B2314079600EBDE93 /* Receiver.swift */; }; + C9EF716E231407DC00EBDE93 /* ReceiverSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF716D231407DC00EBDE93 /* ReceiverSelection.swift */; }; + C9EF717023140B3800EBDE93 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9EF716F23140B3800EBDE93 /* WindowController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C9667DF22329C68F0008D030 /* ReceiverView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiverView.swift; sourceTree = ""; }; + C9667DF42329C6A10008D030 /* util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = util.swift; sourceTree = ""; }; + C9EF714E2314055C00EBDE93 /* fx_cast_selector.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = fx_cast_selector.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C9EF71512314055C00EBDE93 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C9EF71532314055C00EBDE93 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + C9EF71552314055E00EBDE93 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C9EF71582314055E00EBDE93 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C9EF715A2314055E00EBDE93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C9EF715B2314055E00EBDE93 /* fx_cast_selector.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = fx_cast_selector.entitlements; sourceTree = ""; }; + C9EF71612314062500EBDE93 /* InitDataProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitDataProvider.swift; sourceTree = ""; }; + C9EF71672314075900EBDE93 /* InitData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitData.swift; sourceTree = ""; }; + C9EF71692314077E00EBDE93 /* MediaType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaType.swift; sourceTree = ""; }; + C9EF716B2314079600EBDE93 /* Receiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Receiver.swift; sourceTree = ""; }; + C9EF716D231407DC00EBDE93 /* ReceiverSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiverSelection.swift; sourceTree = ""; }; + C9EF716F23140B3800EBDE93 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C9EF714B2314055C00EBDE93 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C9EF71452314055C00EBDE93 = { + isa = PBXGroup; + children = ( + C9EF71502314055C00EBDE93 /* fx_cast_selector */, + C9EF714F2314055C00EBDE93 /* Products */, + ); + sourceTree = ""; + }; + C9EF714F2314055C00EBDE93 /* Products */ = { + isa = PBXGroup; + children = ( + C9EF714E2314055C00EBDE93 /* fx_cast_selector.app */, + ); + name = Products; + sourceTree = ""; + }; + C9EF71502314055C00EBDE93 /* fx_cast_selector */ = { + isa = PBXGroup; + children = ( + C9EF71662314073800EBDE93 /* models */, + C9EF71612314062500EBDE93 /* InitDataProvider.swift */, + C9EF71512314055C00EBDE93 /* AppDelegate.swift */, + C9EF71532314055C00EBDE93 /* ViewController.swift */, + C9667DF22329C68F0008D030 /* ReceiverView.swift */, + C9667DF42329C6A10008D030 /* util.swift */, + C9EF716F23140B3800EBDE93 /* WindowController.swift */, + C9EF71552314055E00EBDE93 /* Assets.xcassets */, + C9EF71572314055E00EBDE93 /* Main.storyboard */, + C9EF715A2314055E00EBDE93 /* Info.plist */, + C9EF715B2314055E00EBDE93 /* fx_cast_selector.entitlements */, + ); + path = fx_cast_selector; + sourceTree = ""; + }; + C9EF71662314073800EBDE93 /* models */ = { + isa = PBXGroup; + children = ( + C9EF71672314075900EBDE93 /* InitData.swift */, + C9EF71692314077E00EBDE93 /* MediaType.swift */, + C9EF716B2314079600EBDE93 /* Receiver.swift */, + C9EF716D231407DC00EBDE93 /* ReceiverSelection.swift */, + ); + path = models; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C9EF714D2314055C00EBDE93 /* fx_cast_selector */ = { + isa = PBXNativeTarget; + buildConfigurationList = C9EF715E2314055E00EBDE93 /* Build configuration list for PBXNativeTarget "fx_cast_selector" */; + buildPhases = ( + C9EF714A2314055C00EBDE93 /* Sources */, + C9EF714B2314055C00EBDE93 /* Frameworks */, + C9EF714C2314055C00EBDE93 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = fx_cast_selector; + productName = fx_cast_selector; + productReference = C9EF714E2314055C00EBDE93 /* fx_cast_selector.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C9EF71462314055C00EBDE93 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1030; + LastUpgradeCheck = 1030; + ORGANIZATIONNAME = "Matt Hensman"; + TargetAttributes = { + C9EF714D2314055C00EBDE93 = { + CreatedOnToolsVersion = 10.3; + }; + }; + }; + buildConfigurationList = C9EF71492314055C00EBDE93 /* Build configuration list for PBXProject "fx_cast_selector" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C9EF71452314055C00EBDE93; + productRefGroup = C9EF714F2314055C00EBDE93 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C9EF714D2314055C00EBDE93 /* fx_cast_selector */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C9EF714C2314055C00EBDE93 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C9EF71562314055E00EBDE93 /* Assets.xcassets in Resources */, + C9EF71592314055E00EBDE93 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C9EF714A2314055C00EBDE93 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C9EF716A2314077E00EBDE93 /* MediaType.swift in Sources */, + C9EF716C2314079600EBDE93 /* Receiver.swift in Sources */, + C9EF71622314062500EBDE93 /* InitDataProvider.swift in Sources */, + C9667DF52329C6A10008D030 /* util.swift in Sources */, + C9EF71542314055C00EBDE93 /* ViewController.swift in Sources */, + C9EF71682314075900EBDE93 /* InitData.swift in Sources */, + C9EF717023140B3800EBDE93 /* WindowController.swift in Sources */, + C9EF716E231407DC00EBDE93 /* ReceiverSelection.swift in Sources */, + C9667DF32329C6900008D030 /* ReceiverView.swift in Sources */, + C9EF71522314055C00EBDE93 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + C9EF71572314055E00EBDE93 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C9EF71582314055E00EBDE93 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C9EF715C2314055E00EBDE93 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_IMPLICIT_RETAIN_SELF = 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C9EF715D2314055E00EBDE93 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_IMPLICIT_RETAIN_SELF = 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + C9EF715F2314055E00EBDE93 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = fx_cast_selector/fx_cast_selector.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 7NS3H2Z7RF; + INFOPLIST_FILE = fx_cast_selector/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "tf.matt.fx-cast-selector"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + C9EF71602314055E00EBDE93 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = fx_cast_selector/fx_cast_selector.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 7NS3H2Z7RF; + INFOPLIST_FILE = fx_cast_selector/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "tf.matt.fx-cast-selector"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C9EF71492314055C00EBDE93 /* Build configuration list for PBXProject "fx_cast_selector" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C9EF715C2314055E00EBDE93 /* Debug */, + C9EF715D2314055E00EBDE93 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C9EF715E2314055E00EBDE93 /* Build configuration list for PBXNativeTarget "fx_cast_selector" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C9EF715F2314055E00EBDE93 /* Debug */, + C9EF71602314055E00EBDE93 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = C9EF71462314055C00EBDE93 /* Project object */; +} diff --git a/app/selector/mac/fx_cast_selector/AppDelegate.swift b/app/selector/mac/fx_cast_selector/AppDelegate.swift new file mode 100644 index 0000000..6cc3a2e --- /dev/null +++ b/app/selector/mac/fx_cast_selector/AppDelegate.swift @@ -0,0 +1,18 @@ +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + weak var mainWindow: NSWindow! + + func applicationDidResignActive (_ aNotification: Notification) { + if InitDataProvider.shared.data.closeIfFocusLost { + self.mainWindow?.performClose(aNotification) + } + } + + func applicationShouldTerminateAfterLastWindowClosed( + _ sender: NSApplication) -> Bool { + return true + } +} + diff --git a/app/selector/mac/fx_cast_selector/Assets.xcassets/AppIcon.appiconset/Contents.json b/app/selector/mac/fx_cast_selector/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/app/selector/mac/fx_cast_selector/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/app/selector/mac/fx_cast_selector/Assets.xcassets/Contents.json b/app/selector/mac/fx_cast_selector/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/app/selector/mac/fx_cast_selector/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/app/selector/mac/fx_cast_selector/Base.lproj/Main.storyboard b/app/selector/mac/fx_cast_selector/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f778058 --- /dev/null +++ b/app/selector/mac/fx_cast_selector/Base.lproj/Main.storyboard @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/selector/mac/fx_cast_selector/Info.plist b/app/selector/mac/fx_cast_selector/Info.plist new file mode 100644 index 0000000..24b2272 --- /dev/null +++ b/app/selector/mac/fx_cast_selector/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.2 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2019 Matt Hensman. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/app/NativeMacReceiverSelector/InitDataProvider.swift b/app/selector/mac/fx_cast_selector/InitDataProvider.swift similarity index 100% rename from app/NativeMacReceiverSelector/InitDataProvider.swift rename to app/selector/mac/fx_cast_selector/InitDataProvider.swift diff --git a/app/NativeMacReceiverSelector/ReceiverView.swift b/app/selector/mac/fx_cast_selector/ReceiverView.swift similarity index 92% rename from app/NativeMacReceiverSelector/ReceiverView.swift rename to app/selector/mac/fx_cast_selector/ReceiverView.swift index dcc1e50..3f94e0f 100644 --- a/app/NativeMacReceiverSelector/ReceiverView.swift +++ b/app/selector/mac/fx_cast_selector/ReceiverView.swift @@ -1,6 +1,5 @@ import Cocoa - protocol ReceiverViewDelegate : AnyObject { func didCast (_ receiver: Receiver) } @@ -14,17 +13,11 @@ class ReceiverView : NSStackView { var castButton: NSButton! var castingSpinner: NSProgressIndicator! - var isEnabled: Bool { - get { - return self.castButton.isEnabled - } - set { - self.castButton.isEnabled = newValue - } + get { return self.castButton.isEnabled } + set { self.castButton.isEnabled = newValue } } - override init (frame: CGRect) { super.init(frame: frame) } @@ -68,8 +61,8 @@ class ReceiverView : NSStackView { , action: #selector(ReceiverView.onCast)) self.castButton.bezelStyle = .rounded - self.castButton.widthAnchor.constraint(equalToConstant: 100).isActive = true - + self.castButton.widthAnchor.constraint( + equalToConstant: 100).isActive = true self.castingSpinner = NSProgressIndicator() self.castingSpinner.style = .spinning diff --git a/app/NativeMacReceiverSelector/ViewController.swift b/app/selector/mac/fx_cast_selector/ViewController.swift similarity index 58% rename from app/NativeMacReceiverSelector/ViewController.swift rename to app/selector/mac/fx_cast_selector/ViewController.swift index f986d73..3b58e6f 100644 --- a/app/NativeMacReceiverSelector/ViewController.swift +++ b/app/selector/mac/fx_cast_selector/ViewController.swift @@ -1,62 +1,28 @@ import Cocoa +class ViewController: NSViewController { + @IBOutlet weak var labelCast: NSTextField! + @IBOutlet weak var labelTo: NSTextField! + @IBOutlet weak var mediaTypePopUpButton: NSPopUpButton! + + @IBOutlet weak var mainStackView: NSStackView! -class ViewController : NSViewController { - var mediaTypePopUpButton: NSPopUpButton! + var receiverViews = [ReceiverView]() - var filePath: String? - - - override func loadView () { - /*let visualEffectView = NSVisualEffectView() - visualEffectView.blendingMode = .behindWindow - visualEffectView.state = .active*/ - - self.view = NSView() - } - - override func viewDidLoad () { + + override func viewDidLoad() { super.viewDidLoad() - + let initData = InitDataProvider.shared.data - - /** - * View Hierarchy - * -------------- - * - * stackView \ (NSStackView) - * ├ mediaTypeStackView \ (NSStackView) - * │ ├ mediaSelectCastLabel \ (NSTextField) - * │ ├ mediaTypePopUpButton \ (NSPopUpButton) - * │ └ mediaSelectToLabel \ (NSTextField) - * │ - * ├ receiverSeparator \ (NSBox) ┐ - * └ receiverView \ (ReceiverView:NSStackView) │ - * ├ metaStackView \ (NSStackView) │ - * │ ├ receiver name \ (NSTextField) ├ Repeats - * │ └ receiver host \ (NSTextField) │ - * ├ spinner \ (NSProgressIndicator) │ - * └ button \ (NSButton) ┘ - */ - - - let stackView = NSStackView() - stackView.orientation = .vertical - stackView.alignment = .leading - stackView.autoresizingMask = [ .width, .height ] - stackView.edgeInsets = NSEdgeInsetsMake(8, 8, 8, 8) - - - self.mediaTypePopUpButton = NSPopUpButton() - self.mediaTypePopUpButton.autoenablesItems = false + self.mediaTypePopUpButton.addItems(withTitles: [ initData.i18n_mediaTypeApp , initData.i18n_mediaTypeTab , initData.i18n_mediaTypeScreen , initData.i18n_mediaTypeFile ]) - + if let appItem = self.mediaTypePopUpButton .item(withTitle: initData.i18n_mediaTypeApp) , let tabItem = self.mediaTypePopUpButton @@ -65,128 +31,97 @@ class ViewController : NSViewController { .item(withTitle: initData.i18n_mediaTypeScreen) , let fileItem = self.mediaTypePopUpButton .item(withTitle: initData.i18n_mediaTypeFile) { - - if let mediaTypePopUpButtonMenu = self.mediaTypePopUpButton.menu { - mediaTypePopUpButtonMenu.delegate = self - mediaTypePopUpButtonMenu.insertItem(NSMenuItem.separator() - , at: mediaTypePopUpButtonMenu.index(of: fileItem)) + + if let menu = self.mediaTypePopUpButton.menu { + menu.delegate = self + menu.insertItem(NSMenuItem.separator() + , at: self.mediaTypePopUpButton.index(of: fileItem)) } - - // Set tags to enum value + appItem.tag = MediaType.app.rawValue tabItem.tag = MediaType.tab.rawValue screenItem.tag = MediaType.screen.rawValue fileItem.tag = MediaType.file.rawValue } - + for item in self.mediaTypePopUpButton.itemArray { if (initData.availableMediaTypes & item.tag) == 0 { item.isEnabled = false } } - + self.mediaTypePopUpButton.selectItem( withTag: initData.defaultMediaType.rawValue) - - let mediaTypeStackView = NSStackView() - if initData.i18n_mediaSelectCastLabel != "" { - mediaTypeStackView.addView( - makeLabel(initData.i18n_mediaSelectCastLabel), in: .leading) + labelCast.stringValue = initData.i18n_mediaSelectCastLabel + labelCast.isHidden = false } - - mediaTypeStackView.addView(self.mediaTypePopUpButton, in: .leading) - if initData.i18n_mediaSelectToLabel != "" { - mediaTypeStackView.addView( - makeLabel(initData.i18n_mediaSelectToLabel), in: .leading) + labelTo.stringValue = initData.i18n_mediaSelectToLabel + labelTo.isHidden = false } - - stackView.addArrangedSubview(mediaTypeStackView) - - - if initData.receivers.count < 1 { + + if initData.receivers.count == 0 { let separator = NSBox() separator.boxType = .separator - - let notFoundStackView = NSStackView(views: [ + + let notFoundPlaceholder = NSStackView(views: [ makeLabel(initData.i18n_noReceiversFound) ]) - - notFoundStackView.alignment = .centerX - notFoundStackView.edgeInsets = NSEdgeInsetsMake(18, 0, 18, 0) - - stackView.addArrangedSubview(separator) - stackView.addArrangedSubview(notFoundStackView) + + notFoundPlaceholder.alignment = .centerX + notFoundPlaceholder.edgeInsets = NSEdgeInsetsMake(18, 0, 18, 0) + + self.mainStackView.addArrangedSubview(separator) + self.mainStackView.addArrangedSubview(notFoundPlaceholder) } else { - /** - * For each receiver in the initData list, create a new - * ReceiverView, set self as a ReceiverViewDelegate and - * appends to main stack view. - * - * Keeps a reference to the receiver view to call disable() - * later. - */ for receiver in initData.receivers { - // Create separator between last receiver / media type let receiverSeparator = NSBox() receiverSeparator.boxType = .separator - + let receiverView = ReceiverView(receiver: receiver) receiverView.receiverViewDelegate = self - + if UInt(initData.availableMediaTypes) == 0 || (initData.availableMediaTypes - & initData.defaultMediaType.rawValue) == 0 { + & initData.defaultMediaType.rawValue) == 0 { receiverView.isEnabled = false } - - + self.receiverViews.append(receiverView) - - stackView.addArrangedSubview(receiverSeparator) - stackView.addArrangedSubview(receiverView) + + self.mainStackView.addArrangedSubview(receiverSeparator) + self.mainStackView.addArrangedSubview(receiverView) } } - - - // Add to main view and set width to resize window - self.view.addSubview(stackView) - self.view.autoresizesSubviews = true + + self.view.frame.size.height = 0 self.view.frame.size.width = 350 } - - override func viewDidAppear () { - // Set window title and update visibility - if let window = self.view.window { - window.title = InitDataProvider.shared.data.i18n_extensionName - window.titleVisibility = .visible - } - } } -extension ViewController : NSMenuDelegate { +extension ViewController: NSMenuDelegate { func menuDidClose (_ menu: NSMenu) { let initData = InitDataProvider.shared.data - + guard let selectedItem = self.mediaTypePopUpButton.selectedItem , let mediaType = MediaType(rawValue: selectedItem.tag) else { return } - + if initData.availableMediaTypes & mediaType.rawValue != 0 { for receiverView in self.receiverViews { receiverView.isEnabled = true } } - + guard let fileItem = self.mediaTypePopUpButton .item(at: self.mediaTypePopUpButton.indexOfItem( withTag: MediaType.file.rawValue)) else { return } - + if (mediaType == .file) { let panel = NSOpenPanel() panel.allowsMultipleSelection = false @@ -194,38 +129,38 @@ extension ViewController : NSMenuDelegate { panel.canChooseDirectories = false panel.canCreateDirectories = false panel.canChooseFiles = true - + guard let window = self.view.window else { return } - + panel.beginSheetModal(for: window) { (result) in if (result == .OK) { let url = panel.urls[0] let fileName = url.lastPathComponent - + // Truncate file name and set as title fileItem.title = fileName.count > 12 ? "\(fileName.prefix(12))..." : fileName - + self.filePath = url.path - + return } else { // Re-select the default media type item self.mediaTypePopUpButton.selectItem( - withTag: initData.defaultMediaType.rawValue) - + withTag: initData.defaultMediaType.rawValue) + let defaultMediaTypeAvailable = initData.availableMediaTypes & initData.defaultMediaType.rawValue != 0 - + for receiverView in self.receiverViews { receiverView.isEnabled = defaultMediaTypeAvailable } } } } - - + + // Reset file item fileItem.title = initData.i18n_mediaTypeFile self.filePath = nil @@ -234,26 +169,26 @@ extension ViewController : NSMenuDelegate { extension ViewController : ReceiverViewDelegate { func didCast (_ receiver: Receiver) { - + // Disable media type UI self.mediaTypePopUpButton.isEnabled = false - + // Disable cast buttons for receiverView in self.receiverViews { receiverView.isEnabled = false } - - + + guard let selectedItem = self.mediaTypePopUpButton.selectedItem , let mediaType = MediaType(rawValue: selectedItem.tag) else { return } - + let selection = ReceiverSelection( receiver: receiver , mediaType: mediaType , filePath: self.filePath ?? nil) - + if let jsonData = try? JSONEncoder().encode(selection) , let jsonString = String(data: jsonData, encoding: .utf8) { print(jsonString) diff --git a/app/selector/mac/fx_cast_selector/WindowController.swift b/app/selector/mac/fx_cast_selector/WindowController.swift new file mode 100644 index 0000000..554f8d9 --- /dev/null +++ b/app/selector/mac/fx_cast_selector/WindowController.swift @@ -0,0 +1,25 @@ +import Cocoa + +class WindowController: NSWindowController { + override func windowDidLoad() { + super.windowDidLoad() + + if let appDelegate = NSApplication.shared.delegate as? AppDelegate { + appDelegate.mainWindow = self.window + } + + if let window = self.window + , let screen = window.screen { + let windowX = InitDataProvider.shared.data.windowPositionX + let windowY = Int(screen.frame.height - CGFloat( + InitDataProvider.shared.data.windowPositionY)) + + window.setFrameTopLeftPoint(NSPoint(x: windowX, y: windowY)) + + window.title = InitDataProvider.shared.data.i18n_extensionName + window.titleVisibility = .visible + + NSApp.activate(ignoringOtherApps: true) + } + } +} diff --git a/app/selector/mac/fx_cast_selector/fx_cast_selector.entitlements b/app/selector/mac/fx_cast_selector/fx_cast_selector.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/app/selector/mac/fx_cast_selector/fx_cast_selector.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/app/NativeMacReceiverSelector/models/InitData.swift b/app/selector/mac/fx_cast_selector/models/InitData.swift similarity index 92% rename from app/NativeMacReceiverSelector/models/InitData.swift rename to app/selector/mac/fx_cast_selector/models/InitData.swift index 641eccb..8321cc7 100644 --- a/app/NativeMacReceiverSelector/models/InitData.swift +++ b/app/selector/mac/fx_cast_selector/models/InitData.swift @@ -1,13 +1,13 @@ -struct InitData : Codable { +struct InitData : Decodable { let receivers: [Receiver] let defaultMediaType: MediaType let availableMediaTypes: Int - + let closeIfFocusLost: Bool - + let windowPositionX: Int let windowPositionY: Int - + let i18n_extensionName: String let i18n_castButtonTitle: String let i18n_mediaTypeApp: String diff --git a/app/NativeMacReceiverSelector/models/MediaType.swift b/app/selector/mac/fx_cast_selector/models/MediaType.swift similarity index 84% rename from app/NativeMacReceiverSelector/models/MediaType.swift rename to app/selector/mac/fx_cast_selector/models/MediaType.swift index 7e1f569..7bb6ba5 100644 --- a/app/NativeMacReceiverSelector/models/MediaType.swift +++ b/app/selector/mac/fx_cast_selector/models/MediaType.swift @@ -1,6 +1,3 @@ -import Foundation - - enum MediaType: Int, Codable { case app = 1 case tab = 2 diff --git a/app/selector/mac/fx_cast_selector/models/Receiver.swift b/app/selector/mac/fx_cast_selector/models/Receiver.swift new file mode 100644 index 0000000..3de9c68 --- /dev/null +++ b/app/selector/mac/fx_cast_selector/models/Receiver.swift @@ -0,0 +1,23 @@ +struct Receiver : Codable { + struct Status: Codable { + struct Application: Codable { + let displayName: String + let isIdleScreen: Bool + let statusText: String + } + + struct Volume: Codable { + let level: Double + let muted: Bool + } + + let application: Application + let volume: Volume + } + + let friendlyName: String + let host: String + let id: String + let port: Int + let status: Status +} diff --git a/app/NativeMacReceiverSelector/models/ReceiverSelection.swift b/app/selector/mac/fx_cast_selector/models/ReceiverSelection.swift similarity index 100% rename from app/NativeMacReceiverSelector/models/ReceiverSelection.swift rename to app/selector/mac/fx_cast_selector/models/ReceiverSelection.swift diff --git a/app/NativeMacReceiverSelector/util.swift b/app/selector/mac/fx_cast_selector/util.swift similarity index 100% rename from app/NativeMacReceiverSelector/util.swift rename to app/selector/mac/fx_cast_selector/util.swift diff --git a/app/src/bridge/index.ts b/app/src/bridge/index.ts index ddcba72..6550572 100755 --- a/app/src/bridge/index.ts +++ b/app/src/bridge/index.ts @@ -204,8 +204,11 @@ function handleReceiverSelectorMessage (message: Message) { receiverSelectorApp.kill(); } + const receiverSelectorPath = path.join(process.cwd() + , "fx_cast_selector.app/Contents/MacOS/fx_cast_selector"); + receiverSelectorApp = child_process.spawn( - path.join(process.cwd(), "selector") + receiverSelectorPath , [ receiverSelectorData ]); receiverSelectorAppClosed = false;