Updating from Capacitor 8 to Capacitor 9
In this guide, you'll find steps to update your project to the current Capacitor 9 version as well as a list of breaking changes.
iOS
The following guide describes how to upgrade your Capacitor 8 iOS project to Capacitor 9.
Raise iOS Deployment Target
Capacitor 9 requires iOS 16.0 or greater.
Do the following for your Xcode project: select the Project within the project editor and open the Build Settings tab. Under the Deployment section, change iOS Deployment Target to iOS 16.0. Repeat the same steps for any app Targets.
Then, if the project is using CocoaPods, open ios/App/Podfile and update the iOS version to 16.0:
platform :ios, '16.0'
Breaking changes in @capacitor/ios
Capacitor 9 removes the Swift and Objective-C APIs that were deprecated in previous major versions. If your app or plugin still uses any of them, replace them as follows.
CAPBridge compatibility class removed
The CAPBridge class was a compatibility shim and has been removed entirely. Use the replacements below:
| Removed | Replacement |
|---|---|
CAPBridge.statusBarTappedNotification | Notification.Name.capacitorStatusBarTapped |
CAPBridge.getLastUrl() | ApplicationDelegateProxy.shared.lastURL |
CAPBridge.handleOpenUrl(_:_:) | ApplicationDelegateProxy.shared.application(_:open:options:) |
CAPBridge.handleContinueActivity(_:_:) | ApplicationDelegateProxy.shared.application(_:continue:restorationHandler:) |
CAPBridge.handleAppBecameActive(_:) | No longer needed, it was a no-op |
Bridge (CAPBridgeProtocol) methods removed
| Removed | Replacement |
|---|---|
getWebView() | webView property |
isSimulator() | isSimEnvironment property |
isDevMode() | isDevEnvironment property |
getStatusBarVisible() / setStatusBarVisible(_:) | statusBarVisible property |
getStatusBarStyle() / setStatusBarStyle(_:) | statusBarStyle property |
setStatusBarAnimation(_:) | statusBarAnimation property |
getUserInterfaceStyle() | userInterfaceStyle property |
getLocalUrl() | config.localURL |
getSavedCall(_:) | savedCall(withID:) |
releaseCall(callbackId:) | releaseCall(withID:) |
presentVC(_:animated:completion:) | viewController?.present(_:animated:completion:) |
dismissVC(animated:completion:) | viewController?.dismiss(animated:completion:) |
modulePrint(_:_:) | CAPLog.print(_:) |
Other removals
| Removed | Replacement |
|---|---|
CAPNotifications enum | Notification.Name.capacitor* constants (e.g. Notification.Name.capacitorOpenURL) |
PluginCallErrorData, PluginResultData and JSResultBody typealiases | PluginCallResultData |
CAPPluginCall.hasOption(_:) | Typed accessors (getString(_:), getInt(_:), etc.) |
JSDate.toString(_:) | No longer needed, dates are mapped to strings during serialization |
InstanceConfiguration.getPluginConfigValue(_:_:) | getPluginConfig(_:) |
InstanceConfiguration.getValue(_:) / getString(_:) | Direct property accessors on InstanceConfiguration |
CAPPlugin.getConfigValue(_:) | getConfig() and the typed accessors on PluginConfig |
CAPFileManager.getPortablePath(host:uri:) | portablePath(fromLocalURL:) on the bridge |
CapacitorBridge initializer taking cordovaConfiguration | The initializer without the cordovaConfiguration parameter |
CapacitorBridge.httpsInterceptorStartIdentifier | httpInterceptorStartIdentifier, all proxied requests are handled by it |
CapacitorUrlRequest.setRequestHeaders([String: String]) | setRequestHeaders([String: Any]). Note: the replacement sets header values instead of appending them, so repeated keys overwrite the previous value |