diff --git a/CMakeLists.txt b/CMakeLists.txt index a1d9f69..4db2209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,12 @@ set(LibIntl_DIR "${PREBUILT_INSTALL_PATH}/lib/cmake") find_package(LibIntl) set(fmt_DIR "${PREBUILT_INSTALL_PATH}/lib/cmake/fmt") find_package(fmt) +if (TARGET fmt::fmt-header-only) + # Resolve swiftc warnings + set_target_properties(fmt::fmt-header-only PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "FMT_HEADER_ONLY" + ) +endif() option(ENABLE_TEST "" OFF) option(ENABLE_COVERAGE "" OFF) @@ -77,7 +83,7 @@ include_directories( "${HOMEBREW_PATH}/include" # nlohmann-json ) -add_definitions(-DFCITX_GETTEXT_DOMAIN=\"fcitx5-macos\") +add_compile_definitions($<$:-DFCITX_GETTEXT_DOMAIN=\"fcitx5-macos\">) add_subdirectory(macosfrontend) add_subdirectory(macosnotifications) diff --git a/src/config/customphrase.swift b/src/config/customphrase.swift index b47c4b0..eb84632 100644 --- a/src/config/customphrase.swift +++ b/src/config/customphrase.swift @@ -201,7 +201,7 @@ struct CustomPhraseView: View { return } } - openInEditor(customphrase.localPath()) + openInEditor(url: customphrase) } label: { Text("Open in editor") } diff --git a/src/config/dictmanager.swift b/src/config/dictmanager.swift index 2134e7c..8fc616c 100644 --- a/src/config/dictmanager.swift +++ b/src/config/dictmanager.swift @@ -92,9 +92,9 @@ struct DictManagerView: View { let enabledPath = dictDir.appendingPathComponent(dict.id + ".dict") let disabledPath = dictDir.appendingPathComponent(dict.id + ".dict.disable") if $0 { - moveFile(disabledPath, enabledPath) + let _ = moveFile(disabledPath, enabledPath) } else { - moveFile(enabledPath, disabledPath) + let _ = moveFile(enabledPath, disabledPath) } reloadDicts() } @@ -145,7 +145,7 @@ struct DictManagerView: View { Button { for dict in selectedDicts { - removeFile(dictDir.appendingPathComponent(dict + ".dict")) + let _ = removeFile(dictDir.appendingPathComponent(dict + ".dict")) } selectedDicts.removeAll() reloadDicts() diff --git a/src/config/imageoptionview.swift b/src/config/imageoptionview.swift index ee8e527..523eaae 100644 --- a/src/config/imageoptionview.swift +++ b/src/config/imageoptionview.swift @@ -43,8 +43,8 @@ struct ImageOptionView: OptionView { var body: some View { VStack { Picker("", selection: $model.mode) { - ForEach(0.. Bool { let url = getCacheURL(plugin, native: native) let path = url.localPath() let ret = exec("/usr/bin/tar", ["-xjf", path, "-C", libraryDir.localPath()]) - removeFile(url) + let _ = removeFile(url) return ret } diff --git a/src/config/plugin.swift b/src/config/plugin.swift index 4505fe6..0c08fdd 100644 --- a/src/config/plugin.swift +++ b/src/config/plugin.swift @@ -176,9 +176,9 @@ struct PluginView: View { if keptFiles.contains(file) { continue } - removeFile(libraryDir.appendingPathComponent(file)) + let _ = removeFile(libraryDir.appendingPathComponent(file)) } - removeFile(descriptor) + let _ = removeFile(descriptor) FCITX_INFO("Uninstalled \(selectedPlugin)") } selectedInstalled.removeAll() diff --git a/src/config/quickphrase.swift b/src/config/quickphrase.swift index 3c48b32..8772b73 100644 --- a/src/config/quickphrase.swift +++ b/src/config/quickphrase.swift @@ -196,7 +196,6 @@ struct QuickPhraseView: View { Button { mkdirP(localQuickphrasePath) let localURL = localQuickphraseDir.appendingPathComponent(quickphraseVM.current + ".mb") - let path = localURL.localPath() if !localURL.exists() { if !copyFile( globalQuickphraseDir.appendingPathComponent(quickphraseVM.current + ".mb"), @@ -206,7 +205,7 @@ struct QuickPhraseView: View { return } } - openInEditor(path) + openInEditor(url: localURL) } label: { Text("Open in editor") }.disabled(quickphraseVM.current.isEmpty) diff --git a/src/config/util.swift b/src/config/util.swift index 9f1693a..30c453a 100644 --- a/src/config/util.swift +++ b/src/config/util.swift @@ -173,16 +173,24 @@ func readJSON(_ file: URL) -> JSON? { return nil } -func openInEditor(_ path: String) { +func openInEditor(url: URL) { let apps = ["VSCodium", "Visual Studio Code"] for app in apps { let appURL = URL(fileURLWithPath: "/Applications/\(app).app") if appURL.exists() { - NSWorkspace.shared.openFile(path, withApplication: app) + NSWorkspace.shared.open( + [url], withApplicationAt: appURL, configuration: NSWorkspace.OpenConfiguration(), + completionHandler: nil) return } } - NSWorkspace.shared.openFile(path, withApplication: "TextEdit") + if let textEditURL = NSWorkspace.shared.urlForApplication( + withBundleIdentifier: "com.apple.TextEdit") + { + NSWorkspace.shared.open( + [url], withApplicationAt: textEditURL, configuration: NSWorkspace.OpenConfiguration(), + completionHandler: nil) + } } func exec(_ command: String, _ args: [String]) -> Bool {