swift-typed-resources

1.0.0

Simple Swift Package to generate typed resources (via keypath mechanism) in code such as Strings or Images
bestK1ngArthur/swift-typed-resources

What's New

1.0.0

2025-07-21T20:36:26Z
  • Bump swift-argument-parser version
  • Update readme

Swift Typed Resources

Simple Swift Package to generate typed resources (via keypath mechanism) in code such as Strings or Images. Inspired by R.swift.

Example

struct SettingsView: View {
    var body: some View {
        Text(\.settingsDataTitle)
    }
}

Supported File Types

🔠 Strings 🖼️ Images
✅ .xcstrings ✅ .xcassets

Usage in Swift Package

Install

You can add swift-typed-resources to an Swift Package by adding it as a dependency.

let package = Package(
    name: "MyPackage",
    platforms: [.iOS(.v15), .macOS(.v13)],
    products: [
        .library(
            name: "MyPackage",
            targets: ["MyPackage"]
        )
    ],
    dependencies: [
        .package(url: "https://github.com/bestK1ngArthur/swift-typed-resources.git", exact: "0.0.6")
    ],
    targets: [
        .target(
            name: "MyPackage",
            dependencies: [
                .product(name: "SwiftTypedResources", package: "swift-typed-resources")
            ],
            resources: [.process("Resources")]
        )
    ]
)

Generate

  1. Right-click on MyPackage to show Xcode context menu.
  2. Then select GenerateResources in swift-typed-resources section to generate swift files.
Screenshot 2024-12-26 at 13 12 09

Generated Files Example

Generated/TypedStrings.swift

import SwiftTypedResources

public extension TypedStrings {

    // MARK: Main
    var mainActivity: TypedStringConfig { (key: "Main.Activity", table: "Localizable", bundle: .module) }
    var mainAppName: TypedStringConfig { (key: "Main.AppName", table: "Localizable", bundle: .module) }
}

Generated/TypedImages.swift

import SwiftTypedResources

public extension TypedImages {

    // MARK: App Icons
    var appIconClassicPreview: TypedImageConfig { (name: "AppIcon-Classic-Preview", bundle: .module) }
    var appIconFreshPreview: TypedImageConfig { (name: "AppIcon-Fresh-Preview", bundle: .module) }
}

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

Last updated: Mon Oct 27 2025 13:50:01 GMT-0900 (Hawaii-Aleutian Daylight Time)