# GoogleSignIn iOS configuration
## Google Oauth
Create a new google oauth credentials for iOS.

To make the GoogleSignin plugin work in iOS you need the .plist file which is a configuration file Google provides us. It stores key-values pairs.
Here are the key components that may be included in a .plist file for Google OAuth on iOS:
* ***REVERSED_CLIENT_ID***
The REVERSED_CLIENT_ID is derived from your iOS app's bundle identifier (often referred to as "reverse domain name notation").
It is used to uniquely identify your iOS app when interacting with Google services, such as Google Sign-In.
* ***CLIENT_ID***
The CLIENT_ID is a unique identifier assigned to your application when you register it with an identity provider like Google. It is a crucial part of the OAuth 2.0 authorization process.
In an iOS app using Google Sign-In, the CLIENT_ID is typically used during the initialization of the Google Sign-In SDK to identify your app to the Google API
* ***PLIST_VERSION***
* ***BUNDLE_ID***
### Download the .plist file
You have to download this .plist file that Google provides. And rename it to **GoogleService-Info.plist**. This step is important, if you do not do it, it will not be recognized by Xcode.

### With this file we can create the **URL scheme**. What it is?
A URL scheme is a way to enable communication between apps on iOS. It allows one app to open another app or respond to specific URLs.
For Google Sign-In on iOS, a custom URL scheme is used to redirect the user back to your app after they have signed in with Google.
### Configure URL scheme
So you have to set the REVERSED_CLIENT_ID in your URL scheme both in Unity and Xcode
#### Unity

#### Xcode

Once you have the .plist downloaded you have to add it to the **StreamingAssets** Unity folder. So it can be reference once the build is done.
Followed this, you also have to create an Editor Folder in unity and create a script inside it. I called it `GoogleSignInPostBuild`. This script copies the file to the root of the xcode project and sets the correct target.
```
[PostProcessBuild(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath)
{
var projPath = buildPath + "/Unity-iPhone.xcodeproj/project.pbxproj";
var proj = new PBXProject();
proj.ReadFromFile(projPath);
var targetGuid = proj.GetUnityMainTargetGuid();
proj.AddFileToBuild(
targetGuid,
proj.AddFile("Data/Raw/GoogleService-Info.plist", "GoogleService-Info.plist")
);
proj.WriteToFile(projPath);
}
```
After doing the unity build your Xcode project should look this somethink like this:

Notice how to the `GoogleService-Info.plist` was automatically added to the project.
Now you are good to go.