Skip to content

fix(app): silence the String?-to-Any coercion warning in getAppLanguage on iOS - #2598

Open
devmax128 wants to merge 1 commit into
ionic-team:mainfrom
devmax128:fix/app-language-optional-coercion
Open

devmax128 wants to merge 1 commit into
ionic-team:mainfrom
devmax128:fix/app-language-optional-coercion

Conversation

@devmax128

Copy link
Copy Markdown

What

Building an app that uses @capacitor/app on Xcode 27 (Swift 6.3) shows one warning from this plugin:

app/ios/Sources/AppPlugin/AppPlugin.swift:121:22: warning: expression implicitly coerced from 'String?' to 'Any'

getAppLanguage puts Bundle.main.preferredLocalizations.first (a String?) straight into the [String: Any] passed to call.resolve. This PR makes the coercion explicit with as Any, which keeps the exact same behaviour — a missing localization still resolves as null — and clears the warning.

Verification

Built an app consuming the plugin with Xcode 27: the warning is gone, no new ones. No API or behaviour change.

Found while building PanicButton SOS.

…ge on iOS

Xcode 27 (Swift 6.3) warns "expression implicitly coerced from 'String?' to
'Any'" for the value handed to call.resolve. Making the coercion explicit
with `as Any` keeps the exact same behaviour (a missing localization still
resolves as null) and clears the warning.
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