## More project structure cleanup:
- Removes redundant workspace and project files for PurchaseTester
- Cleans up bad references
- Cleans up certificates
- Re-does the process to deploy PurchaseTester, since it was designed to
run from the xcworkspace, which doesn't work anymore.
- adds a `dry-run` option to deploying PurchaseTester and adds a job for
it in the all-tests workflow. It tries building it and archiving but
doesn't actually publish to TestFlight. We didn't really have a test for
this, so it's another thing that could have broken in production.
## Motivation
Having to remember which Xcode project to open to work on every specific
feature drives me insane.
This just adds the Testing Apps to the main RevenueCat.workspace so we
can launch them from there and I can stop pulling my hair out.
It also removes the old UIKit PurchaseTester since we haven't been using
it for years.
The Backend Integration tests app and the PurchaseTesterSwiftUI app were
using a storekit config file from the old PurchaseTester for some
reason, so I cleaned that up too - added it as a separate file per app.
| Before | After |
| :-: | :-: |
| <img width="312" alt="Screenshot 2024-07-24 at 5 54 55 PM"
src="https://github.com/user-attachments/assets/3afc73b1-3432-4ec0-843c-b9ccfdd371ce">
| <img width="325" alt="image"
src="https://github.com/user-attachments/assets/f5ce7d06-4adc-40d5-a086-73febc0d84cf">
|
# Changes summary:
- Add all Testing Apps to `RevenueCat.xcworkspace`
- Kill PurchaseTester UIKit
- Move StoreKit config file from PurchaseTester UIKit to
BackendIntegrationTests
- Create new StoreKit Config file for PurchaseTester SwiftUI
- Replace SPM dependency from PurchaseTester -> RevenueCat with a local
dependency
Follow up to #3673.
### Changes:
- Split `loadshedder-integration-tests` into `integration-tests-all` and
`loadshedder-integration-tests-v3`
- Removed `loadshedder-integration-tests` from `build_test`: this
reverts #3673. We already run loadshedder tests as part of `SK1` and
`SK2` test suites.
- Add `BackendIntegrationTests-Shedder` test plane. This isn't used by
CI (see above point), but it can be useful to run all of the load
shedder tests.
### Motivation
Our snapshot testing sometimes needs regeneration and it requires
regeneration of iOS 12. iOS 12 simulators only run on Intel machines and
not all of us have them.
This PR will allow a CircleCI job to be manually triggered to regenerate
snapshot tests
### Description
#### Step 1: Trigger CircleCI workflow
Run `bundle exec fastlane generate_snapshots`
#### Step 2: Run CircleCI workflow with generate snapshots
This will start a series of jobs on CircleCI that will have the
`CIRCLECI_TESTS_GENERATE_SNAPSHOTS` set to `true` that will regenerate
new/updated snapshot test assets.
<img width="853" alt="Screenshot 2023-05-12 at 3 30 38 PM"
src="https://github.com/RevenueCat/purchases-ios/assets/401294/ae757f84-88de-4309-9181-4631e72d0ed3">
#### Step 3: Create pull requests
If there are any files changed, a new PR will be created against the
base branch (set earlier in the `generate_snapshots` lane)
Example PR 👉https://github.com/RevenueCat/purchases-ios/pull/2481
<img width="1250" alt="Screenshot 2023-05-12 at 3 31 00 PM"
src="https://github.com/RevenueCat/purchases-ios/assets/401294/6bc70151-f7c3-413e-aa85-c787c41ba60c">
---------
Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
This is a follow up to #717.
In order to be able to reproduce #2338, which seems to be an issue only
on `watchOS`, it's important that we now run tests on `watchOS` as well.
We probably won't be able to fully replicate that issue since we don't
run tests on actual devices, so they'll still run on 64 bits. But this
way we might be able to prevent issues that are only reproducible on
`watchOS` in the future.
## Changes:
- Added CircleCI job
- Added lane
- Simplified `UnitTestsHostApp` definition using `SwiftUI`
- Increased _test only_ `watchOS` deployment target to 7.0 (this was
necessary to be able to have a common `@main` for the host app)
- Increased _test only_ `tvOS` deployment target to `14.0` (same as
above, plus we only run tvOS tests on the latest version anyway. We test
backwards compatibility through iOS already)
- Fixed test compilation on `watchOS`
- Disabled `HTTPClient` tests on `watchOS` (see
https://github.com/AliSoftware/OHHTTPStubs/issues/287)
- `StoreKitConfigTestCase` is only available from `watchOS 7.0` since
that's when `SKTestSession` was introduced
- Added `watchOS` support to `UnitTests` target
- Added `watchOS` support to `ReceiptParserTests` target
- Fixed `isFamilySharable` `watchOS` version checks for version 8.0
- Created new `CI-RevenueCat` Test Plan to only run unit tests and not
StoreKit tests on `watchOS`
* Auto retry failed tests up to 3 times
* Add testplan file
* Update Fastfile
* Use different test plans for local dev vs ci
* Update config.yml
* Bump Xcode
* moved test suites to Tests folder
* fixed outdated path
* fixed more outdated paths
* moved TestsPlans to Tests folder
* update path to Constants.swift
The `Package.resolved` file is not backwards compatible. We only have test SPM dependencies, so by `.gitignore`ing it we can support both Xcode versions.
Also fixed invalid Nimble usages of `===` that were no longer valid since https://github.com/Quick/Nimble/pull/955.
* Rename all Configuration.storekit files with RevenueCat specific names
* Fix reference from backend tests
* Nope but maybe this will fix it
* Hopefully this
They don't compile when _building_ the framework, but they will when running for testing.
This adds an extra step for us locally to ensure that we don't break an API, without having to manually build those projects.
<img width="733" alt="Screen Shot 2021-12-02 at 13 14 42" src="https://user-images.githubusercontent.com/685609/144505641-35a89386-f20a-46f7-8783-303989a0a0f7.png">
Because they're part of tests now, we don't need the extra CircleCI steps. I left the `fastlane` lanes because they might still be useful to run from the command line.
Because the testers are now part of the main project too, they can easily be run by themselves as well:
<img width="211" alt="Screen Shot 2021-12-03 at 09 47 14" src="https://user-images.githubusercontent.com/685609/144648963-57205c32-f31c-4c11-92c6-45f4b20310a1.png">
* Sk2: fetch products, make purchases (#800)
* added product struct
* added Product protocol and separated wrappers for sk1 and sk2
* added price and localizedPriceString to Product
* added bridging code and first call to generic productsWithIdentifiers
* a lot of cleanup, added a couple more properties for products
* added subscription group id and cleaned up a bit
* Updated productsManager so it forwards the products calls to fetchers for sk1 and sk2
* updated a few tests and API availability checks
* updated a few methods to use productwrapper instead of skproduct
* updated tests in many places and apis
* fixed rebase issues
* fixed a few todos
* fixed a few issues caught by swiftlint
* fixed rebase issues and some visibility issues
* updated a few places to use SK2
* added horrifyingly hacky implementation for purchasing with sk2
* small cleanup, re-added method for getting SKProducts directly
* cleanup
* added caching to sk2 products fetcher
* removed trailing whitespace
* slight cleanup
* added more clarifying comments
* another cleanup
* added missing availability marks for macOS
* fixed availability marks for ProductsFetcher in ProductsManager
* yet another fix for macOS availability checks
* and more fixes for macOS version since 13.0 doesn't exist
* fixed issues in api tester
* fixed pod lib lint on non-arch64 architectures
* bundle update fastlane
* added test for dictionary += operator
* removed unnecessary method for fetching product wrappers
* cleanup file names
* updated references in StoreKitTests
* fixed targets for test file
* fixed rebase issues
* added StoreKit 2 transaction listener in the hopes of getting purchases working, unfortunately doesn't seem to work well
* fix bad refactor
* refactored, move purchasing logic to the orchestrator, added processing of results of SK 2 purchases to the orchestrator and the sk2 listener
* added arch checks in a few places to fix builds in armv7
* added another todo
* updated test for ProductsManager in StoreKit Test
* renamed `Product.swift` -> `ProductWrapper.swift`
* increased timeout for test
* added checks to ensure test compatibility with lower iOS versions
* ProductWrapper -> ProductDetails
* import Purchases -> import RevenueCat
* withProductDetailss -> withProductDetails
* productDetailss -> productDetails
* productsFromOptimalStore -> productsFromOptimalStoreKitVersion
* linting
* `Task.init {` -> `Task {`
* added comment explaining explicit cancel
* more improvements from PR comments
* `} catch let error {` -> `} catch {`
* readability improvements
* move init to the top for consistency
* extracted logging string into PurchasesString
* extracted another string
* added todo comment
* improvements from PR comments, removed redundant method
* removed unused method, more renames and improvements from PR comments
* updates xcode version for CI
* split files into StoreKit 1 and StoreKit 2 groups
* fix indentation
* fixed rebase issues
* Fix PurchaseTester project (#847)
* CheckTrialOrIntroPriceEligibility StoreKit2 support (#807)
* Sk2: fetch products, make purchases (#800)
* added product struct
* added Product protocol and separated wrappers for sk1 and sk2
* added price and localizedPriceString to Product
* added bridging code and first call to generic productsWithIdentifiers
* a lot of cleanup, added a couple more properties for products
* added subscription group id and cleaned up a bit
* Updated productsManager so it forwards the products calls to fetchers for sk1 and sk2
* updated a few tests and API availability checks
* updated a few methods to use productwrapper instead of skproduct
* updated tests in many places and apis
* fixed rebase issues
* fixed a few todos
* fixed a few issues caught by swiftlint
* fixed rebase issues and some visibility issues
* updated a few places to use SK2
* added horrifyingly hacky implementation for purchasing with sk2
* small cleanup, re-added method for getting SKProducts directly
* cleanup
* added caching to sk2 products fetcher
* removed trailing whitespace
* slight cleanup
* added more clarifying comments
* another cleanup
* added missing availability marks for macOS
* fixed availability marks for ProductsFetcher in ProductsManager
* yet another fix for macOS availability checks
* and more fixes for macOS version since 13.0 doesn't exist
* fixed issues in api tester
* fixed pod lib lint on non-arch64 architectures
* bundle update fastlane
* added test for dictionary += operator
* removed unnecessary method for fetching product wrappers
* cleanup file names
* updated references in StoreKitTests
* fixed targets for test file
* fixed rebase issues
* added StoreKit 2 transaction listener in the hopes of getting purchases working, unfortunately doesn't seem to work well
* fix bad refactor
* refactored, move purchasing logic to the orchestrator, added processing of results of SK 2 purchases to the orchestrator and the sk2 listener
* added arch checks in a few places to fix builds in armv7
* added another todo
* updated test for ProductsManager in StoreKit Test
* renamed `Product.swift` -> `ProductWrapper.swift`
* increased timeout for test
* added checks to ensure test compatibility with lower iOS versions
* ProductWrapper -> ProductDetails
* import Purchases -> import RevenueCat
* withProductDetailss -> withProductDetails
* productDetailss -> productDetails
* productsFromOptimalStore -> productsFromOptimalStoreKitVersion
* linting
* `Task.init {` -> `Task {`
* added comment explaining explicit cancel
* more improvements from PR comments
* `} catch let error {` -> `} catch {`
* readability improvements
* move init to the top for consistency
* extracted logging string into PurchasesString
* extracted another string
* added todo comment
* improvements from PR comments, removed redundant method
* removed unused method, more renames and improvements from PR comments
* updates xcode version for CI
* split files into StoreKit 1 and StoreKit 2 groups
* fix indentation
* adds check intro trial sk2 support
* fixes and renames
* removes debugging variables
* fixes and use of ProductsManager
* fix sk2Product isEligibleForIntroOffer
* remove swiftlint warning
* adds header and links to issues
* fix strings
* early return
* indentation fix
* removes maccatalyst
* fixes compilation and renames to checkEligibility
* changes on ProductsManager adding a specific sk2 function
* makes changes in TrialOrIntroPriceEligibilityChecker
* rename function to sk2ProductDetails
* some renaming
* duplicated ProductsFetcherSK1Tests.swift
* add XCTUnwrap
* revert
Co-authored-by: aboedo <andresboedo@gmail.com>
* fixed offeringsManagerTests (#856)
* Separate storekit test and backend tests (#845)
* Sk2: fetch products, make purchases (#800)
* added product struct
* added Product protocol and separated wrappers for sk1 and sk2
* added price and localizedPriceString to Product
* added bridging code and first call to generic productsWithIdentifiers
* a lot of cleanup, added a couple more properties for products
* added subscription group id and cleaned up a bit
* Updated productsManager so it forwards the products calls to fetchers for sk1 and sk2
* updated a few tests and API availability checks
* updated a few methods to use productwrapper instead of skproduct
* updated tests in many places and apis
* fixed rebase issues
* fixed a few todos
* fixed a few issues caught by swiftlint
* fixed rebase issues and some visibility issues
* updated a few places to use SK2
* added horrifyingly hacky implementation for purchasing with sk2
* small cleanup, re-added method for getting SKProducts directly
* cleanup
* added caching to sk2 products fetcher
* removed trailing whitespace
* slight cleanup
* added more clarifying comments
* another cleanup
* added missing availability marks for macOS
* fixed availability marks for ProductsFetcher in ProductsManager
* yet another fix for macOS availability checks
* and more fixes for macOS version since 13.0 doesn't exist
* fixed issues in api tester
* fixed pod lib lint on non-arch64 architectures
* bundle update fastlane
* added test for dictionary += operator
* removed unnecessary method for fetching product wrappers
* cleanup file names
* updated references in StoreKitTests
* fixed targets for test file
* fixed rebase issues
* added StoreKit 2 transaction listener in the hopes of getting purchases working, unfortunately doesn't seem to work well
* fix bad refactor
* refactored, move purchasing logic to the orchestrator, added processing of results of SK 2 purchases to the orchestrator and the sk2 listener
* added arch checks in a few places to fix builds in armv7
* added another todo
* updated test for ProductsManager in StoreKit Test
* renamed `Product.swift` -> `ProductWrapper.swift`
* increased timeout for test
* added checks to ensure test compatibility with lower iOS versions
* ProductWrapper -> ProductDetails
* import Purchases -> import RevenueCat
* withProductDetailss -> withProductDetails
* productDetailss -> productDetails
* productsFromOptimalStore -> productsFromOptimalStoreKitVersion
* linting
* `Task.init {` -> `Task {`
* added comment explaining explicit cancel
* more improvements from PR comments
* `} catch let error {` -> `} catch {`
* readability improvements
* move init to the top for consistency
* extracted logging string into PurchasesString
* extracted another string
* added todo comment
* improvements from PR comments, removed redundant method
* removed unused method, more renames and improvements from PR comments
* updates xcode version for CI
* split files into StoreKit 1 and StoreKit 2 groups
* fix indentation
* updated all references from StoreKitTests -> BackendIntegrationTests
* updated references in a few more places
* updated name of target back to StoreKitTests so the cert doesn't get updated 🙄
* fixed issues in tests
* updated arch checks for arm devices from if arm64 to if !arm, so that the code will run successfully in intel macs
* upgraded deployment target to 12.0 to fix issues when compiling StoreKit 2.
Removed arch checks.
* added separate `UnitTestsHostApp` since the `StoreKitTest` app has higher minimum deployment target than the unit tests target
* added separate scheme for unit tests to address the need of StoreKitTest
* fixed scheme name for Scanfile
* small fixes
* added skipping of test depending on OS version availability
* added pre-warming of iOS device since tests aren't starting up correctly in CI
* added pre-warming of iphone 6 and tv
* fixed devices setup since iPhone 6 is no longer available in CircleCI
* renamed StoreKitTestApp + StoreKitTests -> BackendIntegrationTests + HostApp
* more fixes to naming
* updated Nimble version, more fixes to paths
* removed host app for regular unit tests, fixed setup
* even more naming fixes, updated the scan schemes so we don't try to test appleTV for the StoreKitUnitTests
* enabled backend_integration_tests for all commits
* added missing dependency to RevenueCat framework from StoreKitUnitTests target
* fixed dependencies between targets, which would compile more targets than necessary and would have issues where the main framework would get built for the wrong platform
* update fastlane
* fixed lane name
* fixed deployment target for backend integration tests
* updated scan device OS for backend integration tests to 15.0
* fixed integration tests running wrong fastlane lane, added pre-warming devices for regular unit tests, added command line tools installation step
* removed command line tools installation step
* updated device name since iPhone SE isn't available on circleCI
* updated iPhone SE -> iPhone 8 in a couple more places
* removed pre-warming of devices, since it has been removed from Xcode 13
* removed 14.5 device from tests for now
* removed signing from backend integration tests
* fixed rebase issues
* Sk2: ProductDetails cleanup and improvements (#832)
* moved logic to wrap products into productsFetcher, added basic test to compare sk1Wrapper and sk2Wrapper
* added more checks to cover all existing properties for productWrappers
* added test to check that sk1 wrapper works correctly
* added test for SK2 product wrapper
* renamed internal method `purchase(product:` -> `purchase(sk1Product:`
* moved StoreKit2TransactionListener into corresponding group in project
* added base file for PurchaseOrchestratorTests, improved a couple of version checks for tests
* updated imports to `RevenueCat`
* re-added @available in a couple of tests
* update naming: ProductWrapper -> ProductDetails
* fix rebasing issue
* added type aliases for legacy and new skproduct, updated references to them in many places
* renamed mockSKProduct -> mockLegacySKProduct
* more cleanup
* updated naming in a few more places
* and more naming updates
* final batch of naming updates
* updated naming from new and legacy sk products to sk1 and sk2 products
* fixed naming issues with variable names that started in uppercase
* more fixes to variable names
* even more naming fixes
* final batch of naming updates, rebase fixes
* several fixes from rebase
* removed another arch check
* fixes from PR comments
* fixed missing mocks for MockProductsManager
* more "productDetailss" var renames
* removed scan_scheme env variable since we're setting it manually
* added extra test configuration for UnitTests scheme, set test ordering to random
* small ci configuration updates
* added more generous timeout for one test case
* added pre-warming of simulators
* added device pre-warming at the fastlane level
* added test plan
* added manual sleep of 5 mins to see if that fixes the testing issues
* re-added manual opening of simulators, otherwise the wait makes no sense
* made the wait for simulator bit only happen in ci
* improvement from PR comments
* fixed one reason for app crash in iOS < 15, since SceneDelegate was missing
* added check for subscriptionGroupIdentifier
* updated to use XCTSkip instead of early return in a couple of tests
* Tests for CheckTrialOrIntroductoryPriceEligibility StoreKit2 using StoreKitTests (#863)
* Storekit 2: fix tests for iOS 14.5 (#890)
* updated storage of underlyingSK2Product to use Any to prevent crashes in 14.5 devices
* added comment and small cleanup
* re-added iOS 14.5 devices to fastlane scan
* fixed rebase issues
* merge storekit_2_disable_mac_builds
* Sk2 purchase tests (#873)
* added tests skeleton, cleaned up handling of purchase sk2 package
* code clean up, added mocks to sk unit tests target, clean up tests code
* added mockStoreKit2Listener, fixed purchasesOrchestator test
* implemented missing test cases
* casted SK2Product to any for storing to prevent linking issues
* fixed more issues with linking + moved PurchasesOrchestratorTests to storekit tests
* linting
* fixed duplicate files in build phase
* fixed more issues with linking on older OS
* fixed rebase issues
* fix one test in SwiftAPITester
* updated xcode version for swift api tester
* updated api testers to use an existing bundle id to prevent code signing issues
* remove development team + undo bundle id updates
* added fastlane match readonly step
* re-add dev team
* re-add dev team to release builds for objc api tester ios
* updated certs to use fastlane match
* specified missing params for match
* fixed copy/paste issue
* `MockStoreKit2Listener` -> `MockStoreKit2TransactionListener`
* added clearing of user defaults before every test run
* added crude handling of the user cancelled case for SK2 purchases.
* fixed indentation
* updated test name to reflect what it's actually testing
* reset the value of `failTransactionsEnabled` before every test
* moved to using `resetToDefaultState`
* Removes `RequiresXcode13` (#895)
* improve pre-warming and fix flaky tests (#897)
* replaced manual pre-warming with orb
* removed appleTV from prewarming list
* removed duplicate source file
* added test timeouts
* added artificial wait before running storekit tests
* made the artificial wait run only once
* removed unnecessary param
* moved the `Self.hasWaited = true` line above, removed unnecessary parenthesis
* doubled the wait time just in case, made it a static let.
* doubled initial wait time again
* removed another instance of `wait_for_simulator:true`
* Temporarily disable sk2 purchases (#898)
* added a feature flag to disable SK2 temporarily
* fixed tests
* Show Manage Subscriptions public API (#896)
* fix rebase issue
* fixed rebase issues
* Re-enable macOS builds (#923)
* updated xcode version to 13.1.0
* re-enabled macOS builds, re-added API tester for macOS
* Merge main into storekit_2 (#930)
* Begin Refund Request (#924)
* Fix/explicit errors on tasks (#940)
* replaced `Task.init` with `_ = Task<Void, Never>`, so that if the contents of the task throw, the compiler forces us to handle the exception
* added link with explanation to the swift style guide
* Fix: storekit 2 tests on older OS versions (#951)
* removed duplicate line for devices
* fixed tests for older os versions by not storing SK2 types directly in the tests target.
* fixed copy/pasta
* merged main into sk2 (#952)
* improvements from PR comments
* more improvements from PR comments
* even more improvements from PR comments
* more improvements from PR comments
* updated to use the new lock
* removed outdated comment
* added missing cases to switch
* refactor to pass in the systemInfo to productsManager, and to reuse existing instances for intro eligiblity
* made useStoreKit2IfAvailable an instance variable instead of static
* added test cases for fetching from optimal sk with different sk version preferences
* fixed instance of the wrong method being called from overriden `setUpWithError`
* oops, fixed missing `try`
* added more detail to fatalError message when sk version can't be determined
* split tests for `TrialOrIntroPriceEligibilityChecker` into SK1 and SK2
* fix merge conflicts
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
Co-authored-by: beylmk <maddie@revenuecat.com>
* Add deprecations back
* Rename completionBlock -> completion for swift
* Make parameter labels that were optional pre-migration optional again
* Remove 3rd addAttributionData method
* Update test target compile issues
* Pull API Testers into their own projects (#850)
* Update Objc tester -- change dependency to external, use switches for enums, add error code testing
* Add swift API tester
* Add comments for deprecation warnings
* Add objc nillable calls and comments for deprecation warnings
* Add closure versions to swift calls
* Add SwiftAPITester build step to CircleCI
* Update dependency to main
* Update breaking changes
* Update SwiftAPITester to local dependency
* Update to point to migration-fixes branch and make necessary updates
* Update dependency and make fixes
* Add objc tester project with dependency
* Remove api testers from base project, remove purchases dependency
* Move files into project folders
* remove bridging header
* updated package dep
* Change xcode verison for swift apitester
* Use workspace + scheme to build API testers in CircleCI
* Remove APITester scheme from RevenueCat project
Co-authored-by: Joshua Liebowitz <taquitos@users.noreply.github.com>
* Rename all PublicSDKAPITester files to APITesters/ObjCAPITester/ObjCAPITester
* Remove "maybe" from public api
* Remove "block" from "completionBlock" in our API
* Update ObjCAPITester for completionBlock API changes
* Remove some type aliases that aren't particularly helpful
* Update APITester for removed type aliases
* Added tests for ErrorCode enum
* Update ErrorCodeTests.swift
* Clear out RevenueCat.h
* Update PurchasesAPI for block api update