-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watchOS
: fixed crash on single-target apps
#1849
Conversation
Fixes [CSDK-416]. Starting on `watchOS 9.0` (Xcode 14.0), `watchOS` apps can be configured as a single target. Apps that run in this single-target crash when calling `WKExtension.shared`. To prevent this, we can use `WKApplication` if it's available.
Looks like tests failed. Looks good otherwise. |
Yeah it compiled locally with Xcode 14 and 13, I'll need to look into it. |
Fixed. Turns out |
#else | ||
// Before Xcode 14, single-target extensions aren't supported (and WKApplication isn't available) | ||
return WKExtension.shared().applicationState == .background | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this becomes slightly more complex, having to check for 2 things... But well, I don't have a better way to do it and it's not too bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but moving forward we'll only have one. Once Xcode 14 is mandatory, and when we drop anything before watchOS 7.0
, there's really only one implementation :)
* rc-4.11.0: (964 commits) Update RevenueCat-Swift.h for version 4.11.0 Version bump for 4.11.0 skip if needed and adds automatic_release (RevenueCat#1870) Fixed crash on `async` SK1 cancelled purchase (RevenueCat#1869) Added `beginRefundRequest` overload with completion block (RevenueCat#1861) Release/4.10.3 (RevenueCat#1867) Update fastlane-plugin-revenuecat_internal and fix release-train job (RevenueCat#1866) fix typo in comment (RevenueCat#1863) Use Dangerfile repository (RevenueCat#1864) `CircleCI`: added job for building SDK with `SPM` (RevenueCat#1860) `TrialOrIntroPriceEligibilityChecker`: return `.noIntroOfferExists` if the product has no introductory offer (RevenueCat#1859) `Lock`: changed default implementation to use `NSLock` (RevenueCat#1819) `Offering: Sendable` conformance (RevenueCat#1826) `ReceiptParser: Sendable` conformance (RevenueCat#1825) `CustomerInfo: Sendable` conformance (RevenueCat#1824) Added `Collection.onlyElement` (RevenueCat#1857) README updates (RevenueCat#1856) `IntegrationTests`: actually fail test if tests aren't configured (RevenueCat#1855) `watchOS`: fixed crash on single-target apps (RevenueCat#1849) Prepare next version: 4.11.0-SNAPSHOT (RevenueCat#1854) ... # Conflicts: # .circleci/config.yml # .jazzy.yaml # .version # CHANGELOG.latest.md # CHANGELOG.md # Gemfile.lock # Package.swift # Purchases/Attribution/RCAttributionFetcher.h # Purchases/Attribution/RCAttributionFetcher.m # Purchases/Attribution/RCAttributionPoster.m # Purchases/Attribution/RCAttributionTypeFactory.h # Purchases/Attribution/RCAttributionTypeFactory.m # Purchases/Caching/RCDeviceCache.m # Purchases/Misc/RCSystemInfo.m # Purchases/Networking/RCBackend.h # Purchases/Networking/RCBackend.m # Purchases/ProtectedExtensions/RCAttributionTypeFactory+Protected.h # Purchases/Public/RCPurchases.h # Purchases/Public/RCPurchases.m # Purchases/Public/RCPurchasesErrorUtils.h # Purchases/Public/RCPurchasesErrorUtils.m # Purchases/Purchasing/RCOfferingsFactory.m # Purchases/Purchasing/RCStoreKitRequestFetcher.h # Purchases/Purchasing/RCStoreKitRequestFetcher.m # Purchases/SubscriberAttributes/RCSubscriberAttributesManager.h # Purchases/SubscriberAttributes/RCSubscriberAttributesManager.m # PurchasesCoreSwift.podspec # PurchasesCoreSwift/Info.plist # PurchasesCoreSwift/Logging/Strings/AttributionStrings.swift # PurchasesCoreSwift/Logging/Strings/IdentityStrings.swift # PurchasesCoreSwift/Logging/Strings/OfferingStrings.swift # PurchasesCoreSwift/Misc/OperationDispatcher.swift # PurchasesCoreSwift/SubscriberAttributes/SpecialSubscriberAttributes.swift # PurchasesTests/Info.plist # PurchasesTests/Mocks/MockAttributionFetcher.swift # PurchasesTests/Mocks/MockAttributionTypeFactory.swift # PurchasesTests/Mocks/MockBackend.swift # PurchasesTests/Mocks/MockOfferingsFactory.swift # PurchasesTests/Mocks/MockRequestFetcher.swift # PurchasesTests/Networking/BackendTests.swift # PurchasesTests/Purchasing/OfferingsTests.swift # PurchasesTests/Purchasing/PurchasesTests.swift # PurchasesTests/SubscriberAttributes/PurchasesSubscriberAttributesTests.swift # RevenueCat.podspec # Sources/Info.plist # Tests/BackendIntegrationTestApp/Info.plist # Tests/BackendIntegrationTests/Info.plist # Tests/InstallationTests/CocoapodsInstallation/Gemfile.lock # Tests/InstallationTests/XcodeDirectInstallation/XcodeDirectInstallation.xcodeproj/project.pbxproj # Tests/UnitTests/Attribution/AttributionTypeFactoryTests.swift # Tests/UnitTests/Info.plist # Tests/UnitTests/Mocks/MockProductsRequest.swift # Tests/UnitTests/Mocks/MockSubscriberAttributesManager.swift # Tests/UnitTests/Purchasing/StoreKitRequestFetcherTests.swift # fastlane/Fastfile
…nd before watchOS 9.0 Follow up to #1849. That fix was incomplete, and still crashed when ran before watchOS 9.0. Fixes [SDKONCALL-119] and [CSDK-416] and #1891. There are 3 variables we need to take into account: - `watchOS` version - Xcode version - Dual/single target app | watchOS | Xcode | Dual / Single target | Before PR | With this PR | |---------------|-----------|----------------------|--------------------|-------------------| | < 9.0 | < 14.x | Single | `WKExtension` | `WKExtension` | | < 9.0 | < 14.x | Dual | N/A | N/A | | < 9.0 | >= 14.0 | Single | crash⚠️ | always `false` | | < 9.0 | >= 14.0 | Dual | `WKApplication` | `WKExtension` | | >= 9.0 | >= 14.0 | Single | `WKApplication` | `WKApplication` | | >= 9.0 | >= 14.0 | Dual | `WKApplication` | `WKApplication` |
…nd before watchOS 9.0 (#1895) Follow up to #1849. That fix was incomplete, and still crashed when ran before watchOS 9.0. Fixes [SDKONCALL-119] and [CSDK-416] and #1891. There are 3 variables we need to take into account: - `watchOS` version - Xcode version - Dual/single target app | watchOS | Xcode | Dual / Single target | Before PR | With this PR | |---------------|-----------|----------------------|--------------------|-------------------| | < 9.0 | < 14.x | Single | `WKExtension` | `WKExtension` | | < 9.0 | < 14.x | Dual | N/A | N/A | | < 9.0 | >= 14.0 | Single | crash⚠️ | always `false` | | < 9.0 | >= 14.0 | Dual | `WKApplication` | `WKExtension` | | >= 9.0 | >= 14.0 | Single | `WKApplication` | `WKApplication` | | >= 9.0 | >= 14.0 | Dual | `WKApplication` | `WKApplication` |
Fixes CSDK-416.
Starting on
watchOS 9.0
(Xcode 14.0),watchOS
apps can be configured as a single target.Apps that run in this single-target crash when calling
WKExtension.shared
:To prevent this, we can use
WKApplication
if it's available.