Swiftpack.co -  eonist/ResourceHelper as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
eonist/ResourceHelper
Enables you to use .bundle and other resources with SPM Unit-tests
.package(url: "https://github.com/eonist/ResourceHelper.git", from: "1.0.0")

mit platform Lang SPM compatible codebeat badge Builds

Features

  • Enables you to use .bundle and other resources with SPM Unit-tests. (Perfect for Github action CI)
  • Enables you to also use the same code in Xcode unit tests

Example code:

// The temp.bundle folder can be in the root of your project (same directory as your `Package.swift`)
// iOS can only add resources inside .bundle folders
// macOS can only read files within its SandBox. Turn off Sandbox in info.plist (Using swift 5.3 and native spm assets is a better option here)
let path: String = ResourceHelper.projectRootURL(projectRef: #file, fileName: "temp.bundle/payload.json").path
Swift.print("path:  \(path)") // Users/John/Documents/AwesomeApp/temp.bundle/payload.json

Note: Swift 5.3 has support for adding assets with SPM, although a bit cumbersome. here is a tutorial 😅: https://medium.com/better-programming/how-to-add-resources-in-swift-package-manager-c437d44ec593

Installation

ResourceHelper is available using the Swift Package Manager:

Using Xcode 11, go to File -> Swift Packages -> Add Package Dependency and search for ResourceHelper or enter: https://github.com/eonist/ResourceHelper

If you are using Package.swift, you can also add ResourceHelper as a dependency easily.


let package = Package(
  name: "TestProject",
  dependencies: [
    .package(url: "https://github.com/eonist/ResourceHelper.git", .branch("master"))
  ],
  targets: [
    .target(name: "TestProject", dependencies: ["ResourceHelper"])
  ]
)

GitHub

link
Stars: 8
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

1.0.0 🎉
1 year ago

First release ✌️

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API