Popovers
Popovers copied to clipboard
Code is for iOS only
I thought this was a helpful fill-in for porting my macOS SwiftUI app to iOS, however I'm unable to include this SPM package in a project which builds for both macOS and iOS because of how SPM works. Specifying iOS in your Package.swift does not limit the build to to only iOS. Please let me know if you know a better way to accomplish this. Thanks
Hmm this is slightly weird but there might not be any other way, I'll look around. Are you using a universal app template?
No, producing my own from scratch... but generally SwiftUI with macOS + iOS multi-target with SPM is definitely now the way forward, with how much SwiftUI has matured and how much Apple has lowered the bar for targeting macOS natively without Catalyst. Your lib is fantastic as a kind of polyfill for macOS popover, I'd love to see its other features ported to macOS paradigm equivalents someday
Hmm ok. You might be able to enable Popovers for specifically the iOS target then — go to your project settings, then remove Popovers under the macOS target (in Frameworks, Libraries, and Embedded Content
):
![Popovers is under Frameworks, Libraries, and Embedded Content](https://user-images.githubusercontent.com/49819455/178164344-9424c8c6-1d1f-4e7d-bbc3-d942f08fd7e0.png)
I'm using Popovers from my own SPM package, which is the only one that appears in that list (with Popovers embedded inside it). I think Apple has changed the approach for excluding packages from targets
Please accept this PR, I can update it if you agree - this is definitely the current standard approach for libraries and without this, the library is unusable in cross-platform libs or apps
@aehlke it just seems kind of weird to add if os
in every file... I'll accept it for now and look into it more.
Agree it's weird but since SPM and Xcode have no other provision for excluding source per platform, it's what every lib I've seen does (except for ones that can't be added outside iOS or macOS-exclusive projects). We must wait on Apple for a better solution. Thank you very much