fix(ios): make private API calls static for App Store 2.5.2

Merged
RI
1mo ago
+113-15

What

  • Restore existing Capacitor iOS private integration behavior (status bar tap swizzle, WKContentView focus swizzle, optional SSL pinning class lookup, plugin navigation/auth hooks).
  • Centralize private class and selector names in CAPAppStorePrivateAPI and use compile-time constants (static let, #selector, @selector) instead of runtime-built strings.
  • Add scripts/check-ios-dynamic-dispatch.mjs to fail CI when obfuscated runtime dispatch patterns return.

Why

  • App Store guideline 2.5.2 review flags dynamic dispatch and obfuscated private API lookups. Behavior stays the same; only how names are resolved changes.

How

  • UIStatusBarManager+CAPHandleTapAction.m: forward declare handleTapAction: and use @selector(handleTapAction:).
  • WKWebView+Capacitor.swift: NSClassFromString(CAPAppStorePrivateAPI.wkContentViewClassName) and static Selector(...) for _elementDidFocus:... (no WK + ContentView concatenation, no sel_getUid).
  • WebViewDelegationHandler.swift: responds(to:) with #selector(CAPPlugin...) constants from CAPAppStorePrivateAPI.
  • CapacitorHttp.swift: NSClassFromString with static class name constant and #selector(CAPHttpPlugin.request(_:)).
  • Each private call site tagged with // appstore-2.5.2-allow: <reason>.

Upstream sync notes

  • Re-apply CAPAppStorePrivateAPI.swift and static-name edits if upstream reverts to inline NSSelectorFromString / string concatenation in these files.
  • Keep the checker in ios verify after sync merges.

Testing

  • node scripts/check-ios-dynamic-dispatch.mjs
  • CI bun run verify in ios (xcodebuild test)

Not Tested

  • Physical device App Store static analysis (scanner behavior is external).
Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • iOS apps can now support optional SSL-pinning request handlers.
    • Web views respect the configured zoom setting and allow users to scroll to the top by tapping the status bar.
  • Bug Fixes
    • Improved application of keyboard interaction settings in iOS web views, including after page navigation, so configured keyboard behavior is applied more consistently.
    • Improved handling of web view scrolling and zoom gestures across supported configurations.