Skip to content

natmark/XCAssetsKit

Repository files navigation

Header

Build Status Pods Version Swift

XCAssetsKit

.xcassets parser written in Swift 🐧

Usage

    let xcassets: XCAssets = try! XCAssets(fileURL: URL(fileURLWithPath: "path/to/file.xcassets"))

    let contents: XCAssetsContents = xcassets.contents // Decode Contents.json
    let assets: [Assets] = xcassets.assets // Decode Assets
    
    if case .imageSet(let imageSet) == assets[0] {
        print(imageSet.fileName) // image_png
        print(imageSet.contents.images.count) // 3

        print(imageSet.contents.images[0].filename) // Optional("Artboard.png")
        print(imageSet.contents.images[0].scale) // Optional("1x")

        print(imageSet.contents.images[1].filename) // Optional("Artboard@2x.png")
        print(imageSet.contents.images[1].scale) // Optional("2x")

        print(imageSet.contents.images[2].filename) // Optional("Artboard@3x.png")
        print(imageSet.contents.images[2].scale) // Optional("3x")
    }

Supported Assets

  • folder
  • imageset
  • colorset
  • dataset
  • textureset
  • mipmapset
  • cubetextureset
  • appiconset
  • appiconset
  • launchimage
  • brandassets
  • appiconset
  • iconset
  • stickericonset
  • arresorucegroup
  • arreferenceimage
  • arobject
  • complicationset
  • imagestack
  • imagestacklayer
  • spriteatlas
  • gcdashboardimage
  • gcleaderboard
  • gcleaderboardSet
  • stickerpack
  • sticker
  • stickersequence

License

XCAssetsKit is available under the MIT license. See the LICENSE file for more info.