Skip to content
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

Device plugin: iOSVersion is inconsistent for 16.0 vs. 16.0.1 vs. 16.0.10 #1510

Closed
e6c31d opened this issue Mar 30, 2023 · 1 comment · Fixed by #1514
Closed

Device plugin: iOSVersion is inconsistent for 16.0 vs. 16.0.1 vs. 16.0.10 #1510

e6c31d opened this issue Mar 30, 2023 · 1 comment · Fixed by #1514
Labels

Comments

@e6c31d
Copy link

e6c31d commented Mar 30, 2023

Bug Report

Plugin(s)

Device plugin

Capacitor Version

This code was just committed recently and not released yet, but I thought I'd report the issue now so there would be no breaking change after release.

public func getSystemVersionInt() -> Int? {
let majorVersion = UIDevice.current.systemVersion.split(separator: ".")
let majorVersionBig = majorVersion.joined()
let majorVersionBigInt = Int(majorVersionBig)
return majorVersionBigInt
}

On iOS 16.0: 160
On iOS 16.0.1: 1601
On iOS 16.0.10 (hypothetical): 16010

Platform(s)

iOS

Current Behavior

The problem is that iOSVersion simply removes the dots and joins the integers together. This breaks comparison and sorting. For example, 16.0.1 would sort higher than 16.1 because 1601 > 161. It also ignores the fact that minor and patch versions may have more than one digit (It happened before, see: iOS 4.2.10).

Expected Behavior

I suggest two changes:
1- Set minor and patch versions to 0 if they don't exist in systemVersion.
2- Pad minor and patch versions to two digits.

On iOS 16.0: 160000
On iOS 16.0.1: 160001
On iOS 16.0.10 (hypothetical): 160010

Code Reproduction

Other Technical Details

Additional Context

@ionitron-bot
Copy link

ionitron-bot bot commented Apr 30, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Apr 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants