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

[iOS][Xcode][Unity 2019.4.21f1] GoogleService-Info.plist not include in your build #1

Closed
yenmoc opened this issue May 14, 2021 · 0 comments
Assignees
Labels
Firebase Firebase Issue Issue Unity Unity Xcode Xcode

Comments

@yenmoc
Copy link
Owner

yenmoc commented May 14, 2021

Screen Shot 2021-05-14 at 14 21 03

Screen Shot 2021-05-14 at 14 24 58


How to solve the problem

  • Directly copy the file GoogleService-Info.plist during xcode build through PostProcessBuild
  • Place BuildPostProcessorInfo.cs anywhere in your Unity project
#if UNITY_EDITOR && UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

public class BuildPostProcessorInfo
{
        [PostProcessBuild]
	public static void OnPostProcessBuildAddFirebaseFile(BuildTarget buildTarget, string pathToBuiltProject)
	{
		if (buildTarget == BuildTarget.iOS)
		{
			// Go get pbxproj file
			string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
			// PBXProject class represents a project build settings file,
			// here is how to read that in.
			PBXProject proj = new PBXProject();
			proj.ReadFromFile(projPath);
			// Copy plist from the project folder to the build folder
			proj.AddFileToBuild(proj.GetUnityMainTargetGuid(), proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
			// Write PBXProject object back to the file
			proj.WriteToFile(projPath);
		}
	}
}
#endif
@yenmoc yenmoc added Unity Unity Xcode Xcode Issue Issue Firebase Firebase labels May 14, 2021
@yenmoc yenmoc self-assigned this May 14, 2021
@yenmoc yenmoc closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Firebase Firebase Issue Issue Unity Unity Xcode Xcode
Projects
None yet
Development

No branches or pull requests

1 participant