Closed dungi closed 2 years ago
I get the same compiler errors when integrating the OAUth2 library version 5.2.0 with Swift Package Manager and Xcode 13 beta 3 (13A5192i) on macOS Big Sur 11.4 (20F71).
These errors appear due to the changes in the linker mentioned in the Xcode release notes
Resolved in Xcode 13 Beta 3
- Linking Swift packages from application extension targets or watchOS applications no longer emits unresolvable warnings about linking to libraries not safe for use in application extensions. This means that code referencing APIs annotated as unavailable for use in app extensions must now themselves be annotated as unavailable for use in application extensions, in order to allow that code to be used in both apps and app extensions. (66928265)
All libraries that use API marked as unavailable in iOS app extensions, such as UIApplication.shared
, have to mark their code themself with @available(iOSApplicationExtension, unavailable)
in Swift and NS_EXTENSION_UNAVAILABLE
in Objective-C.
Thanks for the clarification.
I'm also encountering this error when building with Xcode 13 beta 3. I've tried to fork and add the @available(iOSApplicationExtension, unavailable)
attribute to the method, but I can't figure out how to build the project without errors.
Is there anything I can do in my code to work around this error, or the change has to be made in the OAUth2 library?
@marcosatanaka can you open a pull request with your changes? Maybe this would help, and maybe this is the change needed for a new build.
@dungi I didn't do much, just added the @available(iOSApplicationExtension, unavailable)
attribute to the method that triggered the error. I committed this to my fork, but it's probably better not to open a pull request yet, because I couldn't get the project to build.
Not sure if I'm missing something (as this is the first time I try to edit a SPM library), but this is the error message I get when trying to build the project:
error: Build input file cannot be found: '/Users/marcosatanaka/Desktop/OAuth2/SwiftKeychain/Keychain/Keychain.swift' (in target 'OAuth2iOS' from project 'OAuth2')
Looks like you missed something. Did you run the Gemfile?
I guess only the flag should help. I saw that someone needed to do the same for Firebase.
I saw this comment on the Package.swift
file, so I had an idea to manually add the SwiftKeychain
project files in the corresponding folder:
// SwiftKeychain is not yet available as a Package, so we symlink to /Sources and make it a Target
//.package(url: "https://github.com/yankodimitrov/SwiftKeychain.git", majorVersion: 1),
After doing this the error disappeared, but I came across a new error, inside SwiftKeychain
:
Initializer 'init()' is internal and cannot be referenced from a default argument value
Which I solved by making the Keychain
struct constructor public. Now OAuth2
builds successfully.
So I'm opening pull request #374.
@marcosatanaka did you clone with submodules? I had the same problem until I did that.
@GyroJoe Thanks a lot for the tip! After cloning with submodules, the project builds successfully, without having to manually add the SwiftKeychain
project files.
Did someone already looked at the PR? When can we expect to have it in stable?
Not sure what the future plan is in SwiftPM, but this was reverted for now in beta 5 🎉:
Swift Packages Resolved in Xcode 13 Beta 5
- You don’t need to annotate code as unavailable for use in application extensions if it references APIs annotated as unavailable for use in application extensions. This reverts a requirement that Xcode 13 Beta 3 introduced. (80615922) (FB9332020)
Thread with some more details: https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/27
Thanks for the info :)
I get current error, when building with iOS 15 SDK. That should be fixed before release of iOS 15 or Xcode 13. We are currently switching to Xcode 13 beta, cause our app will be released next year, and we want to use the new Swift features.