joemasilotti / joemasilotti/bridge-components
ShareComponent crashes on iPad: missing popoverPresentationController config?
- Dominant language
- Kotlin
- Stars
- 478
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
`ShareComponent` crashes on iPad when tapping the share button. Per [UIKit / UIActivityViewController](https://developer.apple.com/documentation/uikit/uiactivityviewcontroller):
> On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.
The crash message indicates the Popover requires a `barButtonItem` or `sourceView`, but neither is set.
Works fine on iPhone (no popover).
## Steps to reproduce
1. Add `` to any page
2. Open the app on iPad (I used TestFlight and Simulator)
3. Tap the share button in the nav bar
4. Crashes with:
```
Thread 1: "UIPopoverPresentationController () should have a non-nil sourceView or barButtonItem set before the presentation occurs."
```
## Claude suggested fix
I haven't gotten into a fix yet, but Claude thinks this would do it:
[`ShareComponent.swift` L33-L39](https://github.com/joemasilotti/bridge-components/blob/v0.12.2/ios/components/ShareComponent.swift#L33-L39) — set `barButtonItem` on the popover before presenting:
```diff
private func share(_ url: URL) {
let activityViewController = UIActivityViewController(
activityItems: [url],
applicationActivities: nil
)
+ activityViewController.popoverPresentationController?.barButtonItem =
+ viewController?.navigationItem.rightBarButtonItem
viewController?.present(activityViewController, animated: true)
}
```
## Environment
- bridge-components v0.12.2
- Hotwire Native iOS 1.2.2
- iPadOS: 26.4
- Device: iPad Pro (11-inch) (3rd generation)
- Distribution: TestFlight
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with ios/components/ShareComponent.swift at lines 33-39 and inspect how the UIActivityViewController is presented. Reproduce the share action on an iPad using the stated page setup and verify the popover has the required presentation anchor. Done means sharing no longer crashes on iPad while the existing iPhone behavior still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100