CaptureContext/swift-package-resources
Package with lightweight resources models for code generation
Table of contents
Products
PackageResources
Product with the primary API, declares accessors for each resource type and some helpers. Unlike generated accessors, this module can be shared across multiple packages or targets without causing any ambiguity.
Basically provides static factories for avaliable resource types.
Color.resource(_:PackageResources.Color)
UIColor.resource(_:PackageResources.Color)
NSColor.resource(_:PackageResources.Color)Image.resource(_:PackageResources.Image)
UIImage.resource(_:PackageResources.Image)
NSImage.resource(_:PackageResources.Image)Font.resource(_:PackageResources.Font)
UIFont.resource(_:PackageResources.Font)
NSFont.resource(_:PackageResources.Font)UIStoryboard.resource(_:PackageResources.Storyboard)
NSStoryboard.resource(_:PackageResources.Storyboard)[!NOTE]
Currently no custom Nib loading is available, but you can access
nameandbundleproperties ofNibResourceto load your custom nib
PackageResourcesCore
Product with resource model declarations.
- Accessors might be redundant for module with generated boilerplate. The only boilerplate that needs to be generated are factories for asset models, API can be provided statically, that is why this module doesn't declare any helpers for initializing objects like
UIImage. - Default API provided with
PackageResourcesproduct are redundant if you want to build your own API over generated boilerplate.
Available resource declarations
| Type | Alias | | --------------------- | ----------------------------- | | _ColorResource | PackageResources.Color | | _FontResource | PackageResources.Font | | _ImageResource | PackageResources.Image | | _StoryboardResource | PackageResources.Storyboard | | _SCNSceneResource | PackageResources.SCNScene |
[!NOTE]
Base types are declared with underscores to avoid ambiguity with system types, for example you may choose to use xcasset catalog out-of-the box boilerplate generation for some asset types
Installation
[!IMPORTANT]
This package is meant to be used with a codegen. You can set up custom swiftgen template or use our default codegen
Basic
You can add swift-package-resources to an Xcode project by adding it as a package dependency.
- From the File menu, select Swift Packages › Add Package Dependency…
- Enter
"https://github.com/capturecontext/swift-package-resources"into the package repository URL text field - Choose products you need to link to your project.
Recommended
If you use SwiftPM for your project structure, add swift-package-resources dependency to your package file
.package(
url: "https://github.com/capturecontext/swift-package-resources.git",
.upToNextMinor("4.0.2")
)Do not forget about target dependencies
.product(
name: "<#Product#>",
package: "swift-package-resources"
)[!NOTE]
The package is compatible with non-Apple platforms, however it uses conditional compilation, so APIs are only available on Apple platforms
License
This library is released under the MIT license. See LICENSE for details.
Package Metadata
Repository: CaptureContext/swift-package-resources
Stars: 2
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: appkit, boilerplate, cocoa, codegen, resources, scenekit, swift, swiftui, uikit
README: README.md