Skip to content

Swiftly toolchains not gating Apple Platform Frameworks correctly #425

@0xTim

Description

@0xTim

My understanding is that when using the open source toolchains installed by Swiftly, it should not see frameworks specific to Apple Platforms, e.g. AuthenticationServices However this isn't matching up with what I'm seeing.

Code that compiles fine with Xcode and on Linux fails compilation from the command line on macOS via Swiftly.

Steps to Reproduce:

  1. Checkout https://github.com/ChimeHQ/OAuthenticator - reproducible on 618971d4d341650db664925fd0479032294064ad
  2. Install Swiftly and a toolchain, e.g. swiftly install 6.2.0 && swiftly use 6.2.0
  3. Try and build - swift build

Expected results:

It should compile correctly

Actual Results:

➜  OAuthenticator git:(main) ✗ swift build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/timc/Developer/OAuthenticator/Sources/OAuthenticator/WebAuthenticationSession+Utility.swift:7:11: error: cannot find type 'WebAuthenticationSession' in scope
 5 | 
 6 | @available(macOS 13.3, iOS 16.4, watchOS 9.4, macCatalyst 16.4, tvOS 16.4, *)
 7 | extension WebAuthenticationSession {
   |           `- error: cannot find type 'WebAuthenticationSession' in scope
 8 | 	public func userAuthenticator(preferredBrowserSession: BrowserSession? = nil) -> Authenticator.UserAuthenticator {
 9 | 		return {
/Users/timc/Developer/OAuthenticator/Sources/OAuthenticator/WebAuthenticationSession+Utility.swift:7:11: error: cannot find type 'WebAuthenticationSession' in scope
 5 | 
 6 | @available(macOS 13.3, iOS 16.4, watchOS 9.4, macCatalyst 16.4, tvOS 16.4, *)
 7 | extension WebAuthenticationSession {
   |           `- error: cannot find type 'WebAuthenticationSession' in scope
 8 | 	public func userAuthenticator(preferredBrowserSession: BrowserSession? = nil) -> Authenticator.UserAuthenticator {
 9 | 		return {

/Users/timc/Developer/OAuthenticator/Sources/OAuthenticator/WebAuthenticationSession+Utility.swift:8:57: error: cannot find type 'BrowserSession' in scope
 6 | @available(macOS 13.3, iOS 16.4, watchOS 9.4, macCatalyst 16.4, tvOS 16.4, *)
 7 | extension WebAuthenticationSession {
 8 | 	public func userAuthenticator(preferredBrowserSession: BrowserSession? = nil) -> Authenticator.UserAuthenticator {
   |                                                         `- error: cannot find type 'BrowserSession' in scope
 9 | 		return {
10 | 			try await self.authenticate(using: $0, callbackURLScheme: $1, preferredBrowserSession: preferredBrowserSession)
[3/3] Compiling OAuthenticator WebAuthenticationSession+Utility.swift

Note - the file uses an if canImport() gate which should not compile the file when it can't see the symbols. That gate passes but then compilation fails

It should either be able to see the frameworks and compile fine and see those symbols or not see the framework and ignore the file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions