Skip to content

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

Merged
OS-ruimoreiramendes merged 2 commits into
ionic-team:mainfrom
devmax128:fix/app-language-optional-coercion
Sep 29, 2026
Merged

OS-ruimoreiramendes merged 2 commits into
ionic-team:mainfrom
devmax128:fix/app-language-optional-coercion

Conversation

@devmax128

Copy link
Copy Markdown
Contributor

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.
@shivapoudel

shivapoudel commented Sep 28, 2026 •

Copy link
Copy Markdown

Verified this change as a patch on @capacitor/app 8.1.1 (with @capacitor/ios 8.5.2, SPM), building an app for the iOS Simulator with Xcode 27.0 (Swift 6.4):

  • Without it: AppPlugin.swift:121:22: warning: expression implicitly coerced from 'String?' to 'Any'
  • With it: no warning from AppPlugin.swift, build succeeds.

Behaviour is unchanged: as Any is exactly the coercion the compiler was already doing implicitly.

@OS-ruimoreiramendes OS-ruimoreiramendes self-assigned this Sep 29, 2026
@OS-ruimoreiramendes
OS-ruimoreiramendes merged commit 0706269 into ionic-team:main Sep 29, 2026
8 of 9 checks passed
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
renovate Bot added a commit to cigaleapp/cigale that referenced this pull request Oct 12, 2026
##### [v8.1.2](https://github.com/ionic-team/capacitor-plugins/releases/tag/%40capacitor/app%408.1.2)

##### Bug Fixes

- **app:** silence the String?-to-Any coercion warning in getAppLanguage on iOS ([#2598](ionic-team/capacitor-plugins#2598)) ([0706269](ionic-team/capacitor-plugins@0706269))
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.

3 participants