You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We present a portal's view that depending on OS availability creates a Live Activity. Because Live Activities are only supported on iOS 16.2+, this is done with if #available(iOS 16.2, *) checks.
In order for this to work we have two different versions of our native Portal's view wrapper. One for iOS 16 and one for iOS 16.2+. The one for iOS 16.2+ is prefixed with @available(iOS 16.2, *).
In other native code, this combo of @available and if #available() checks is sufficient to prevent code from being included that should not be based on the OS version.
However, when launching our Portal's view we encounter a crash with the following stack trace.
The crash is in CapacitorBridge:279 specifically on the call to objs_getClassList.
I did some research, and there is an issue with this exact same problem in the Swift project, with Swift contributors suggesting using this API is neither efficient, nor safe in the event of including classes based on #available checks. Please see this link: swiftlang/swift#61215
iOS (any version) where a developer might choose to include use of ios-specific APIs that are properly hidden behind @available and #available() checks
Current Behavior
In the situation that a class is only included based on Apple SDK availability, the App will crash when presenting a Portal's view.
Expected Behavior
Presenting a Portal's view should not crash the app, as code that is not specific to the user's OS should not be tried to be accessed by legacy obj-c API.
I replied to the issue you opened in ionic-team/ionic-portals#255. This is a known issue that can impact Portals applications with applications that contain non-trivial amounts of native code. You are on an old version of Portals that still allows for plugin auto-registration to occur, but it can be disabled by setting the Portal pluginRegistrationMode to .manual([]). Version 0.8.0 of Portals removed the option for auto-registration altogether and this crash will not occur because there is no codepath that will execute objc_getClassList. The latest version of Portals for iOS is 0.9.0.
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 Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
We present a portal's view that depending on OS availability creates a Live Activity. Because Live Activities are only supported on iOS 16.2+, this is done with
if #available(iOS 16.2, *)
checks.In order for this to work we have two different versions of our native Portal's view wrapper. One for iOS 16 and one for iOS 16.2+. The one for iOS 16.2+ is prefixed with
@available(iOS 16.2, *)
.In other native code, this combo of
@available
andif #available()
checks is sufficient to prevent code from being included that should not be based on the OS version.However, when launching our Portal's view we encounter a crash with the following stack trace.
The crash is in
CapacitorBridge:279
specifically on the call toobjs_getClassList
.I did some research, and there is an issue with this exact same problem in the Swift project, with Swift contributors suggesting using this API is neither efficient, nor safe in the event of including classes based on #available checks. Please see this link: swiftlang/swift#61215
Platform(s)
'IonicPortals', '~> 0.7.0'
Capacitor 4.6.2
CapacitorCordova 4.6.2
iOS (any version) where a developer might choose to include use of ios-specific APIs that are properly hidden behind
@available
and#available()
checksCurrent Behavior
In the situation that a class is only included based on Apple SDK availability, the App will crash when presenting a Portal's view.
Expected Behavior
Presenting a Portal's view should not crash the app, as code that is not specific to the user's OS should not be tried to be accessed by legacy obj-c API.
Other Technical Details
Xcode 15.0
npm --version
output:10.2.4
node --version
output:v18.18.2
pod --version
output (iOS issues only):1.14.2
Additional Context
swiftlang/swift#61215
The text was updated successfully, but these errors were encountered: