From c2d1fe7703a468a95d96a9567bf89c8665d7c68b Mon Sep 17 00:00:00 2001 From: Yuxuan Li Date: Wed, 20 Mar 2024 01:53:30 -0400 Subject: [PATCH 1/2] Add StringCatalogEnumSample project to demonstrate use cases --- .../project.pbxproj | 381 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../xcshareddata/swiftpm/Package.resolved | 15 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../Assets.xcassets/Contents.json | 6 + .../StringCatalogEnumSample/ContentView.swift | 57 +++ .../GeneratedStrings.swift | 35 ++ .../Localizable.xcstrings | 61 +++ .../Preview Assets.xcassets/Contents.json | 6 + .../StringCatalogEnumSampleApp.swift | 17 + 13 files changed, 625 insertions(+) create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.pbxproj create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/Contents.json create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/ContentView.swift create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/GeneratedStrings.swift create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Localizable.xcstrings create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/StringCatalogEnumSampleApp.swift diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.pbxproj b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e1fa13f --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.pbxproj @@ -0,0 +1,381 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + 516EC65E2BAA39E700D67B9F /* StringCatalogEnumLibrary in Frameworks */ = {isa = PBXBuildFile; productRef = 516EC65D2BAA39E700D67B9F /* StringCatalogEnumLibrary */; }; + 516EC6602BAA39E700D67B9F /* xcstrings-enum-generate in Frameworks */ = {isa = PBXBuildFile; productRef = 516EC65F2BAA39E700D67B9F /* xcstrings-enum-generate */; }; + 516EC6642BAA865E00D67B9F /* GeneratedStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516EC6632BAA865E00D67B9F /* GeneratedStrings.swift */; }; + 5191458C2BAA2F83005A36C2 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 5191458B2BAA2F83005A36C2 /* Localizable.xcstrings */; }; + 519A8B652BAA114300839916 /* StringCatalogEnumSampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519A8B642BAA114300839916 /* StringCatalogEnumSampleApp.swift */; }; + 519A8B672BAA114300839916 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519A8B662BAA114300839916 /* ContentView.swift */; }; + 519A8B692BAA114600839916 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 519A8B682BAA114600839916 /* Assets.xcassets */; }; + 519A8B6C2BAA114600839916 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 519A8B6B2BAA114600839916 /* Preview Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 516EC6632BAA865E00D67B9F /* GeneratedStrings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedStrings.swift; sourceTree = ""; }; + 5191458B2BAA2F83005A36C2 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = ""; }; + 519A8B612BAA114300839916 /* StringCatalogEnumSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StringCatalogEnumSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 519A8B642BAA114300839916 /* StringCatalogEnumSampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringCatalogEnumSampleApp.swift; sourceTree = ""; }; + 519A8B662BAA114300839916 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 519A8B682BAA114600839916 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 519A8B6B2BAA114600839916 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 519A8B5E2BAA114300839916 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 516EC6602BAA39E700D67B9F /* xcstrings-enum-generate in Frameworks */, + 516EC65E2BAA39E700D67B9F /* StringCatalogEnumLibrary in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 519A8B582BAA114300839916 = { + isa = PBXGroup; + children = ( + 519A8B632BAA114300839916 /* StringCatalogEnumSample */, + 519A8B622BAA114300839916 /* Products */, + ); + sourceTree = ""; + }; + 519A8B622BAA114300839916 /* Products */ = { + isa = PBXGroup; + children = ( + 519A8B612BAA114300839916 /* StringCatalogEnumSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 519A8B632BAA114300839916 /* StringCatalogEnumSample */ = { + isa = PBXGroup; + children = ( + 5191458B2BAA2F83005A36C2 /* Localizable.xcstrings */, + 519A8B642BAA114300839916 /* StringCatalogEnumSampleApp.swift */, + 519A8B662BAA114300839916 /* ContentView.swift */, + 516EC6632BAA865E00D67B9F /* GeneratedStrings.swift */, + 519A8B682BAA114600839916 /* Assets.xcassets */, + 519A8B6A2BAA114600839916 /* Preview Content */, + ); + path = StringCatalogEnumSample; + sourceTree = ""; + }; + 519A8B6A2BAA114600839916 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 519A8B6B2BAA114600839916 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 519A8B602BAA114300839916 /* StringCatalogEnumSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 519A8B6F2BAA114600839916 /* Build configuration list for PBXNativeTarget "StringCatalogEnumSample" */; + buildPhases = ( + 519A8B5D2BAA114300839916 /* Sources */, + 519A8B5E2BAA114300839916 /* Frameworks */, + 519A8B5F2BAA114300839916 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = StringCatalogEnumSample; + packageProductDependencies = ( + 516EC65D2BAA39E700D67B9F /* StringCatalogEnumLibrary */, + 516EC65F2BAA39E700D67B9F /* xcstrings-enum-generate */, + ); + productName = StringCatalogEnumSample; + productReference = 519A8B612BAA114300839916 /* StringCatalogEnumSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 519A8B592BAA114300839916 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + 519A8B602BAA114300839916 = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = 519A8B5C2BAA114300839916 /* Build configuration list for PBXProject "StringCatalogEnumSample" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 519A8B582BAA114300839916; + packageReferences = ( + 516EC65C2BAA39E700D67B9F /* XCLocalSwiftPackageReference "../XStringCatalog/StringCatalogEnum" */, + ); + productRefGroup = 519A8B622BAA114300839916 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 519A8B602BAA114300839916 /* StringCatalogEnumSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 519A8B5F2BAA114300839916 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 519A8B6C2BAA114600839916 /* Preview Assets.xcassets in Resources */, + 519A8B692BAA114600839916 /* Assets.xcassets in Resources */, + 5191458C2BAA2F83005A36C2 /* Localizable.xcstrings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 519A8B5D2BAA114300839916 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 519A8B672BAA114300839916 /* ContentView.swift in Sources */, + 516EC6642BAA865E00D67B9F /* GeneratedStrings.swift in Sources */, + 519A8B652BAA114300839916 /* StringCatalogEnumSampleApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 519A8B6D2BAA114600839916 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 519A8B6E2BAA114600839916 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 519A8B702BAA114600839916 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"StringCatalogEnumSample/Preview Content\""; + DEVELOPMENT_TEAM = 4457JVC2UZ; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.YuxuanLi.StringCatalogEnumSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 519A8B712BAA114600839916 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"StringCatalogEnumSample/Preview Content\""; + DEVELOPMENT_TEAM = 4457JVC2UZ; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.YuxuanLi.StringCatalogEnumSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 519A8B5C2BAA114300839916 /* Build configuration list for PBXProject "StringCatalogEnumSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 519A8B6D2BAA114600839916 /* Debug */, + 519A8B6E2BAA114600839916 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 519A8B6F2BAA114600839916 /* Build configuration list for PBXNativeTarget "StringCatalogEnumSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 519A8B702BAA114600839916 /* Debug */, + 519A8B712BAA114600839916 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 516EC65C2BAA39E700D67B9F /* XCLocalSwiftPackageReference "../XStringCatalog/StringCatalogEnum" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../XStringCatalog/StringCatalogEnum; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 516EC65D2BAA39E700D67B9F /* StringCatalogEnumLibrary */ = { + isa = XCSwiftPackageProductDependency; + productName = StringCatalogEnumLibrary; + }; + 516EC65F2BAA39E700D67B9F /* xcstrings-enum-generate */ = { + isa = XCSwiftPackageProductDependency; + productName = "xcstrings-enum-generate"; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 519A8B592BAA114300839916 /* Project object */; +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..6533c19 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "b4bd8aca20b55ccc7f089bc7a746454cea99ac3758e577d138c983514ad5bc9c", + "pins" : [ + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531", + "version" : "1.2.3" + } + } + ], + "version" : 3 +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AccentColor.colorset/Contents.json b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/Contents.json b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/ContentView.swift b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/ContentView.swift new file mode 100644 index 0000000..39955a3 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/ContentView.swift @@ -0,0 +1,57 @@ +// +// ContentView.swift +// StringCatalogEnumSample +// This class provides basic content view to test the XCS string functions +// +// Created by Yuxuan Li on 3/19/24. +// + +import SwiftUI + +/** + To use XString Catalog Enum + Define the key and content within Localizable.xcstrings(This could be any name you want) + Then clone the repo and make release the dirctore "StringCatalogEnum" + Once make release is succedd + "Use./xcstrings-enum-generate --xcstrings-path /Path/To/(This could use any name you want)Localizable.xcstrings --output-filename /Path/to/GeneratedStrings.swift(This name could be any name you want) + It will automatically generated an swift file and put it into the project directory + */ +//Basic Usage + +struct ContentView: View { + + //example variable + let userName = "Alice" + //This could be changed + let itemCount = 3 + + var welcomeMessage:String { + String(format: NSLocalizedString("WelcomeMessageFormat", comment: "Welcome message with user name on it"), userName) + } + + var itemMessage: String { + itemCount == 1 ? + NSLocalizedString("SingleItemMessage", comment: "Message for a single item") : + String(format: NSLocalizedString("MultipleItemsMessage", comment: "Message format for multiple items"), itemCount) + } + + + var body: some View { + VStack(spacing:20) { + + Text(welcomeMessage) + Text(itemMessage) + + //This content is defined within Localizable.xcstrins. + Text(XCS.welcomeBackKey.key) + Text(XCS.testingKey.key) + } + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/GeneratedStrings.swift b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/GeneratedStrings.swift new file mode 100644 index 0000000..542d834 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/GeneratedStrings.swift @@ -0,0 +1,35 @@ +// This file is generated by XcodeStringEnum. Please do *NOT* update it manually. +// As a common practice, swiftLint is disabled for generated files. +// swiftlint:disable all + +import SwiftUI + +/// Makes it a bit easier to type. +typealias XCS = XcodeStringKey + +/// Generated by StringCatalogEnum, this enum contains all existing Strin Category keys. +enum XcodeStringKey: String, CaseIterable { + + // MARK: - The following cases should be manually replaced in your codebase. + + /// 'en': "Hello, %@! Welcome to our app." + case welcomeMessageFormat = "WelcomeMessageFormat" + /// 'en': "This Content is for testing only" + case testingKey = "TestingKey" + /// 'en': "Welcome Back!" + case welcomeBackKey = "WelcomeBackKey" + /// 'en': "You are now have %d items." + case multipleItemsMessage = "MultipleItemsMessage" + /// 'en': "You are now have 1 item." + case singleItemMessage = "SingleItemMessage" + /// No localizations available + case helloWorld = "Hello, world!" + + /// Usage: `SwiftUI.Text(XCS.yourStringCatalogKey.key)` + var key: LocalizedStringKey { LocalizedStringKey(rawValue) } + + var string: String { NSLocalizedString(self.rawValue, comment: "Generated localization from String Catalog key: \(key)") } + + // var text: String.LocalizationValue { String.LocalizationValue(rawValue) } +} +// swiftlint:enable all \ No newline at end of file diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Localizable.xcstrings b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Localizable.xcstrings new file mode 100644 index 0000000..5963597 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Localizable.xcstrings @@ -0,0 +1,61 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "MultipleItemsMessage" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "You are now have %d items." + } + } + } + }, + "SingleItemMessage" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "You are now have 1 item." + } + } + } + }, + "TestingKey" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "This Content is for testing only" + } + } + } + }, + "WelcomeBackKey" : { + "extractionState" : "stale", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Welcome Back!" + } + } + } + }, + "WelcomeMessageFormat" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Hello, %@! Welcome to our app." + } + } + } + } + }, + "version" : "1.0" +} \ No newline at end of file diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Preview Content/Preview Assets.xcassets/Contents.json b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/StringCatalogEnumSampleApp.swift b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/StringCatalogEnumSampleApp.swift new file mode 100644 index 0000000..973530c --- /dev/null +++ b/StringCatalogEnum/Samples/StringCatalogEnumSample/StringCatalogEnumSample/StringCatalogEnumSampleApp.swift @@ -0,0 +1,17 @@ +// +// StringCatalogEnumSampleApp.swift +// StringCatalogEnumSample +// +// Created by Yuxuan Li on 3/19/24. +// + +import SwiftUI + +@main +struct StringCatalogEnumSampleApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} From d7931a657126639e54355668f6476534ec185cb3 Mon Sep 17 00:00:00 2001 From: Yuxuan Li Date: Wed, 20 Mar 2024 02:06:42 -0400 Subject: [PATCH 2/2] Fixing the issue that make relese doesnt work --- .../StringEnumHelper.swift | 69 ++++--------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/StringCatalogEnum/Sources/StringCatalogEnumLibrary/StringEnumHelper.swift b/StringCatalogEnum/Sources/StringCatalogEnumLibrary/StringEnumHelper.swift index 10dffd5..8b7280d 100644 --- a/StringCatalogEnum/Sources/StringCatalogEnumLibrary/StringEnumHelper.swift +++ b/StringCatalogEnum/Sources/StringCatalogEnumLibrary/StringEnumHelper.swift @@ -1,15 +1,9 @@ import Foundation -/// Model that helps separate the logic used in StringCatalogEnum struct. public struct StringEnumHelper { public init() {} - /// Creates enum cases depending on whether key == name - /// - Parameters: - /// - stringData: A dictionary containing string data. - /// - keyNameMatches: A boolean flag indicating whether the enum cases should match the keys exactly. - /// - keywordEnum: An array of raw values from the Keyword enum in StringCatalogEnum struct public func createEnumKeys(with stringData: Localizations, keyNameMatches: Bool, keywordEnum: [String]) -> String { var partialOutput = "" var cases = [String]() @@ -21,14 +15,10 @@ public struct StringEnumHelper { continue } - if keyNameMatches { - guard key == name else { - continue - } - } else { - guard key != name else { - continue - } + if keyNameMatches, key != name { + continue + } else if !keyNameMatches, key == name { + continue } guard !knownCases.contains(name) else { @@ -37,7 +27,6 @@ public struct StringEnumHelper { } knownCases.append(name) - // Extract localization values and format them for comments var localizationComments = [String]() if let localizations = data.localizations { for (languageCode, localization) in localizations { @@ -48,75 +37,47 @@ public struct StringEnumHelper { } } - if localizationComments.isEmpty { - localizationComments.append(" /// No localizations available") - } - + localizationComments = localizationComments.isEmpty ? [" /// No localizations available"] : localizationComments let comment = localizationComments.joined(separator: "\n") - let caseString: String = if keywordEnum.contains(name) { - keyNameMatches + let caseString = keywordEnum.contains(name) + ? keyNameMatches ? " case `\(name)`\n" : " case `\(name)` = \"\(key.replacingOccurrences(of: "\n", with: ""))\"\n" - } else { - keyNameMatches + : keyNameMatches ? " case \(name)\n" : " case \(name) = \"\(key.replacingOccurrences(of: "\n", with: ""))\"\n" - } cases.append("\(comment)\n\(caseString)") } + cases.sort() - cases.forEach { string in - partialOutput += string - } + cases.forEach { partialOutput += $0 } return partialOutput } - /// Convert a String Catalog key to a Swift variable name. public func convertToVariableName(key: String) -> String? { var result = key - // Check if the entire string is uppercase if key == key.uppercased() { result = key.lowercased() } - // Uppercase remaining words, e.g. "an example" to "anExample"; result = result.split(separator: " ").enumerated().map { index, substring in index == 0 ? String(substring.prefix(1)).lowercased() + substring.dropFirst() : String(substring).capitalized }.joined() - // Leave only letters and numeric characters result = result.components(separatedBy: CharacterSet.letters.union(CharacterSet.alphanumerics).inverted).joined() - // Remove leading numeric characters - while !result.isEmpty { - let firstLetter = result.prefix(1) - let digitsCharacters = CharacterSet(charactersIn: "0123456789") - if CharacterSet(charactersIn: String(firstLetter)).isSubset(of: digitsCharacters) { - // print("dropping first of: \(result)") - result = String(result.dropFirst()) - } else { - break - } + while let firstChar = result.first, firstChar.isNumber { + result.removeFirst() } - // Return nil if empty - guard !result.isEmpty else { - return nil - } + guard !result.isEmpty else { return nil } + guard result.count > 1 else { return result.lowercased() } - // Return lowercased string if there's only 1 character - guard result.count > 1 else { - return result.lowercased() - } - - // Change the first character to lowercase let firstLetter = result.prefix(1).lowercased() let remainingLetters = result.dropFirst() - result = firstLetter + remainingLetters - - return result + return firstLetter + remainingLetters } }