Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift Package will not build in Xcode 13 (beta 3+) #31

Closed
ptsochantaris opened this issue Jul 16, 2021 · 3 comments
Closed

Swift Package will not build in Xcode 13 (beta 3+) #31

ptsochantaris opened this issue Jul 16, 2021 · 3 comments

Comments

@ptsochantaris
Copy link

First off, thank you for this excellent package and the amount of ease and sanity it introduces when handling callback URLs!

It seems that either Apple or the Swift project made a breaking change in the latest Xcode beta release which affects CallbackURLKit. The change is documented here: https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/11

In short, it means that when compiling a Swift Package, it no longer matters if a main app or an extension is being targeted, but instead the code itself needs to declare whether a method is available for extensions or not, on top of everything else. In CallbackURLKit, this breaks at the point where the code tries to use UIApplication.shared.open(url: ...). While I and I'm sure many others probably think of this change as a bit reckless, it may be something that the code in the package needs to deal with.

The solution, thankfully, is relatively simple. The code needs to have the annotation @available(iOSApplicationExtension, unavailable) around any method that cannot be called from an app extension. In the case of CallbackURLKit, it would just involve "babushka"ing that annotation on the method that opens URLs and the methods that use it in turn.

Please also see the discussion in the Apple Dev Forums here for reference: https://developer.apple.com/forums/thread/685103

I hope this is of some help. Thank you once again for the brilliant and super-useful package.

@phimage
Copy link
Owner

phimage commented Jul 23, 2021

thank for the report
I will fix when I can download this beta 3 (but someone could PR)

@ptsochantaris
Copy link
Author

I case it helps, I hacked around the issue temporarily by editing the sources in the checkouts folder of the package and added the @available(iOSApplicationExtension, unavailable) line above the declarations of Request, Manager and Client, as well as the two methods register and perform near the top of CallbackURLKit.swift.

That works perfectly for my own use since I'm just linking this with a main app target, but I would imagine you may want to make the annotations more fine-grained so that only specific functionality/methods are unavailable in extensions, rather than the whole package :)

@ptsochantaris
Copy link
Author

Hi, seems like Apple eventually decided to fix this issue with SPM, so the hack above is no longer needed on the latest Xcode 13 betas. I will close this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants