From 1572ae5d8fce5d49d088acf7c32bba0908699c98 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 14 Jan 2022 22:27:38 +0800 Subject: [PATCH] Zonble: Swiftify // InputSourceHelper. --- Source/InputSourceHelper.swift | 143 +++++++++++++++++++++ Source/Installer/AppDelegate.m | 12 +- Source/OVInputSourceHelper.h | 50 ------- Source/OVInputSourceHelper.m | 121 ----------------- Source/main.m | 17 +-- Source/vChewingInstaller-Bridging-Header.h | 4 + vChewing.xcodeproj/project.pbxproj | 34 +++-- 7 files changed, 187 insertions(+), 194 deletions(-) create mode 100644 Source/InputSourceHelper.swift delete mode 100644 Source/OVInputSourceHelper.h delete mode 100644 Source/OVInputSourceHelper.m create mode 100644 Source/vChewingInstaller-Bridging-Header.h diff --git a/Source/InputSourceHelper.swift b/Source/InputSourceHelper.swift new file mode 100644 index 00000000..152b1b14 --- /dev/null +++ b/Source/InputSourceHelper.swift @@ -0,0 +1,143 @@ +// +// InputSourceHelper.swift +// +// Copyright (c) 2011-2022 The OpenVanilla Project. +// +// Contributors: +// Mengjuei Hsieh (@mjhsieh) @ OpenVanilla +// Weizhong Yang (@zonble) @ OpenVanilla +// Lukhnos Liu (@lukhnos) @ OpenVanilla +// +// Based on the Syrup Project and the Formosana Library +// by Lukhnos Liu (@lukhnos). +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Cocoa +import Carbon + +public class InputSourceHelper: NSObject { + + @available(*, unavailable) + public override init() { + super.init() + } + + public static func allInstalledInputSources() -> [TISInputSource] { + TISCreateInputSourceList(nil, true).takeRetainedValue() as! [TISInputSource] + } + + @objc (inputSourceForProperty:stringValue:) + public static func inputSource(for propertyKey: CFString, stringValue: String) -> TISInputSource? { + let stringID = CFStringGetTypeID() + for source in allInstalledInputSources() { + if let propertyPtr = TISGetInputSourceProperty(source, propertyKey) { + let property = Unmanaged.fromOpaque(propertyPtr).takeUnretainedValue() + let typeID = CFGetTypeID(property) + if typeID != stringID { + continue + } + if stringValue == property as? String { + return source + } + } + } + return nil + } + + @objc (inputSourceForInputSourceID:) + public static func inputSource(for sourceID: String) -> TISInputSource? { + inputSource(for: kTISPropertyInputSourceID, stringValue: sourceID) + } + + @objc (inputSourceEnabled:) + public static func inputSourceEnabled(for source: TISInputSource) -> Bool { + if let valuePts = TISGetInputSourceProperty(source, kTISPropertyInputSourceIsEnabled) { + let value = Unmanaged.fromOpaque(valuePts).takeUnretainedValue() + return value == kCFBooleanTrue + } + return false + } + + @objc (enableInputSource:) + public static func enable(inputSource: TISInputSource) -> Bool { + let status = TISEnableInputSource(inputSource) + return status == noErr + } + + @objc (enableAllInputModesForInputSourceBundleID:) + public static func enableAllInputMode(for inputSourceBundleD: String) -> Bool { + var enabled = false + for source in allInstalledInputSources() { + guard let bundleIDPtr = TISGetInputSourceProperty(source, kTISPropertyBundleID), + let _ = TISGetInputSourceProperty(source, kTISPropertyInputModeID) else { + continue + } + let bundleID = Unmanaged.fromOpaque(bundleIDPtr).takeUnretainedValue() + if String(bundleID) == inputSourceBundleD { + let modeEnabled = self.enable(inputSource: source) + if !modeEnabled { + return false + } + enabled = true + } + } + + return enabled + } + + @objc (enableInputMode:forInputSourceBundleID:) + public static func enable(inputMode modeID: String, for bundleID: String) -> Bool { + for source in allInstalledInputSources() { + guard let bundleIDPtr = TISGetInputSourceProperty(source, kTISPropertyBundleID), + let modePtr = TISGetInputSourceProperty(source, kTISPropertyInputModeID) else { + continue + } + let inputsSourceBundleID = Unmanaged.fromOpaque(bundleIDPtr).takeUnretainedValue() + let inputsSourceModeID = Unmanaged.fromOpaque(modePtr).takeUnretainedValue() + if modeID == String(inputsSourceModeID) && bundleID == String(inputsSourceBundleID) { + let enabled = enable(inputSource: source) + print("Attempt to enable input source of mode: \(modeID), bundle ID: \(bundleID), result: \(enabled)") + return enabled + } + + } + print("Failed to find any matching input source of mode: \(modeID), bundle ID: \(bundleID)") + return false + + } + + @objc (disableInputSource:) + public static func disable(inputSource: TISInputSource) -> Bool { + let status = TISDisableInputSource(inputSource) + return status == noErr + } + + @objc (registerInputSource:) + public static func registerTnputSource(at url: URL) -> Bool { + let status = TISRegisterInputSource(url as CFURL) + return status == noErr + } + +} + diff --git a/Source/Installer/AppDelegate.m b/Source/Installer/AppDelegate.m index 7f43d2ef..28cfa0ca 100644 --- a/Source/Installer/AppDelegate.m +++ b/Source/Installer/AppDelegate.m @@ -32,7 +32,7 @@ #import "AppDelegate.h" #import -#import "OVInputSourceHelper.h" +#import "vChewingInstaller-Swift.h" static NSString *const kTargetBin = @"vChewing"; static NSString *const kTargetType = @"app"; @@ -197,13 +197,13 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) { NSURL *imeBundleURL = imeBundle.bundleURL; NSString *imeIdentifier = imeBundle.bundleIdentifier; - TISInputSourceRef inputSource = [OVInputSourceHelper inputSourceForInputSourceID:imeIdentifier]; + TISInputSourceRef inputSource = [InputSourceHelper inputSourceForInputSourceID:imeIdentifier]; // if this IME name is not found in the list of available IMEs if (!inputSource) { NSLog(@"Registering input source %@ at %@.", imeIdentifier, imeBundleURL.absoluteString); // then register - BOOL status = [OVInputSourceHelper registerInputSource:imeBundleURL]; + BOOL status = [InputSourceHelper registerInputSource:imeBundleURL]; if (!status) { NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Cannot register input source %@ at %@.", nil), imeIdentifier, imeBundleURL.absoluteString]; @@ -212,7 +212,7 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) { return; } - inputSource = [OVInputSourceHelper inputSourceForInputSourceID:imeIdentifier]; + inputSource = [InputSourceHelper inputSourceForInputSourceID:imeIdentifier]; // if it still doesn't register successfully, bail. if (!inputSource) { NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Cannot find input source %@ after registration.", nil), imeIdentifier]; @@ -234,10 +234,10 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) { // as the kTISPropertyInputSourceIsEnabled can still be true even if the IME is *not* // enabled in the user's current set of IMEs (which means the IME does not show up in // the user's input menu). - BOOL mainInputSourceEnabled = [OVInputSourceHelper inputSourceEnabled:inputSource]; + BOOL mainInputSourceEnabled = [InputSourceHelper inputSourceEnabled:inputSource]; if (!mainInputSourceEnabled || isMacOS12OrAbove) { - mainInputSourceEnabled = [OVInputSourceHelper enableInputSource:inputSource]; + mainInputSourceEnabled = [InputSourceHelper enableInputSource:inputSource]; if (mainInputSourceEnabled) { NSLog(@"Input method enabled: %@", imeIdentifier); } else { diff --git a/Source/OVInputSourceHelper.h b/Source/OVInputSourceHelper.h deleted file mode 100644 index cc4c8919..00000000 --- a/Source/OVInputSourceHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// OVInputSourceHelper.h -// -// Copyright (c) 2010-2011 Lukhnos D. Liu (lukhnos at lukhnos dot org) -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import - -@interface OVInputSourceHelper : NSObject -// list all installed input sources -+ (NSArray *)allInstalledInputSources; - -// search for a certain input source -+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue; - -// shorthand for -inputSourceForProerty:kTISPropertyInputSourceID stringValue: -+ (TISInputSourceRef)inputSourceForInputSourceID:(NSString *)inID; - -// enable/disable an input source (along with all its input modes) -+ (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource; -+ (BOOL)enableInputSource:(TISInputSourceRef)inInputSource; -+ (BOOL)enableAllInputModesForInputSourceBundleID:(NSString *)inID; -+ (BOOL)enableInputMode:(NSString *)modeID forInputSourceBundleID:(NSString *)bundleID; -+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource; - -// register (i.e. make available to Input Source tab in Language & Text Preferences) -// an input source installed in (~)/Library/Input Methods or (~)/Library/Keyboard Layouts/ -+ (BOOL)registerInputSource:(NSURL *)inBundleURL; -@end diff --git a/Source/OVInputSourceHelper.m b/Source/OVInputSourceHelper.m deleted file mode 100644 index 6735545a..00000000 --- a/Source/OVInputSourceHelper.m +++ /dev/null @@ -1,121 +0,0 @@ -// -// OVInputSourceHelper.m -// -// Copyright (c) 2010-2011 Lukhnos D. Liu (lukhnos at lukhnos dot org) -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "OVInputSourceHelper.h" - -@implementation OVInputSourceHelper -+ (NSArray *)allInstalledInputSources -{ - CFArrayRef list = TISCreateInputSourceList(NULL, true); - return (__bridge NSArray *)list; -} - -+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue -{ - CFTypeID stringID = CFStringGetTypeID(); - - for (id source in [self allInstalledInputSources]) { - CFTypeRef property = TISGetInputSourceProperty((__bridge TISInputSourceRef)source, inPropertyKey); - if (!property || CFGetTypeID(property) != stringID) { - continue; - } - - if (inValue && [inValue compare:(__bridge NSString *)property] == NSOrderedSame) { - return (__bridge TISInputSourceRef)source; - } - } - return NULL; -} - -+ (TISInputSourceRef)inputSourceForInputSourceID:(NSString *)inID -{ - return [self inputSourceForProperty:kTISPropertyInputSourceID stringValue:inID]; -} - -+ (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource -{ - CFBooleanRef value = TISGetInputSourceProperty(inInputSource, kTISPropertyInputSourceIsEnabled); - return value ? (BOOL)CFBooleanGetValue(value) : NO; -} - -+ (BOOL)enableInputSource:(TISInputSourceRef)inInputSource -{ - OSStatus status = TISEnableInputSource(inInputSource); - return status == noErr; -} - -+ (BOOL)enableAllInputModesForInputSourceBundleID:(NSString *)inID -{ - BOOL enabled = NO; - - for (id source in [self allInstalledInputSources]) { - TISInputSourceRef inputSource = (__bridge TISInputSourceRef)source; - NSString *bundleID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID); - NSString *mode = (NSString *)CFBridgingRelease(TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID)); - if (mode && [bundleID isEqualToString:inID]) { - BOOL modeEnabled = [self enableInputSource:inputSource]; - if (!modeEnabled) { - return NO; - } - - enabled = YES; - } - } - - return enabled; -} - -+ (BOOL)enableInputMode:(NSString *)modeID forInputSourceBundleID:(NSString *)bundleID -{ - for (id source in [self allInstalledInputSources]) { - TISInputSourceRef inputSource = (__bridge TISInputSourceRef)source; - NSString *inputSoureBundleID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID); - NSString *inputSourceModeID = (NSString *)CFBridgingRelease(TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID)); - - if ([modeID isEqual:inputSourceModeID] && [bundleID isEqual:inputSoureBundleID]) { - BOOL enabled = [self enableInputSource:inputSource]; - NSLog(@"Attempt to enable input source of mode: %@, bundle ID: %@, result: %d", modeID, bundleID, enabled); - return enabled; - } - } - - NSLog(@"Failed to find any matching input source of mode: %@, bundle ID: %@", modeID, bundleID); - return NO; -} - -+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource -{ - OSStatus status = TISDisableInputSource(inInputSource); - return status == noErr; -} - -+ (BOOL)registerInputSource:(NSURL *)inBundleURL -{ - OSStatus status = TISRegisterInputSource((__bridge CFURLRef)inBundleURL); - return status == noErr; -} -@end diff --git a/Source/main.m b/Source/main.m index 6f1da160..14bd2c6e 100644 --- a/Source/main.m +++ b/Source/main.m @@ -37,7 +37,8 @@ // #import -#import "OVInputSourceHelper.h" +#import +#import "vChewing-Swift.h" static NSString *const kConnectionName = @"vChewing_1_Connection"; @@ -58,20 +59,20 @@ int main(int argc, char *argv[]) bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; } - TISInputSourceRef inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID]; + TISInputSourceRef inputSource = [InputSourceHelper inputSourceForInputSourceID:bundleID]; // if this IME name is not found in the list of available IMEs if (!inputSource) { NSLog(@"Registering input source %@ at %@.", bundleID, [bundleURL absoluteString]); // then register - BOOL status = [OVInputSourceHelper registerInputSource:bundleURL]; + BOOL status = [InputSourceHelper registerInputSource:bundleURL]; if (!status) { NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]); return -1; } - inputSource = [OVInputSourceHelper inputSourceForInputSourceID:bundleID]; + inputSource = [InputSourceHelper inputSourceForInputSourceID:bundleID]; // if it still doesn't register successfully, bail. if (!inputSource) { NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID); @@ -80,22 +81,22 @@ int main(int argc, char *argv[]) } // if it's not enabled, just enabled it - if (inputSource && ![OVInputSourceHelper inputSourceEnabled:inputSource]) { + if (inputSource && ![InputSourceHelper inputSourceEnabled:inputSource]) { NSLog(@"Enabling input source %@ at %@.", bundleID, [bundleURL absoluteString]); - BOOL status = [OVInputSourceHelper enableInputSource:inputSource]; + BOOL status = [InputSourceHelper enableInputSource:inputSource]; if (!status) { NSLog(@"Fatal error: Cannot enable input source %@.", bundleID); return -1; } - if (![OVInputSourceHelper inputSourceEnabled:inputSource]){ + if (![InputSourceHelper inputSourceEnabled:inputSource]){ NSLog(@"Fatal error: Cannot enable input source %@.", bundleID); return -1; } } if (argc > 2 && !strcmp(argv[2], "--all")) { - BOOL enabled = [OVInputSourceHelper enableAllInputModesForInputSourceBundleID:bundleID]; + BOOL enabled = [InputSourceHelper enableAllInputModesForInputSourceBundleID:bundleID]; if (enabled) { NSLog(@"All input sources enabled for %@", bundleID); } diff --git a/Source/vChewingInstaller-Bridging-Header.h b/Source/vChewingInstaller-Bridging-Header.h new file mode 100644 index 00000000..1b2cb5d6 --- /dev/null +++ b/Source/vChewingInstaller-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 6e83dec4..c4a0bbb6 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ 5BC3EE1C278FC48C00F5E44C /* VTCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC3EE19278FC48C00F5E44C /* VTCandidateController.swift */; }; 5BC3EE1D278FC48C00F5E44C /* HorizontalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC3EE1A278FC48C00F5E44C /* HorizontalCandidateController.swift */; }; 5BC3FB83278492DE0022E99A /* data-chs.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5BC3FB82278492DE0022E99A /* data-chs.txt */; }; + 5BDF2CFE2791BE4400838ADB /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDF2CFD2791BE4400838ADB /* InputSourceHelper.swift */; }; + 5BDF2CFF2791BECC00838ADB /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDF2CFD2791BE4400838ADB /* InputSourceHelper.swift */; }; 5BF4A6FE27844738007DC6E7 /* frmAboutWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 5BF4A6FC27844738007DC6E7 /* frmAboutWindow.m */; }; 5BF4A70027844DC5007DC6E7 /* frmAboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5BF4A70227844DC5007DC6E7 /* frmAboutWindow.xib */; }; 6A0421A815FEF3F50061ED63 /* FastLM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A0421A615FEF3F50061ED63 /* FastLM.cpp */; }; @@ -23,7 +25,6 @@ 6A0D4ED015FC0D6400ABF4B3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4EC415FC0D6400ABF4B3 /* AppDelegate.m */; }; 6A0D4ED215FC0D6400ABF4B3 /* InputMethodController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4EC715FC0D6400ABF4B3 /* InputMethodController.mm */; }; 6A0D4ED315FC0D6400ABF4B3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4EC815FC0D6400ABF4B3 /* main.m */; }; - 6A0D4ED415FC0D6400ABF4B3 /* OVInputSourceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4ECA15FC0D6400ABF4B3 /* OVInputSourceHelper.m */; }; 6A0D4ED515FC0D6400ABF4B3 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4ECC15FC0D6400ABF4B3 /* PreferencesWindowController.m */; }; 6A0D4F0815FC0DA600ABF4B3 /* Bopomofo.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 6A0D4EEF15FC0DA600ABF4B3 /* Bopomofo.tiff */; }; 6A0D4F0915FC0DA600ABF4B3 /* Bopomofo@2x.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 6A0D4EF015FC0DA600ABF4B3 /* Bopomofo@2x.tiff */; }; @@ -38,7 +39,6 @@ 6A2E40F9253A6AA000D1AE1D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A2E40F5253A69DA00D1AE1D /* Images.xcassets */; }; 6A38BC1515FC117A00A8A51F /* data.txt in Resources */ = {isa = PBXBuildFile; fileRef = 6A38BBF615FC117A00A8A51F /* data.txt */; }; 6A38BC2815FC158A00A8A51F /* InputMethodKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6A38BC2715FC158A00A8A51F /* InputMethodKit.framework */; }; - 6AB3620D274CA50700AC7547 /* OVInputSourceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4ECA15FC0D6400ABF4B3 /* OVInputSourceHelper.m */; }; 6ACA41CD15FC1D7500935EF6 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6A0D4EA615FC0D2D00ABF4B3 /* Cocoa.framework */; }; 6ACA41F915FC1D9000935EF6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ACA41E915FC1D9000935EF6 /* AppDelegate.m */; }; 6ACA41FA15FC1D9000935EF6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6ACA41EA15FC1D9000935EF6 /* InfoPlist.strings */; }; @@ -88,10 +88,12 @@ 5B9781D72763850700897999 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "Source/zh-Hans.lproj/InfoPlist.strings"; sourceTree = ""; }; 5B9781D82763850700897999 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "Source/zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 5B9781D92763850700897999 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.xib"; sourceTree = ""; }; + 5BA923AC2791B7C20001323A /* vChewingInstaller-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "vChewingInstaller-Bridging-Header.h"; sourceTree = ""; }; 5BC3EE18278FC48C00F5E44C /* VerticalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerticalCandidateController.swift; sourceTree = ""; }; 5BC3EE19278FC48C00F5E44C /* VTCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VTCandidateController.swift; sourceTree = ""; }; 5BC3EE1A278FC48C00F5E44C /* HorizontalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalCandidateController.swift; sourceTree = ""; }; 5BC3FB82278492DE0022E99A /* data-chs.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "data-chs.txt"; sourceTree = ""; }; + 5BDF2CFD2791BE4400838ADB /* InputSourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceHelper.swift; sourceTree = ""; }; 5BF4A6FB27844738007DC6E7 /* frmAboutWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = frmAboutWindow.h; sourceTree = ""; }; 5BF4A6FC27844738007DC6E7 /* frmAboutWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = frmAboutWindow.m; sourceTree = ""; }; 5BF4A70327844DD0007DC6E7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/frmAboutWindow.xib; sourceTree = ""; }; @@ -109,8 +111,6 @@ 6A0D4EC615FC0D6400ABF4B3 /* InputMethodController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputMethodController.h; sourceTree = ""; }; 6A0D4EC715FC0D6400ABF4B3 /* InputMethodController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputMethodController.mm; sourceTree = ""; }; 6A0D4EC815FC0D6400ABF4B3 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 6A0D4EC915FC0D6400ABF4B3 /* OVInputSourceHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVInputSourceHelper.h; sourceTree = ""; }; - 6A0D4ECA15FC0D6400ABF4B3 /* OVInputSourceHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OVInputSourceHelper.m; sourceTree = ""; }; 6A0D4ECB15FC0D6400ABF4B3 /* PreferencesWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesWindowController.h; sourceTree = ""; }; 6A0D4ECC15FC0D6400ABF4B3 /* PreferencesWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindowController.m; sourceTree = ""; }; 6A0D4EEF15FC0DA600ABF4B3 /* Bopomofo.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Bopomofo.tiff; sourceTree = ""; }; @@ -264,6 +264,7 @@ 6A0D4EC215FC0D3C00ABF4B3 /* Source */ = { isa = PBXGroup; children = ( + 5BDF2CFD2791BE4400838ADB /* InputSourceHelper.swift */, 5B58E87D278413E7003EA2AD /* MITLicense.txt */, 6A0D4ED815FC0DA600ABF4B3 /* CandidateUI */, 6A38BBDD15FC115800A8A51F /* Data */, @@ -280,12 +281,11 @@ 6A0D4EF615FC0DA600ABF4B3 /* vChewing-Prefix.pch */, 6AFF97EF253B299E007F1C49 /* OVNonModalAlertWindowController.h */, 6AFF97F1253B299E007F1C49 /* OVNonModalAlertWindowController.m */, - 6A0D4EC915FC0D6400ABF4B3 /* OVInputSourceHelper.h */, - 6A0D4ECA15FC0D6400ABF4B3 /* OVInputSourceHelper.m */, 6A0D4ECB15FC0D6400ABF4B3 /* PreferencesWindowController.h */, 6A0D4ECC15FC0D6400ABF4B3 /* PreferencesWindowController.m */, D427A9C025ED28CC005D43E0 /* OpenCCBridge.swift */, D427A9BF25ED28CC005D43E0 /* vChewing-Bridging-Header.h */, + 5BA923AC2791B7C20001323A /* vChewingInstaller-Bridging-Header.h */, 5B42B63E27876FDC00BB9B9F /* UserOverrideModel.cpp */, 5B42B63F27876FDC00BB9B9F /* UserOverrideModel.h */, ); @@ -530,6 +530,9 @@ 6A0D4EA115FC0D2D00ABF4B3 = { LastSwiftMigration = 1240; }; + 6ACA41CA15FC1D7500935EF6 = { + LastSwiftMigration = 1320; + }; }; }; buildConfigurationList = 6A0D4E9715FC0CFA00ABF4B3 /* Build configuration list for PBXProject "vChewing" */; @@ -621,10 +624,10 @@ buildActionMask = 2147483647; files = ( 6A0D4ED015FC0D6400ABF4B3 /* AppDelegate.m in Sources */, + 5BDF2CFE2791BE4400838ADB /* InputSourceHelper.swift in Sources */, 6A0D4ED215FC0D6400ABF4B3 /* InputMethodController.mm in Sources */, 6A0D4ED315FC0D6400ABF4B3 /* main.m in Sources */, 5BF4A6FE27844738007DC6E7 /* frmAboutWindow.m in Sources */, - 6A0D4ED415FC0D6400ABF4B3 /* OVInputSourceHelper.m in Sources */, 5BC3EE1B278FC48C00F5E44C /* VerticalCandidateController.swift in Sources */, 5B42B64027876FDC00BB9B9F /* UserOverrideModel.cpp in Sources */, 6A0D4ED515FC0D6400ABF4B3 /* PreferencesWindowController.m in Sources */, @@ -643,8 +646,8 @@ files = ( 6ACA41F915FC1D9000935EF6 /* AppDelegate.m in Sources */, 6A225A232367A1D700F685C6 /* ArchiveUtil.m in Sources */, - 6AB3620D274CA50700AC7547 /* OVInputSourceHelper.m in Sources */, 6ACA41FF15FC1D9000935EF6 /* main.m in Sources */, + 5BDF2CFF2791BECC00838ADB /* InputSourceHelper.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -901,7 +904,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Source/vChewing-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; @@ -1022,6 +1024,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1046,11 +1049,17 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../; INFOPLIST_FILE = "Source/Installer/Installer-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "org.openvanilla.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OBJC_BRIDGING_HEADER = "Source/vChewingInstaller-Bridging-Header.h"; + SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; name = Debug; @@ -1061,6 +1070,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1079,10 +1089,16 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../; INFOPLIST_FILE = "Source/Installer/Installer-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "org.openvanilla.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OBJC_BRIDGING_HEADER = "Source/vChewingInstaller-Bridging-Header.h"; + SWIFT_VERSION = 5.0; WRAPPER_EXTENSION = app; }; name = Release;