Using Apple SwiftUI Translate library: when calling:
try await session.prepareTranslation()
the first time, the API's Language Download sheet does not show (or shows briefly and dismisses immediately) Even when the sheet doesn't show, the keyboard is lowered, as though the sheet would be appearing, but then the keyboard raises as though the sheet was dismissed.
The following Errors are printed in the console dozens of times; but on all subsequent executions, the API Language Download sheet shows as expected.
The trigger code is in a function which is executed when a Translate button is tapped.
Any ideas would be welcome!
Console Error on first execution only
LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
Attempt to map database failed: permission was denied. This attempt will not be retried.
Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
Attempt to map database failed: permission was denied. This attempt will not be retried.
Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
Attempt to map database failed: permission was denied. This attempt will not be retried.
Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
Error returned from iconservicesagent image request: <ISBundleIdentifierIcon: 0x300df3c30> BundleID: (null) digest: 7749FEEE-F663-39B4-AD68-A18CFF762CCC - <ISImageDescriptor: 0x3033b26c0> - (64.00, 64.00)@2x v:4 l:5 a:0:0:0:0 t:() b:0 s:2 ps:0 digest: DF83A970-D4C9-3D90-BB7D-0BC21FC22E03 error: Error Domain=NSOSStatusErrorDomain Code=-609 "Client is disallowed from making such an icon request" UserInfo={NSLocalizedDescription=Client is disallowed from making such an icon request}
Error returned from iconservicesagent image request: <ISTypeIcon: 0x300d0fb70>,Type: com.apple.appprotection.badge.faceid - <ISImageDescriptor: 0x3033ad0e0> - (32.00, 32.00)@2x v:0 l:5 a:0:0:0:0 t:() b:0 s:2 ps:0 digest: 648D7A72-90CB-3858-9409-5C554BB43B8E error: Error Domain=NSOSStatusErrorDomain Code=-609 "Client is disallowed from making such an icon request" UserInfo={NSLocalizedDescription=Client is disallowed from making such an icon request}
Connection interrupted, finishing translation with error Error Domain=TranslationErrorDomain Code=14 "(null)"
Got response from extension with error: Error Domain=TranslationErrorDomain Code=14 "(null)"
Reported that remote UI finished but didn't get finished configuration, reporting the error as: Error Domain=TranslationErrorDomain Code=20 "(null)"
VS terminated with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
Reported that remote UI finished but didn't get finished configuration, reporting the error as: Error Domain=TranslationErrorDomain Code=14 "(null)"
VS terminated with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
VS terminated with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
VS terminated with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
VS terminated with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
Trigger the Translation:
// check if we need to create a translation configuration
if configuration == nil {
configuration = TranslationSession.Configuration.init(
source: Locale.Language(identifier: sourceLanguageCode),
target: Locale.Language(identifier: targetLanguageCode)
)
} else {
// or just update the target code then invalidate the config to re-trigger the refresh
of .translationTask()
configuration?.source = Locale.Language(identifier: sourceLanguageCode)
configuration?.target = Locale.Language(identifier: targetLanguageCode)
configuration?.invalidate()
}
Prepare and check if Download sheet should be presented:
.translationTask(configuration) { session in
do {
// prepare translation & present API download sheet if lanugage download needed.
try await session.prepareTranslation()
} catch {
print("Translate failed: \(error)")
}
}