Files
purchases-ios/Sources/LocalReceiptParsing/ReceiptParser-only-files/PurchasesReceiptParser+Extensions.swift
T
Mark VillacampaandNachoSoto 84806ad86e Improve sandbox detector for macOS apps (#3549)
Checking for the presence of `Xcode/DerivedData` in the receipt path was
failing for TestFlight builds or if the .app bundle generated by Xcode
was moved from the folder.

Additionally, checking for `MASReceipt/receipt` seems less robust than
simply using compiler directives.

Instead, for macOS apps, we check the environment embedded in the receipt and alternatively check the signature of the app bundle.

---------

Co-authored-by: NachoSoto <NachoSoto@users.noreply.github.com>
2024-01-09 19:12:47 +01:00

29 lines
907 B
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// PurchasesReceiptParser+Extensions.swift
//
// Created by Nacho Soto on 12/14/22.
import Foundation
public extension PurchasesReceiptParser {
/// A default ``PurchasesReceiptParser`` configured for use.
static let `default`: PurchasesReceiptParser = .init(logger: ReceiptParserLogger())
/// Fetches and parses the local receipt
/// - Returns: ``AppleReceipt`` of the parsed local receipt.
/// - Throws: ``PurchasesReceiptParser/Error`` if fetching or parsing failed.
func fetchAndParseLocalReceipt() throws -> AppleReceipt {
return try LocalReceiptFetcher().fetchAndParseLocalReceipt()
}
}