Skip to content

CI: run tests on iOS 11#2036

Closed
NachoSoto wants to merge 3 commits into
mainfrom
ios-11-tests
Closed

CI: run tests on iOS 11#2036
NachoSoto wants to merge 3 commits into
mainfrom
ios-11-tests

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Nov 7, 2022

Copy link
Copy Markdown
Contributor

We support iOS 11, so we should make sure tests pass there too.

@NachoSoto NachoSoto added the ci label Nov 7, 2022
@NachoSoto NachoSoto requested a review from a team November 7, 2022 23:16
@NachoSoto NachoSoto force-pushed the ios-11-tests branch 2 times, most recently from 88e7063 to 4e4e608 Compare November 7, 2022 23:33
@NachoSoto

Copy link
Copy Markdown
Contributor Author

I'm testing with Xcode 13.0.0 (which technically we don't support), and we still can't install an iOS 11 simulator :(

@NachoSoto NachoSoto closed this Nov 8, 2022
@NachoSoto NachoSoto deleted the ios-11-tests branch November 8, 2022 00:12
NachoSoto added a commit that referenced this pull request Nov 8, 2022
Fixes [TRIAGE-172]

See stacktrace:
```
Fatal Exception: NSInternalInconsistencyException
Invalid parameter not satisfying: formatOptions == 0 || !(formatOptions & ~(NSISO8601DateFormatWithYear | NSISO8601DateFormatWithMonth | NSISO8601DateFormatWithWeekOfYear | NSISO8601DateFormatWithDay | NSISO8601DateFormatWithTime | NSISO8601DateFormatWithTimeZone | NSISO8601DateFormatWithSpaceBetweenDateAndTime | NSISO8601DateFormatWithDashSeparatorInDate | NSISO8601DateFormatWithColonSeparatorInTime | NSISO8601DateFormatWithColonSeparatorInTimeZone | NSISO8601DateFormatWithFullDate | NSISO8601DateFormatWithFullTime | NSISO8601DateFormatWithInternetDateTime))
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x141d04 __exceptionPreprocess
1 libobjc.A.dylib 0x8528 objc_exception_throw
2 CoreFoundation 0x141bd8 +[NSException raise:format:]
3 Foundation 0xacc24 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 Foundation 0xe4794 -[NSISO8601DateFormatter setFormatOptions:]
5 RevenueCat 0x4795c one-time initialization function for withMilliseconds
6 libdispatch.dylib 0x1048 _dispatch_client_callout
7 libdispatch.dylib 0x4710 dispatch_once_f$VARIANT$mp
8 RevenueCat 0x47b0c date(from:) in Formatter #1 in closure #1 in variable initialization expression of static NSISO8601DateFormatter.default + 60 (DateFormatter+Extensions.swift:60)
9 RevenueCat 0x47b68 protocol witness for DateFormatterType.date(from:) in conformance Formatter #1 in closure #1 in variable initialization expression of static NSISO8601DateFormatter.default (<compiler-generated>)
10 RevenueCat 0xe6b8 AppleReceiptBuilder.build(fromContainer:) (AppleReceiptBuilder.swift)
```

This is the key part:
`formatOptions == 0 || !(formatOptions & ~(NSISO8601DateFormatWithYear |
NSISO8601DateFormatWithMonth | NSISO8601DateFormatWithWeekOfYear |
NSISO8601DateFormatWithDay | NSISO8601DateFormatWithTime |
NSISO8601DateFormatWithTimeZone |
NSISO8601DateFormatWithSpaceBetweenDateAndTime |
NSISO8601DateFormatWithDashSeparatorInDate |
NSISO8601DateFormatWithColonSeparatorInTime |
NSISO8601DateFormatWithColonSeparatorInTimeZone |
NSISO8601DateFormatWithFullDate | NSISO8601DateFormatWithFullTime |
NSISO8601DateFormatWithInternetDateTime))`

This is coming from the following code:
```swift
static let withMilliseconds: DateFormatterType = {
    let formatter = ISO8601DateFormatter()
    formatter.formatOptions = [
        .withInternetDateTime,
        .withFractionalSeconds
    ]

    return formatter
}()
```

Even though `.withFractionalSeconds` is available in iOS 11, that
assertion seems wrong, as it's treating that option as invalid. This was
a regression in #998, almost a year ago, but since we have very little
coverage on iOS 11 we never noticed until now.

Unfortunately it seems like we won't be able to run iOS 11 tests in CI
(#2036), but this change is fairly safe, it just reverts to using the
old `DateFormatter` for older versions.

[TRIAGE-172]:
https://revenuecats.atlassian.net/browse/TRIAGE-172?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant