Swift Package Index


Enables you to use .bundle and other resources with SPM Unit-tests


  • The latest stable release is 1.0.0. Released 6 months ago.
  • The last commit to master was 2 months ago.

Swift Version Compatibility

  • 1.0.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 1.0.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

mit platform Lang SPM compatible Builds codebeat badge

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
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"])
  ]
)