Hello, so I’m attempting to build my game for my friend who uses a mac and found that he couldn’t run the file built from my machine (Windows 10). I figured it was a problem with execution so I rebuilt the game from a Linux machine (Ubuntu 20.04) and my friend was able to run the program but it ran into an error of “Build is Damaged” whenever he launched it. I’m using Unity version 2020.3.2f1 for my project right now. Thinking that the cause may have been some configuration or error, I built an new project with no settings changes, sent it over to my friend, and ran into the same errors. Is this a known bug with the current version of 2020 unity editors?
In an attempt to work around and test this without having to send my game files to my friend constantly, I found a macOS VM that I could run from my Linux machine (GitHub - foxlet/macOS-Simple-KVM: Tools to set up a quick macOS VM in QEMU, accelerated by KVM.). While running through the error messages, I found this old forum post Unity Issue Tracker - [macOS] "build is damaged and cannot be opened" error when downloading Unity build from internet and that mentioned using the codesign command. Through these convoluted steps and a custom build workflow, I was able to build the project, sign it with the codesign command on the macOS VM, and send it to my friend.
Commands used to build project, whole script here - PropHunt-Mirror/Assets/Editor/ScriptBatch.cs at main · nicholas-maltbie/PropHunt-Mirror · GitHub
/Applications/Unity/Hub/Editor/2020.3.2f1/Unity.app/Contents/MacOS/Unity -quit -batchmode -executeMethod ScriptBatch.MacOSBuild
# Use the --deep parameter because I have sub bundle files that need to be signed
codesign -s - -f --deep Builds/MacOS/PropHunt.app
codesign -s - -f Builds/MacOS/PropHunt.app
Code for configuring build
public class ScriptBatch : IPostprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
public static string[] GetScenes()
{
return new string[] { "Assets/Scenes/BasicHouse.unity" };
}
public void OnPostprocessBuild(BuildReport report)
{
#if UNITY_STANDALONE_OSX
UnityEngine.Debug.Log("Signing files for MacOS Build");
UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath + "/Contents/PlugIns/steam_api.bundle");
UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath + "/Contents/PlugIns/phonon.bundle");
UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath + "/Contents/PlugIns/audioplugin_phonon.bundle");
UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath);
#endif
UnityEngine.Debug.Log("MyCustomBuildProcessor.OnPostprocessBuild for target " + report.summary.platform + " at path " + report.summary.outputPath);
}
[MenuItem("Build/MacOS Build")]
public static void MacOSBuild()
{
// Get filename.
string path = "Builds/MacOS";
string[] levels = GetScenes();
string appFolder = path + "/PropHunt.app";
PlayerSettings.SetArchitecture(BuildTargetGroup.Standalone, 1);
// Build player.
BuildPipeline.BuildPlayer(levels, appFolder, BuildTarget.StandaloneOSX, BuildOptions.Development);
}
}
I’m using some extra bundles for steam_api and phonon and thought they had some configuration problems but ran into the same errors even I used an empty project with no plugins, bundles, or other odd configurations. I could only get the compiled program to run on a macOS when built and signed from a macOS machine. The cross platform builds from windows to Linux (Ubuntu 20.04) or Linux (Ubuntu 20.04) to windows worked just fine. This is the part that threw me off the most, even a basic, empty unity project could not be built cross platform for a Mac. This might just be a problem with my macOS VM and my friend’s individual machine but I feel like there must be something I’m missing.
Here is the link to my whole repository if you want to know more about the individual configuration settings - GitHub - nicholas-maltbie/PropHunt-Mirror: PropHunt project made using Unity and Mirror Networking
Is there a better way to build the project for macOS, I remember it being more straightforward.
Is there a simple configuration setting I’m forgetting or have done incorrectly? I tried to look for resources online but didn’t find anything for addressing the issue me and my friends ran into. This set of build steps using a macOS VM is rather convoluted but I can probably mostly automate it so I’m not too worried but would like to know if there is a better option available.