|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEditor.Callbacks;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
#if UNITY_EDITOR_OSX
|
|
|
|
|
|
using UnityEditor.iOS.Xcode;
|
|
|
|
|
|
|
|
|
|
|
|
public class GrpcBuildPostProcess
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[PostProcessBuild]
|
|
|
|
|
|
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (buildTarget == BuildTarget.iOS)
|
|
|
|
|
|
{
|
|
|
|
|
|
/* .xcodeproj/project.pbxproj */
|
|
|
|
|
|
|
|
|
|
|
|
//Get path to the PBX project
|
|
|
|
|
|
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
|
|
|
|
|
|
|
|
|
|
|
|
//Read the pbx project
|
|
|
|
|
|
PBXProject proj = new PBXProject();
|
|
|
|
|
|
proj.ReadFromString(File.ReadAllText(projPath));
|
|
|
|
|
|
|
|
|
|
|
|
//Get the build target
|
|
|
|
|
|
string target = proj.TargetGuidByName("Unity-iPhone");
|
|
|
|
|
|
|
|
|
|
|
|
//set ENABLE_BITCODE to false (this shouldn't be required in Unity 5.2+)
|
|
|
|
|
|
proj.SetBuildProperty(target, "ENABLE_BITCODE", "No");
|
|
|
|
|
|
|
|
|
|
|
|
//Add libz.dylib
|
|
|
|
|
|
string name = proj.AddFile("/usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Source);
|
|
|
|
|
|
proj.AddFileToBuild(target, name);
|
|
|
|
|
|
//proj.AddFrameworkToProject(target, "/usr/lib/libz.dylib", false);
|
|
|
|
|
|
|
|
|
|
|
|
//Write back out the PBX project
|
|
|
|
|
|
File.WriteAllText(projPath, proj.WriteToString());
|
|
|
|
|
|
|
|
|
|
|
|
/* Info.plist */
|
|
|
|
|
|
|
|
|
|
|
|
// Read the Info.plist file
|
|
|
|
|
|
string plistPath = path + "/Info.plist";
|
|
|
|
|
|
PlistDocument plist = new PlistDocument();
|
|
|
|
|
|
plist.ReadFromString(File.ReadAllText(plistPath));
|
|
|
|
|
|
|
|
|
|
|
|
// Get root of plist
|
|
|
|
|
|
PlistElementDict rootDict = plist.root;
|
|
|
|
|
|
//Set Requires full screen = true. This was needed only with Xcode 9.
|
|
|
|
|
|
rootDict.SetBoolean("UIRequiresFullScreen", true);
|
|
|
|
|
|
//Adding background modes for remote notification (For Push notifications - OneSignal)
|
|
|
|
|
|
var bgModes = rootDict.CreateArray("UIBackgroundModes");
|
|
|
|
|
|
bgModes.AddString("remote-notification");
|
|
|
|
|
|
|
|
|
|
|
|
//Write out the Info.plist file
|
|
|
|
|
|
plist.WriteToFile(plistPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|