Swiftpack.co - benspratling4/SwiftAASAValidator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by benspratling4.
benspratling4/SwiftAASAValidator 0.1.1
Validate that apple-app-site-association files are set up correctly
⭐️ 1
🕓 1 year ago
iOS macOS tvOS
.package(url: "https://github.com/benspratling4/SwiftAASAValidator.git", from: "0.1.1")

SwiftAASAValidator

Validate that apple-app-site-association files are set up correctly

The idea is you can use these functions in your test suite for doing automated tests on the validity of your apple-app-site-association file

Fetching your apple-app-site-association files

To fetch the apple-app-site-association files, create a URL which is your domain, such as

let domainUrl:URL = URL(string:"https://www.example.com")!

and retrieve the two urls for the allowed locations like so:

let appleAppSiteAssociationURLs:[URL] = try! domainUrl.urlsForAppleAppSiteAssociation()

Then use the urls to fetch the files. it shoudle exist at one of the two locations.

Deserializing an apple-app-site-association file

Once you've fetched the Data of the apple-app-site-association file, deserialize it with a JSONDecoder, like so:

let appleAppSiteAssociation:AppleAppSiteAssociation = try! JSONDecoder().decode(AppleAppSiteAssociation.self, from: data)

Testing matching URLs

Test which app ids can be linked for a given URL, using the .matchedAppIds(...) method.

let testUrl:URL = URL(string: "https://www.example.com/buy/")!
let testAppId:String = "ABCED1234.com.example.app"
XCTAssertEqual(appleAppSiteAssociation.applinks?.matchedAppIds(testUrl).contains(testAppId), true)

Each class within contains its own testing methods and its properties can be introspected.

Unsupported features

percentEncoded is not handled correctly

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Fix bug in hex digit matches
1 year ago

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