From db5db2805433262d9743590cc66e1f700c41aa92 Mon Sep 17 00:00:00 2001 From: Dong Yuwei Date: Sat, 16 Mar 2024 20:09:27 +0800 Subject: [PATCH] loadPreparedData asynchronously; fix build in Xcode 15.3 --- .gitignore | 2 + Podfile.lock | 4 +- .../MDCDamerauLevenshtein.podspec.json | 1 + Pods/Manifest.lock | 4 +- Pods/Pods.xcodeproj/project.pbxproj | 4 +- .../xcschemes/GCDWebServer.xcscheme | 58 ------------------- .../xcschemes/MDCDamerauLevenshtein.xcscheme | 58 ------------------- .../xcschemes/Pods-Tests.xcscheme | 58 ------------------- .../xcschemes/Pods-hallelujah.xcscheme | 58 ------------------- .../xcschemes/xcschememanagement.plist | 31 ---------- .../Pods-Tests/Pods-Tests-frameworks.sh | 2 +- .../Pods-hallelujah-frameworks.sh | 2 +- hallelujah.xcodeproj/project.pbxproj | 14 +++-- src/ConversionEngine.mm | 16 +++-- 14 files changed, 29 insertions(+), 283 deletions(-) delete mode 100644 Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/GCDWebServer.xcscheme delete mode 100644 Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/MDCDamerauLevenshtein.xcscheme delete mode 100644 Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-Tests.xcscheme delete mode 100644 Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-hallelujah.xcscheme delete mode 100644 Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/.gitignore b/.gitignore index 6888f49..8af46f4 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ Pods/Target Support Files/GCDWebServer/GCDWebServer.debug.xcconfig Pods/Target Support Files/GCDWebServer/GCDWebServer.release.xcconfig Pods/Target Support Files/MDCDamerauLevenshtein/MDCDamerauLevenshtein.debug.xcconfig Pods/Target Support Files/MDCDamerauLevenshtein/MDCDamerauLevenshtein.release.xcconfig +Pods/Pods.xcodeproj/xcuserdata/yuweidong.xcuserdatad/ +*.xcuserdatad diff --git a/Podfile.lock b/Podfile.lock index 097b930..51134fc 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -24,8 +24,8 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 - MDCDamerauLevenshtein: 973db4b240863f3c6b64f076ef2c27a73a8af0bf + MDCDamerauLevenshtein: 5b84ae3325d6678d44850915e882ce22d4d5537d PODFILE CHECKSUM: 97aa7f494743e0815318a886fcba109e8ae99240 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/Pods/Local Podspecs/MDCDamerauLevenshtein.podspec.json b/Pods/Local Podspecs/MDCDamerauLevenshtein.podspec.json index 50dab06..afce850 100644 --- a/Pods/Local Podspecs/MDCDamerauLevenshtein.podspec.json +++ b/Pods/Local Podspecs/MDCDamerauLevenshtein.podspec.json @@ -29,6 +29,7 @@ "osx": null, "ios": null, "tvos": null, + "visionos": null, "watchos": null } } diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock index 097b930..51134fc 100644 --- a/Pods/Manifest.lock +++ b/Pods/Manifest.lock @@ -24,8 +24,8 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 - MDCDamerauLevenshtein: 973db4b240863f3c6b64f076ef2c27a73a8af0bf + MDCDamerauLevenshtein: 5b84ae3325d6678d44850915e882ce22d4d5537d PODFILE CHECKSUM: 97aa7f494743e0815318a886fcba109e8ae99240 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index 77e9e01..4a91d6c 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -536,8 +536,8 @@ BFDFE7DC352907FC980B868725387E98 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1240; - LastUpgradeCheck = 1240; + LastSwiftUpdateCheck = 1500; + LastUpgradeCheck = 1500; }; buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; diff --git a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/GCDWebServer.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/GCDWebServer.xcscheme deleted file mode 100644 index 8f1efa3..0000000 --- a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/GCDWebServer.xcscheme +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/MDCDamerauLevenshtein.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/MDCDamerauLevenshtein.xcscheme deleted file mode 100644 index 31912d0..0000000 --- a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/MDCDamerauLevenshtein.xcscheme +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-Tests.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-Tests.xcscheme deleted file mode 100644 index 6cfcdb8..0000000 --- a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-Tests.xcscheme +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-hallelujah.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-hallelujah.xcscheme deleted file mode 100644 index ff291ef..0000000 --- a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/Pods-hallelujah.xcscheme +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 648aae3..0000000 --- a/Pods/Pods.xcodeproj/xcuserdata/yuwdong.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - SchemeUserState - - GCDWebServer.xcscheme - - isShown - - - MDCDamerauLevenshtein.xcscheme - - isShown - - - Pods-Tests.xcscheme - - isShown - - - Pods-hallelujah.xcscheme - - isShown - - - - SuppressBuildableAutocreation - - - diff --git a/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh b/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh index ba89c29..e38009f 100755 --- a/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh +++ b/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh @@ -18,7 +18,7 @@ echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" -SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" +SWIFT_STDLIB_PATH="${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" BCSYMBOLMAP_DIR="BCSymbolMaps" diff --git a/Pods/Target Support Files/Pods-hallelujah/Pods-hallelujah-frameworks.sh b/Pods/Target Support Files/Pods-hallelujah/Pods-hallelujah-frameworks.sh index a69ab8f..60bc9b6 100755 --- a/Pods/Target Support Files/Pods-hallelujah/Pods-hallelujah-frameworks.sh +++ b/Pods/Target Support Files/Pods-hallelujah/Pods-hallelujah-frameworks.sh @@ -18,7 +18,7 @@ echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" -SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" +SWIFT_STDLIB_PATH="${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" BCSYMBOLMAP_DIR="BCSymbolMaps" diff --git a/hallelujah.xcodeproj/project.pbxproj b/hallelujah.xcodeproj/project.pbxproj index 6dac4b1..59c6d4f 100644 --- a/hallelujah.xcodeproj/project.pbxproj +++ b/hallelujah.xcodeproj/project.pbxproj @@ -169,7 +169,7 @@ name = Products; sourceTree = ""; }; - 29B97314FDCFA39411CA2CEA = { + 29B97314FDCFA39411CA2CEA /* NumberInput */ = { isa = PBXGroup; children = ( 080E96DDFE201D6D7F000001 /* Classes */, @@ -311,7 +311,7 @@ en, Base, ); - mainGroup = 29B97314FDCFA39411CA2CEA; + mainGroup = 29B97314FDCFA39411CA2CEA /* NumberInput */; productRefGroup = 19C28FACFE9D520D11CA2CBB /* Products */; projectDirPath = ""; projectRoot = ""; @@ -521,7 +521,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", "\"${PODS_CONFIGURATION_BUILD_DIR}/MDCDamerauLevenshtein/MDCDamerauLevenshtein.framework/Headers\"", - "$SOURCE_ROOT/include", + $SOURCE_ROOT/include, ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; @@ -566,7 +566,7 @@ HEADER_SEARCH_PATHS = ( "$(inherited)", "\"${PODS_CONFIGURATION_BUILD_DIR}/MDCDamerauLevenshtein/MDCDamerauLevenshtein.framework/Headers\"", - "$SOURCE_ROOT/include", + $SOURCE_ROOT/include, ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; @@ -584,13 +584,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0F9B2D528219BB1952DEBE74 /* Pods-hallelujah.debug.xcconfig */; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; - "HEADER_SEARCH_PATHS[arch=*]" = "$SOURCE_ROOT/include"; + "HEADER_SEARCH_PATHS[arch=*]" = $SOURCE_ROOT/include; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "\"$(LOCAL_LIBRARY_DIR)/Input Methods/\""; LIBRARY_SEARCH_PATHS = ( @@ -610,11 +611,12 @@ isa = XCBuildConfiguration; baseConfigurationReference = C821F631E5B6762735CA76CB /* Pods-hallelujah.release.xcconfig */; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_MODEL_TUNING = G5; - "HEADER_SEARCH_PATHS[arch=*]" = "$SOURCE_ROOT/include"; + "HEADER_SEARCH_PATHS[arch=*]" = $SOURCE_ROOT/include; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "\"$(LOCAL_LIBRARY_DIR)/Input Methods/\""; LIBRARY_SEARCH_PATHS = ( diff --git a/src/ConversionEngine.mm b/src/ConversionEngine.mm index c1b7a35..687f782 100644 --- a/src/ConversionEngine.mm +++ b/src/ConversionEngine.mm @@ -25,14 +25,18 @@ + (instancetype)sharedEngine { } - (void)loadPreparedData { - [self loadTrie]; - self.wordsWithFrequencyAndTranslation = [self getWordsWithFrequencyAndTranslation]; - self.substitutions = [self getUserDefinedSubstitutions]; - self.pinyinDict = [self getPinyinData]; - self.phonexEncoded = [self getPhonexEncodedWords]; - self.phonexEncoder = [self getPhonexEncoder]; + // Dispatch the loading process to a background queue. + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + [self loadTrie]; + self.wordsWithFrequencyAndTranslation = [self getWordsWithFrequencyAndTranslation]; + self.substitutions = [self getUserDefinedSubstitutions]; + self.pinyinDict = [self getPinyinData]; + self.phonexEncoded = [self getPhonexEncodedWords]; + self.phonexEncoder = [self getPhonexEncoder]; + }); } + - (void)loadTrie { NSString *path = [[NSBundle mainBundle] pathForResource:@"google_227800_words" ofType:@"bin"]; const char *path2 = [path cStringUsingEncoding:[NSString defaultCStringEncoding]];