Open AhsanAli65 opened 9 months ago
Yeah I get the error
Receiver 'OIDAuthState' for class message is a forward declaration
Same here, need support.
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.
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.
@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.
Hi everybody. We are investigating this and will hopefully update this thread in a bit with our plan.
Thanks for looking into this!
Any update?
Unfortunately no. Thanks for checking. We will update here when we do have anything to share.
@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.
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.
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
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 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.
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:
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:
- Registered a new client on the Google console
- Used ASWebAuthenticationSession
- Create a redirect on my website to a "myapp://" URL
- Exchange the code for an access token and ID token,
- 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:
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:
Update 2: Just had to fix some stuff with the Build Identifier. I'll post a link to an example SwiftUI App here soon.
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!!
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
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?
Support needed for Vision OS in order to build Vision pro Apps