[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6716":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":18,"lastSyncTime":36,"discoverSource":37},6716,"R.swift","mac-cain13\u002FR.swift","mac-cain13","Strong typed, autocompleted resources like images, fonts and segues in Swift projects","",null,"Swift",9577,780,106,72,0,1,2,4,39.68,"MIT License",false,"main",[25,26,27,28,29,30,31,32],"autocompletion","code-generator","ios","resources","swift","tvos","watchos","xcode","2026-06-12 02:01:29","# R.swift [![Version](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FR.swift.svg?style=flat)](https:\u002F\u002Fcocoapods.org\u002Fpods\u002FR.swift) [![License](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fl\u002FR.swift.svg?style=flat)](License) ![Platform](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fp\u002FR.swift.svg?style=flat)\n\n_Get strong typed, autocompleted resources like images, fonts and segues in Swift projects_\n\n## Why use this?\n\nIt makes your code that uses resources:\n- **Fully typed**, less casting and guessing what a method will return\n- **Compile time checked**, no more incorrect strings that make your app crash at runtime\n- **Autocompleted**, never have to guess that image name again\n\nCurrently you type:\n```swift\nlet icon = UIImage(named: \"settings-icon\")\nlet font = UIFont(name: \"San Francisco\", size: 42)\nlet color = UIColor(named: \"indicator highlight\")\nlet viewController = CustomViewController(nibName: \"CustomView\", bundle: nil)\nlet string = String(format: NSLocalizedString(\"welcome.withName\", comment: \"\"), locale: NSLocale.current, \"Arthur Dent\")\n```\n\nWith R.swift it becomes:\n```swift\nlet icon = R.image.settingsIcon()\nlet font = R.font.sanFrancisco(size: 42)\nlet color = R.color.indicatorHighlight()\nlet viewController = CustomViewController(nib: R.nib.customView)\nlet string = R.string.localizable.welcomeWithName(\"Arthur Dent\")\n```\n\nCheck out [more examples](Documentation\u002FExamples.md) or hear about [how Fabric.app uses R.swift](https:\u002F\u002Facademy.realm.io\u002Fposts\u002Fslug-javi-soto-building-fabric-in-swift\u002F#rswift-2956)!\n\n## Demo\n\n**Autocompleted images:**\n\n![Autocompleted images](Documentation\u002FImages\u002FDemoUseImage.gif)\n\n**Compiletime checked images:**\n\n![Compiletime checked images](Documentation\u002FImages\u002FDemoRenameImage.gif)\n\nThis is only the beginning, check out [more examples](Documentation\u002FExamples.md)!\n\n## CocoaHeadsNL presentation\n\nMathijs Kadijk presented R.swift at the September 2016 CocoaHeadsNL meetup.\nTalking about the ideas behind R.swift and demonstrating how to move from plain stringly-typed iOS code to statically typed code.\n\n\u003Ca href=\"https:\u002F\u002Fwww.youtube.com\u002Fembed\u002FC8kRUTV9TOA\">\u003Cimg src=\"https:\u002F\u002Fi.ytimg.com\u002Fvi\u002FC8kRUTV9TOA\u002Fmaxresdefault.jpg\" width=\"560\" alt=\"R.swift presentation at CocoaHeadsNL\">\u003C\u002Fa>\n\n## Features\n\nAfter installing R.swift into your project you can use the `R`-struct to access resources. If the struct is outdated just build and R.swift will correct any missing\u002Fchanged\u002Fadded resources.\n\nR.swift currently supports these types of resources:\n- [Images](Documentation\u002FExamples.md#images)\n- [Fonts](Documentation\u002FExamples.md#custom-fonts)\n- [Resource files](Documentation\u002FExamples.md#resource-files)\n- [Colors](Documentation\u002FExamples.md#colors)\n- [Localized strings](Documentation\u002FExamples.md#localized-strings)\n- [Storyboards](Documentation\u002FExamples.md#storyboards)\n- [Segues](Documentation\u002FExamples.md#segues)\n- [Nibs](Documentation\u002FExamples.md#nibs)\n- [Reusable cells](Documentation\u002FExamples.md#reusable-table-view-cells)\n- [Project](Documentation\u002FExamples.md#project)\n- [Entitlements](Documentation\u002FExamples.md#entitlements)\n- [Info.plist](Documentation\u002FExamples.md#info-plist)\n\nRuntime validation with [`R.validate()`](Documentation\u002FExamples.md#runtime-validation):\n- If all images used in storyboards and nibs are available\n- If all named colors used in storyboards and nibs are available\n- If all view controllers with storyboard identifiers can be loaded\n- If all custom fonts can be loaded\n\n## Q&A\n\n- [Why was R.swift created?](Documentation\u002FQandA.md#why-was-rswift-created)\n- [Why should I choose R.swift over alternative X or Y?](Documentation\u002FQandA.md#why-should-i-choose-rswift-over-alternative-x-or-y)\n- [What are the requirements to run R.swift?](Documentation\u002FQandA.md#what-are-the-requirements-to-run-rswift)\n- [How to fix missing imports in the generated file?](Documentation\u002FQandA.md#how-to-fix-missing-imports-in-the-generated-file)\n- [How to use classes with the same name as their module?](Documentation\u002FQandA.md#how-to-use-classes-with-the-same-name-as-their-module)\n- [Can I ignore resources?](Documentation\u002FIgnoring.md)\n- [Can I use R.swift in a library?](Documentation\u002FQandA.md#can-i-use-rswift-in-a-library)\n- [How does R.swift work?](Documentation\u002FQandA.md#how-does-rswift-work)\n- [How to upgrade to a new major version?](Documentation\u002FMigration.md)\n- [How can I only run specific generators?](Documentation\u002FIgnoring.md#only-run-specific-generators-exclude-rsomething)\n\n## Installation\n\nAs of Rswift 7, Swift Package Manager is the recommended method of installation.\n\n[Demo video: Updating from R.swift 6 to Rswift 7](https:\u002F\u002Fyoutu.be\u002FicihJ_hin3I?t=66) (Starting at 1:06, this describes the installation of Rswift 7).\n\n### Xcode project using SPM (Recommended)\n\n[Demo Video: Install R.swift in Xcode with SPM](Documentation\u002FRswiftSPMInstallation.mp4)\n\n1. In Project Settings, on the tab \"Package Dependencies\", click \"+\", search for `https:\u002F\u002Fgithub.com\u002Fmac-cain13\u002FR.swift` and click \"Add Package\".\n2. Select the target that will use R.swift next to \"RswiftLibrary\" and click \"Add Package\".\n4. Now click on your target, on the tab \"Build Phases\", in the section \"Run Build Tool Plug-ins\", click \"+\" and add `RswiftGenerateInternalResources`. ([Screenshot](Documentation\u002FImages\u002FRunBuildToolPluginsRswift.png))\n5. Now the `R` struct should be available in your code, use auto-complete to explore all static references.\n\nNote: The first build you might need to approve the new plugin by clicking the build error warning you about the new plugin.\n\n#### R.swift on Xcode Cloud or any other CI\n\nOn your CI server you can't explicitly allow the build plugin to run, so you need to disable plugin validation to be able to build without user interaction:\n\n5. Run a script on your CI that runs: `defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES` before Xcode starts building.\n\nOn Xcode Cloud you can add a [custom build script](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Fxcode\u002Fwriting-custom-build-scripts) in `ci_scripts\u002Fci_post_clone.sh` with this line that Xcode will run.\n\n### Package.swift based SPM project\n\n1. Add a dependency in Package.swift:\n    ```swift\n    dependencies: [\n        .package(url: \"https:\u002F\u002Fgithub.com\u002Fmac-cain13\u002FR.swift.git\", from: \"7.0.0\")\n    ]\n    ```\n2. For each relevant target, add a dependency and a plugin\n    ```swift\n    .target(\n        name: \"Example\",\n        dependencies: [.product(name: \"RswiftLibrary\", package: \"R.swift\")],\n        plugins: [.plugin(name: \"RswiftGeneratePublicResources\", package: \"R.swift\")]\n    )\n    ```\n3. Build your project, now the `R` struct should be available in your code, use auto-complete to explore all static references\n\n\u003Cdetails>\n\u003Csummary>\u003Ch3>CocoaPods\u003C\u002Fh3>\u003C\u002Fsummary>\n\n1. Add `pod 'R.swift'` to your [Podfile](http:\u002F\u002Fcocoapods.org\u002F#get_started) and run `pod install`\n2. In Xcode: Click on your project in the file list, choose your target under `TARGETS`, click the `Build Phases` tab and add a `New Run Script Phase` by clicking the little plus icon in the top left\n3. Drag the new `Run Script` phase **above** the `Compile Sources` phase and **below** `Check Pods Manifest.lock`, expand it and paste the following script:\n   ```bash\n   \"$PODS_ROOT\u002FR.swift\u002Frswift\" generate \"$SRCROOT\u002FR.generated.swift\"\n   ```\n4. Add `$SRCROOT\u002FR.generated.swift` to the \"Output Files\" of the Build Phase\n5. Uncheck \"Based on dependency analysis\" so that R.swift is run on each build\n6. Build your project, in Finder you will now see a `R.generated.swift` in the `$SRCROOT`-folder, drag the `R.generated.swift` files into your project and **uncheck** `Copy items if needed`\n\n_Screenshot of the Build Phase can be found [here](Documentation\u002FImages\u002FBuildPhaseExample.png)_\n\n_Tip:_ Add the `*.generated.swift` pattern to your `.gitignore` file to prevent unnecessary conflicts.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Ch3>Manually\u003C\u002Fh3>\u003C\u002Fsummary>\n\n0. Add the [R.swift](https:\u002F\u002Fgithub.com\u002Fmac-cain13\u002FR.swift) library to your project\n1. [Download](https:\u002F\u002Fgithub.com\u002Fmac-cain13\u002FR.swift\u002Freleases) a R.swift release, unzip it and put it into your source root directory\n2. In Xcode: Click on your project in the file list, choose your target under `TARGETS`, click the `Build Phases` tab and add a `New Run Script Phase` by clicking the little plus icon in the top left\n3. Drag the new `Run Script` phase **above** the `Compile Sources` phase, expand it and paste the following script:  \n   ```bash\n   \"$SRCROOT\u002Frswift\" generate \"$SRCROOT\u002FR.generated.swift\"\n   ```\n4. Add `$SRCROOT\u002FR.generated.swift` to the \"Output Files\" of the Build Phase\n5. Uncheck \"Based on dependency analysis\" so that R.swift is run on each build\n6. Build your project, in Finder you will now see a `R.generated.swift` in the `$SRCROOT`-folder, drag the `R.generated.swift` files into your project and **uncheck** `Copy items if needed`\n\n_Screenshot of the Build Phase can be found [here](Documentation\u002FImages\u002FManualBuildPhaseExample.png)_\n\n_Tip:_ Add the `*.generated.swift` pattern to your `.gitignore` file to prevent unnecessary conflicts.\n\u003C\u002Fdetails>\n\n## Contribute\n\nWe'll love contributions, read the [contribute docs](Documentation\u002FContribute.md) for info on how to report issues, submit ideas and submit pull requests!\n\n## License\n\n[R.swift](https:\u002F\u002Fgithub.com\u002Fmac-cain13\u002FR.swift) is created by [Mathijs Kadijk](https:\u002F\u002Fgithub.com\u002Fmac-cain13) and [Tom Lokhorst](https:\u002F\u002Fgithub.com\u002Ftomlokhorst) released under a [MIT License](License).\n","R.swift 是一个用于 Swift 项目的代码生成工具，它能够为图片、字体和转场等资源提供强类型和自动补全功能。该项目的核心功能在于通过自动生成的 `R` 结构体，开发者可以以强类型的方式访问项目中的各种资源，包括但不限于图片、字体、颜色、本地化字符串以及故事板等。这不仅减少了手动输入资源名称时可能发生的错误，还使得编译器能够在编译阶段就对资源引用进行检查，从而提高了代码的安全性和可维护性。适用于需要频繁使用到项目内嵌资源，并希望提升开发效率与代码质量的 iOS、tvOS 和 watchOS 应用开发场景。","2026-06-11 03:08:29","top_language"]