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

Support for Vision OS #353

Open
AhsanAli65 opened this issue Dec 1, 2023 · 19 comments
Open

Support for Vision OS #353

AhsanAli65 opened this issue Dec 1, 2023 · 19 comments
Labels
enhancement New feature or request

Comments

@AhsanAli65
Copy link

Support needed for Vision OS in order to build Vision pro Apps

@AhsanAli65 AhsanAli65 added enhancement New feature or request triage Issues that need to be triaged labels Dec 1, 2023
@mdmathias mdmathias removed the triage Issues that need to be triaged label Dec 1, 2023
@WillBishop
Copy link

Yeah I get the error

Receiver 'OIDAuthState' for class message is a forward declaration

@kevinmore
Copy link

Same here, need support.

@kevinmore
Copy link

kevinmore commented Jan 7, 2024

So, after almost a day's digging, I've managed to make it working in visionOS. Basically, we need to let the signin assume that visionOS is MacCatalyst.

You'll need to checkout and modify AppAuth-iOS, GTMAppAuth and GoogleSignIn-iOS individually.

Sorry guys, I can't share detailed steps, let's wait for an official release.

Screenshot 2024-01-07 at 15 18 15

@KaiTheRedNinja
Copy link

This library works for "Built for iPad" apps, which are similar to mac catalyst but for visionOS. I managed to get it working and get the same visionos-native looking interface as kevinmore. This shows that it does have the ability to work on visionos.

However, there doesn't seem to be a way to have it work on visionos-native apps. The dependencies of this library are also built specifically for iOS and macOS, and their #if TARGET_OS_(something) were seemingly built with the assumptions that there wouldn't be anything outside of iOS and macOS running their libraries. There are several statements like

#if TARGET_OS_IOS
// something here
#elseif TARGET_OS_OSX
// something else here
#endif

all throughout this library and its dependencies. Usually, one of the two cases would be true. However, when compiling for visionos native targets, neither of these conditions are true, leading to many syntax errors.

This means that this issue can't be solved unless
a) Somebody figures out how to embed built-for-ipad libraries within a VisionOS native app. Given that embedding mac catalyst components within a native mac app is unheard of, I don't think this is possible. I might be wrong though.
b) The dependencies ALL support VisionOS, which will take a long time and at least some coordinated effort.

@kevinmore
Copy link

@KaiTheRedNinja
Nope, I'm building a native visionOS app, not a compatible iPad app, with Firebase as backend. And I can confirm Google Sign In works.
I'm not targeting other platforms than visionOS, so I just replaced Mac Catalyst targets with visionOS.
For a full support of all platforms, let's wait for the official release.

@mdmathias
Copy link
Collaborator

Hi everybody. We are investigating this and will hopefully update this thread in a bit with our plan.

@SAllen0400
Copy link

Thanks for looking into this!

@exentrich
Copy link

Any update?

@mdmathias
Copy link
Collaborator

Unfortunately no. Thanks for checking. We will update here when we do have anything to share.

@Volodymyr-13
Copy link

@mdmathias I'm eagerly anticipating this as well. However, it's unfortunate that Google didn't anticipate the need for an updated version during the beta phase of visionOS. This means we'll likely encounter bugs that need addressing, making the initial release feel more like just a beta version. As a result, stability might still be an issue even with the upcoming release, at least in my estimation. It's surprising that such foresight wasn't part of the planning process. Incorporating measures to address potential issues during the beta phase could have been a proactive approach to ensuring a smoother transition to the final release. It's crucial to anticipate and mitigate challenges early on to deliver a more stable and polished product to users.

@mdmathias
Copy link
Collaborator

Hi @Volodymyr-13. We do our best to keep up with everything we can amidst our many responsibilities. I would like to mention that this repository is open source and we welcome contributions from the community. Regardless, I apologize for any difficulty you're experiencing related to the absence of visionOS support in GSI.

@herberthobregon
Copy link

My solution was to remove the Google sign-in from my App and leave only the AppleID sign-in. Google won't pay me to contribute to their library and eventually they are the ones who lose

@Volodymyr-13
Copy link

I would like to mention that this repository is open source and we welcome contributions from the community.

I find it quite disheartening and AWKWARD to hear that a company as renowned as great GOOGLE relies on volunteer support for its official product repository.
It seems totally unexpected and absolutely disappointing, considering Google's stature in the industry.
This situation raises questions about the company's approach to supporting its own products.
While I understand you're just doing your job here and I'm not directing this frustration at you personally, but I hope this feedback reaches someone higher up who can address it. However... less likely, I'm I right?

@MarcoDotIO
Copy link

I would like to mention that this repository is open source and we welcome contributions from the community.

I find it quite disheartening and AWKWARD to hear that a company as renowned as great GOOGLE relies on volunteer support for its official product repository.

It seems totally unexpected and absolutely disappointing, considering Google's stature in the industry.

This situation raises questions about the company's approach to supporting its own products.

While I understand you're just doing your job here and I'm not directing this frustration at you personally, but I hope this feedback reaches someone higher up who can address it. However... less likely, I'm I right?

I've learned this the hard way within the OSS community, even sub-sections ran by corporations like Google. That sometimes you kind of have to go ahead and start DiY-ing the solutions yourself. It's what I'll be doing myself, as I have a currently ongoing project that requires the use of retrieving JWT tokens from a Google Sign In.

I get it sucks, but that's really the life of a software developer. Nobody said this was easy. 😉

Also for the record, if Google doesn't release their implementation before I go ahead and solve it myself, I'll make a PR with the added in implementation and will link it here.

@WillBishop
Copy link

For everyone else who eagerly wants this, I found moving away from this SDK really not that hard. Took me about 1.5-2 hours to figure it all out, but with about 100 lines of code I've got Google Sign In working without the SDK (and it works with Firebase).

For me the steps were:

  1. Registered a new client on the Google console
  2. Used ASWebAuthenticationSession
  3. Create a redirect on my website to a "myapp://" URL
  4. Exchange the code for an access token and ID token,
  5. Hand that off to Firebase :)

@MarcoDotIO
Copy link

MarcoDotIO commented Mar 30, 2024

For everyone else who eagerly wants this, I found moving away from this SDK really not that hard. Took me about 1.5-2 hours to figure it all out, but with about 100 lines of code I've got Google Sign In working without the SDK (and it works with Firebase).

For me the steps were:

  1. Registered a new client on the Google console
  2. Used ASWebAuthenticationSession
  3. Create a redirect on my website to a "myapp://" URL
  4. Exchange the code for an access token and ID token,
  5. Hand that off to Firebase :)

Can you provide some sample code on your end? For my setup, my visionOS app crashes on startup with a EXC_BAD_ACCESS error:

Screenshot 2024-03-30 at 11 50 58 AM

Here's also my content view:

import SwiftUI
import AuthenticationServices

struct ContentView: View {
    @State private var authenticationSession: ASWebAuthenticationSession?
    
    var body: some View {
        Button("Sign in with Google") {
            startGoogleSignIn()
        }
    }
    
    private func startGoogleSignIn() {
        let clientId = "YOUR_CLIENT_ID.apps.googleusercontent.com"
        let redirectUri = "YOUR_BUNDLE_ID:/oauth2redirect"
        let authUrl = URL(string: "https://accounts.google.com/o/oauth2/v2/auth?client_id=\(clientId)&redirect_uri=\(redirectUri)&response_type=code&scope=email")!
        let callbackUrlScheme = "YOUR_BUNDLE_ID"
        
        authenticationSession = ASWebAuthenticationSession(url: authUrl, callbackURLScheme: callbackUrlScheme) { callbackURL, error in
            guard error == nil, let callbackURL = callbackURL else { return }
            
            let queryItems = URLComponents(string: callbackURL.absoluteString)?.queryItems
            if let code = queryItems?.first(where: { $0.name == "code" })?.value {
                // Use this authorization code to get an access token
                print("Authorization code: \(code)")
            }
        }
        
        authenticationSession?.presentationContextProvider = UIApplication.shared.windows.first?.rootViewController
        authenticationSession?.start()
    }
}

extension UIViewController: ASWebAuthenticationPresentationContextProviding {
    public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
        return self.view.window ?? ASPresentationAnchor()
    }
}

Edit: Seems like the state variable was causing the error. So after some rework, I'm getting this error:

Screenshot 2024-03-30 at 11 59 34 AM

Update 2: Just had to fix some stuff with the Build Identifier. I'll post a link to an example SwiftUI App here soon.

@jparismorgan
Copy link

Update 2: Just had to fix some stuff with the Build Identifier. I'll post a link to an example SwiftUI App here soon.

Hi @MarcoDotIO, would love the link to the example SwiftUI app if you have it, thank you!!

@je-von
Copy link

je-von commented Apr 14, 2024

Hi, I wrote an article regarding this issue. Hope it can help anyone who needs it! https://jevonlevin.medium.com/sign-in-with-google-on-your-swiftui-vision-pro-app-15d542b8dfd7

@chriscycheng
Copy link

chriscycheng commented Aug 29, 2024

I am still seeing this on 7.1.0 and having trouble upgrading to 8.0.0 on XCode. Has this been fixed? or do we need to continue using the workaround?

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

No branches or pull requests