What is the best way to enable game center while using cloud build? I know there is stuff out there like this, which work:
Hello! I was wondering if anyone had managed to "turn on" iCloud for Cloud builds. I've had a good old search around, and have of course looked into the various frameworks to modify the project file, but unfortunately iCloud is a bit more complex...
Reading time: 3 mins 🕑
Likes: 14 ❤
However, that is super hacky and since Game Center is officially supported by Unity, I think they would have a much better way. Am I missing something?
Thanks!
Bumping the thread Anyone?
I haven’t tried this yet, but I think you can strongly link the Game Kit framework in a post-process method, like so:
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IPHONE
using UnityEditor.iOS.Xcode;
#endif
public class PListPostProcess
{
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
#if UNITY_IPHONE
// Get path to Xcode project
string projPath = PBXProject.GetPBXProjectPath(path);
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
// Read target
string targetName = PBXProject.GetUnityTargetName();
string projectTarget = proj.TargetGuidByName(targetName);
// Get target for project Plist
string plistPath = Path.Combine(path, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Edit Xcode project settings to include Game Kit
proj.AddFrameworkToProject(projectTarget, "GameKit.framework", false); // 'false' so the framework is strongly linked
// Write plist
File.WriteAllText(plistPath, plist.WriteToString());
// Write product
proj.WriteToFile(projPath);
#endif
}
}
This edits the Xcode project to make GameKit.framework required.
Alternate solution: click on a .a or .h file in your iOS plugins, and in the Inspector panel you should see “Framework Dependencies.” Check GameKit and you’re done, no need for post-process methods.
1 Like