diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 49c60577c..20775b2a7 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -3198,7 +3198,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 11.0; MARKETING_VERSION = 2.5.0; PRODUCT_BUNDLE_IDENTIFIER = "com.izual.Easydict-debug"; PRODUCT_MODULE_NAME = Easydict; @@ -3238,7 +3238,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 11.0; MARKETING_VERSION = 2.5.0; PRODUCT_BUNDLE_IDENTIFIER = com.izual.Easydict; PRODUCT_MODULE_NAME = Easydict; diff --git a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved index 85e3f87d5..6dda3d72c 100644 --- a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/generative-ai-swift", "state" : { - "revision" : "fead3038a70047a72ea2cf39e96d3add71c372de", - "version" : "0.4.4" + "revision" : "5cf2aae0f4d04b77fe7b2110da1145462ff92b84", + "version" : "0.4.6" } }, { diff --git a/Easydict/Feature/Service/Gemini/GeminiService.swift b/Easydict/Feature/Service/Gemini/GeminiService.swift index 3d9eb13e0..2c510b4fc 100644 --- a/Easydict/Feature/Service/Gemini/GeminiService.swift +++ b/Easydict/Feature/Service/Gemini/GeminiService.swift @@ -75,25 +75,36 @@ public final class GeminiService: QueryService { override public func translate(_ text: String, from: Language, to: Language, completion: @escaping (EZQueryResult, Error?) -> Void) { Task { - // https://github.com/google/generative-ai-swift do { var resultString = "" let prompt = GeminiService.translationPrompt + "Translate the following \(from.rawValue) text into \(to.rawValue): \(text)" print("gemini prompt: \(prompt)") let model = GenerativeModel(name: "gemini-pro", apiKey: apiKey) - let outputContentStream = model.generateContentStream(prompt) - // stream response - for try await outputContent in outputContentStream { + if #available(macOS 12.0, *) { + let outputContentStream = model.generateContentStream(prompt) + + // stream response + for try await outputContent in outputContentStream { + guard let line = outputContent.text else { + return + } + + print("gemini response: \(line)") + resultString += line + } + } else { + let outputContent = try await model.generateContent(prompt) guard let line = outputContent.text else { return } print("gemini response: \(line)") resultString += line - result.translatedResults = [resultString] - completion(result, nil) } + + result.translatedResults = [resultString] + completion(result, nil) } catch { print(error.localizedDescription) completion(result, error) diff --git a/Easydict/Feature/Utility/EZDeviceSystemInfo/EZDeviceSystemInfo.m b/Easydict/Feature/Utility/EZDeviceSystemInfo/EZDeviceSystemInfo.m index 148da924f..79e11eb56 100644 --- a/Easydict/Feature/Utility/EZDeviceSystemInfo/EZDeviceSystemInfo.m +++ b/Easydict/Feature/Utility/EZDeviceSystemInfo/EZDeviceSystemInfo.m @@ -57,7 +57,7 @@ + (NSString *)getDeviceModel { /// Get device UUID, 4F07896A-1580-5270-A0E8-D7FA9DFA6868 + (NSString *)getDeviceUUID { - io_service_t platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); CFStringRef uuidString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR("IOPlatformUUID"), kCFAllocatorDefault, 0); NSString *uuid = (__bridge NSString *)(uuidString); IOObjectRelease(platformExpert);