Commit Graph
3 Commits
Author SHA1 Message Date
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
NachoSoto b87dfe5b51 Added new ReceiptParser.fetchAndParseLocalReceipt (#2204)
Fixes [CSDK-622].

### Changes:
- Extracted `FileReader` to be able to use it in `ReceiptParser`
- Extracted `MockBundle` to be able to use it in `ReceiptParser`
- Added new `public` `ReceiptParser.fetchAndParseLocalReceipt()`, **only
to `ReceiptParser`** (this is not available through `RevenueCat`).
- Added tests for the new API
- Added new API to `ReceiptParserAPITester`

Initially I thought about moving `ReceiptFetcher` to the
`Receipt|Parser` target. Unfortunately that would require moving a whole
bunch of other dependencies (`OperationDispatcher`, etc, etc).
We have no easy way to create a third "Core" framework in which to place
these common dependencies, so that wouldn't be trivial.

This solution adds a much simpler version of `ReceiptFetcher` that
simply reads from `Bundle.appStoreReceiptURL`. As it's documented there,
under normal circumstances `SKReceiptRefreshRequest` is not required, so
this implementation should work for 99% of use cases, and so this way we
avoid increasing the.codebase complexity unnecessarily.

[CSDK-622]:
https://revenuecats.atlassian.net/browse/CSDK-622?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2023-01-17 12:35:56 -08:00
NachoSoto 6d78f2bffe Created ReceiptParser SPM (#2155)
Finishes [CSDK-17].
Follow up to #2153. Extracted from #2096.

### Changes:
- Created target in `Package.swift`. It can be built separately: `swift
build --target ReceiptParser`
![Screenshot 2022-11-29 at 09 29
10](https://user-images.githubusercontent.com/685609/204600321-9c99958c-a683-4b59-8334-df1cf1235d1d.png)
- Created `ReceiptParser` target in project:
![Screenshot 2022-12-14 at 13 56
38](https://user-images.githubusercontent.com/685609/207723593-40535089-1436-4b62-81cc-d098d589f83a.png)
- Added `ReceiptParser` scheme to allow building the target from Xcode:
![Screenshot 2022-12-14 at 13 57
02](https://user-images.githubusercontent.com/685609/207723665-dace0aa1-4ae7-4382-895f-908f356043b4.png)
- Added CI `spm-receipt-parser` job
- Added CI `installation-tests-receipt-parser` job
- Added `ReceiptParserAPITester` to test API for `ReceiptParser`'s
target
- Compile `ReceiptParserAPITester` when running `RevenueCat` tests so
these are validated as well. -

[CSDK-17]:
https://revenuecats.atlassian.net/browse/CSDK-17?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2022-12-22 12:02:00 -08:00