Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Mac Unity Build (from a PC) not opening on Mac

Discussion in 'macOS' started by Iccontemporary, Aug 7, 2020.

  1. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    I made the Build for my project for both PC and Mac, however I had massive issues getting the Mac one to actually work. Here is the tutorial I used to make the builds which was suppppper helpful, but it didn't help fix my issue:


    I just figured out how to make the Mac build work with a friend and it was a bit of work. Once you follow the video's directions exactly for the Mac version, you can send the file to your Mac but when you do it will be labeled MacOS and then when you try to open it it will most likely fail and say missing application to open.

    From what I have learned from numerous threads (and I don't know how true this is, this is based off of other users), this is because the compression actually corrupts the executable file to open it on the Mac.

    ********
    *EDIT*

    The comments made it clear to me that "this has nothing to do with compression or even corruption. All files taken from a Windows machine will have default permissions, which are read/write. To launch something, you need to mark the executable with execute permission.

    This problem doesn't exist if you build from Mac or Linux editor."

    However, the following information did allow my Mac Build to run after the compression.

    *********

    To fix this, you have to use Terminal to navigate your way into the file and unlock the permission settings that were changed due what we believe is from the compression.

    I honestly can't remember where I found this code and when I remember I'll be sure to credit them, but with terminal you need to navigate to the download folder (or wherever you put your app) and add the following:

    cd <PATH_TO_YOUR_APP>/<APP_NAME>.app/Contents/MacOS/

    and add the following:

    chmod -R 777 [applicationName].app

    This unlocked the permissions on the application but when the app was opened, we had to allow permission through the Mac firewall to let it run on the computer. Once we approved permission, the app ran no problem.

    I hope this helps and I'm by no means a professional with this so but my friend and I can try to help in anyway possible.
     
    Last edited: Aug 9, 2020
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,796
    I don't think that has anything to do with compression. Windows simply does not have the concept of Unix file permissions, nor any way to represent them.
     
  3. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Truthfully I have no idea either, I'm only reiterating / compiling all the research I found from numerous threads but I'll specify that better
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,877
    Yeah this has nothing to do with compression or even corruption. All files taken from a Windows machine will have default permissions, which are read/write. To launch something, you need to mark the executable with execute permission.

    This problem doesn't exist if you build from Mac or Linux editor.
     
  5. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Do you know how to mark the executable prior to sending it from a PC? None of this information came up in my research and using Terminal afterwards was the only solution that worked.

    Thanks for also pointing out that it's not to do with compression.
     
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,796
    If you could do it on the PC, Unity would be doing it for you. The point is that you can't set the executable bit in Windows, because the Windows file system has no way to represent that.

    Though I suppose Unity could, in theory, spit out a Mac disk image, containing your app with all the bits set correctly... but there are probably technical reasons why that is very hard to do.
     
  7. peter_the_coder

    peter_the_coder

    Joined:
    Nov 28, 2017
    Posts:
    11
    well, so in reality it means, I can not build a mac build from windows so my friends can test it.
    Thats not very comfortable nowadays.
    Would it not made sense for unity to add a fixed Script with the build with also a readme how to do it ?

    Peter
     
    VardenEE and Iccontemporary like this.
  8. BeringelaUnity

    BeringelaUnity

    Joined:
    Jun 9, 2016
    Posts:
    5
    On Windows 10 you have the option to run WSL Windows Subsystem for Linux.
    Using WSL you can access your Windows file system from a linux command prompt, and use chmod etc to set file permissions.
     
    Pyr3z, MuntyMcFly, JakesFable and 2 others like this.
  9. jacobsherwood85

    jacobsherwood85

    Joined:
    Apr 3, 2018
    Posts:
    3
    I really can’t believe that there isn’t some sort of fix, be it from Unity, Microsoft, or Apple.

    it seems absolutely insane to me that in 2021 this could still be an issue, it’s not like we’re talking about someone’s personal rpg maker game or something, we’re talking about an industry standard tool.

    I feel like with something as big as unity these companies would work together to find a way to seamlessly build for all supported build platforms.

    It really feels lazy to me.

    I understand that windows can’t natively set the permissions, but I don’t believe for a second that they couldn’t implement something, nor do I believe that Unity is incapable of implementing some sort of fix, and if absolutely nothing else Apple certainly would be able to do it, considering it’s running natively on their platform.

    As simple as it is to fix it’s absolutely absurd to make end users go through this process. I don’t expect users to pay for a game and then modify it just to make it work, no matter how simple that modification may be.

    Unity needs to reach out to Microsoft and Apple so that this can be seamless.
     
  10. Rong_Deng

    Rong_Deng

    Joined:
    Jun 17, 2017
    Posts:
    1
    The problem I had:
    1. Make mac build on windows with Unity 2020.2.X
    2. Put on google drive and share
    3. Download the build on Mac
    4. Show it's damaged and can't open​

    Solution:
    1. Open Terminal
    2. cd to the *.app folder
    3. xattr -rc *.app
    4. Double-click, it opens
     
    Iccontemporary likes this.
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,877
    Iccontemporary likes this.
  12. poliman

    poliman

    Joined:
    Feb 5, 2015
    Posts:
    26
    I use 2020.3.0f1 and the BUG is NOT FIXED.
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,877
    Can you elaborate? The fix landed and has fixed the issue in all cases we could think of to test.
     
  14. CreakyVibez

    CreakyVibez

    Joined:
    Feb 22, 2021
    Posts:
    6
    i dont have chmod on my cmd
     
  15. CreakyVibez

    CreakyVibez

    Joined:
    Feb 22, 2021
    Posts:
    6
    its still an issue. my permissions are full control and still mac users cant run the app
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,877
    What is the error you're seeing? Can you show a screenshot?
     
  17. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,686
    I would like to note that the issue being discussed here is NOT the issue described in that ticket, which is why so many on this thread (me included) and in the comments on the ticket are saying it's not resolved.

    Issue in this thread is Unix file permissions. Windows Unity Editor makes a Mac build; Windows doesn't have file permissions like macOS does; so the files don't have the "execute" bit set; so when opened on a Mac, it is not allowed to execute.

    Issue in the ticket, which is the one resolved in 2020.3.x, is codesigning, which is how Apple tries to keep riffraff from running executables rampantly on maxOS.

    It may be that these issues were confused with each other and a ticket for the file permissions bug has never actually existed, and if so that definitely should be created, because Mac builds built with the Unity editor still are not runnable.
     
    Last edited: Mar 30, 2021
  18. KHatch_T17

    KHatch_T17

    Joined:
    Dec 3, 2020
    Posts:
    1
    Any plans to back fix this bug into 2019.4 LFS? It's causing us issues as well.
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,877
  20. mxoconnell

    mxoconnell

    Joined:
    Jun 8, 2014
    Posts:
    17
    Facing this issue on 2019.4.22f1 worked for other test macs but not on "macOS Big Sur v11.2.3"
     
    Iccontemporary likes this.
  21. mxoconnell

    mxoconnell

    Joined:
    Jun 8, 2014
    Posts:
    17
    We found a workaround where you open a terminal in the directory which contains the .app. Then you enter the command:
    sudo chmod -R 755 YOUR-APP-NAME.app
     
    Tmonrap and Iccontemporary like this.
  22. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,686
    Well yeah, but I can't exactly ask users to do that. And without a Mac myself I can't run that for them.
     
    JakesFable and Iccontemporary like this.
  23. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    When I first made this post, you didn't have to unlock the app each time. If you unlocked it once and shared it with other people, it would work. Now that I've updated my Mac though, I'm running into this problem too and trying to find the solution to it
     
  24. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    When you save this file and open it on another computer, does it stay unlocked? I'm running into an issue now where it needs to be unlocked on terminal each time
     
  25. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    So it seems this only happens when you compress the file on windows and then open it on your mac (even with Big Sur v11.2.3). Transfer the file from your Windows on a USB and then upload it on your mac. It should work then (it works for me).

    So I tried to do this again using a MacBook Pro 2020 with Catalina 10.15.7 and it also did not work. However, I then tried it with a MacBook Pro 2014 that uses the same version of Catalina and it worked... I have no idea why or how though.
     
  26. Anja-hft

    Anja-hft

    Joined:
    Apr 11, 2021
    Posts:
    1
    Did you find a solution for that? I have the same issue.
     
  27. Balthamet

    Balthamet

    Joined:
    Jan 25, 2014
    Posts:
    56
    This sounds like this could be easily solved by having WSL installed on your Windows computer
     
  28. BrainSlugs83

    BrainSlugs83

    Joined:
    Jun 18, 2015
    Posts:
    38
    I'd like to point that whether NTFS supports the executable attribute or not is irrelevant. -- Zip files *DO* support the attribute. -- All Unity has to do to fix this issue is spit out a zip file with the relevant attributes set. -- This would fix the problem for BOTH Mac and Linux builds (Linux obviously has the same problem).
     
    jukibom likes this.
  29. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,686
    Mac security practices like Apple's requirement for developers to have certificates that they build with are unrelated to the issue in this thread. This is about Unix file permissions.
     
    JakesFable likes this.
  30. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Still experiencing this -- the xattr command doesn't seem to work on others' Macs
     
  31. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Hey everyone, I managed to get it to work for Mac!!

    You have to change the permission first, which you can do with -R 755 YOUR-APP-NAME.app and then you have to ZIP your file. You then upload your zip and the program should work - it does for me at least.
     
  32. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Try changing the permission and then zipping the file, and upload the zip file
     
  33. deflix73

    deflix73

    Joined:
    Aug 1, 2015
    Posts:
    5
    Extraordinary after coming back to Unity after a few years with UE4 and I hit a wall immediately with this - what a sham.
     
  34. Nagan17

    Nagan17

    Joined:
    Jan 15, 2020
    Posts:
    1
    Hey. Im having the same problem. Can you tell me how do you changed the permissions. Steps would be great. Thanks
     
  35. BlackDove634

    BlackDove634

    Joined:
    Jan 30, 2020
    Posts:
    14
    Really hoping to get a streamlined solution for this from Unity staff! I'm losing my mind trying to get this to work. Please help!
     
  36. rollerball93

    rollerball93

    Joined:
    Nov 8, 2021
    Posts:
    4
    bump how do i fix
     
  37. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18

    On your mac open the terminal app and make sure your project is placed on your desktop. Then type the following into terminal, with each new line meaning you hit enter:

    cd:desktop
    chmod -R 777 (appname).app

    This keeps the file unlocked, but if you want to upload it to your dropbox or itch.io, zip the folder and upload the zipped folder. Let me know if that helps!
     
  38. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    n your mac open the terminal app and make sure your project is placed on your desktop. Then type the following into terminal, with each new line meaning you hit enter:

    cd:desktop
    chmod -R 777 (appname).app

    This keeps the file unlocked, but if you want to upload it to your dropbox or itch.io, zip the folder and upload the zipped folder. Let me know if that helps!
     
  39. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    On your mac open the terminal app and make sure your project is placed on your desktop. Then type the following into terminal, with each new line meaning you hit enter:

    cd:desktop
    chmod -R 777 (appname).app

    This keeps the file unlocked, but if you want to upload it to your dropbox or itch.io, zip the folder and upload the zipped folder. Let me know if that helps!
     
  40. j_a_quent

    j_a_quent

    Joined:
    Sep 18, 2018
    Posts:
    5
    It's incredibly annoying that a program like Unity is not able to make one their basic functionality work. I am creating an application for mac using Unity on Windows and friends that I send the application cannot open it even if I have other friends use chmod -R 777 (appname).app and then I send them that version.
     
  41. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Have you tried zipping the file that you unlock and sending them the zipped file?
     
  42. j_a_quent

    j_a_quent

    Joined:
    Sep 18, 2018
    Posts:
    5
    Yes, I did this as well. This morning I copied the application to a stick and opened it on a Mac. It works fine but when I send the same .zip over the internet it does not work.
     
  43. j_a_quent

    j_a_quent

    Joined:
    Sep 18, 2018
    Posts:
    5
    Update: The problem seems to be .zip when I instead create a .tar archive and send the appplication via the internet (e.g. a messenger) than everyone (N = 3) I tried can open it. I create the .tar archive with 7z on windows.
     
  44. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    18
    Have you tried hosting the file on a storage site like dropbox? That's what I do. If you use dropbox, send your friends the dropbox link of the file but change the 0 at the end of the link to a 1
     
  45. abedieckman

    abedieckman

    Joined:
    Nov 22, 2017
    Posts:
    6
    It is now September of 2022 and this issue has still not been fixed.
     
  46. lazer

    lazer

    Joined:
    Aug 15, 2012
    Posts:
    12
    After wasting a day looking for solutions, the best I came up with was to employ an external tool in my custom editor build script to reset permissions of every file in the zip I generate as part of my build process.

    Depends on DotNetZip and https://sourceforge.net/p/galaxyv2/code/HEAD/tree/other/zip_exec/.

    Code (CSharp):
    1.  
    2. public static void make_executable(string zip_path)
    3.     {
    4.         List<string> filenames = new List<string>();
    5.         using (ZipFile zip = new ZipFile(zip_path))
    6.         {
    7.             foreach (var ze in zip.Entries)
    8.             {
    9.                 Debug.Log($"zip entry filename: {ze.FileName}");
    10.                 filenames.Add(ze.FileName);
    11.             }
    12.         }
    13.  
    14.         foreach (var fn in filenames)
    15.         {
    16.             make_path_in_zip_executable(zip_path, fn);
    17.         }
    18.     }
    19.  
    20.     static void make_path_in_zip_executable(string zip_path, string path_in_zip)
    21.     {
    22.         string asset_path = Application.dataPath;
    23.  
    24.         // depends on zip_exec tool: https://sourceforge.net/p/galaxyv2/code/HEAD/tree/other/zip_exec/
    25.         string zip_exec_path = Path.Combine(asset_path, "BuildScripts/Editor/zip_exec", "zip_exec.exe");
    26.  
    27.         try {
    28.             Process p = new Process();
    29.             p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    30.             p.StartInfo.CreateNoWindow = true;
    31.             p.StartInfo.UseShellExecute = false;
    32.             p.StartInfo.FileName = zip_exec_path;
    33.          
    34.             p.StartInfo.Arguments = $"{zip_path} {path_in_zip}";
    35.             p.EnableRaisingEvents = true;
    36.             Debug.Log($"{p.StartInfo.FileName} {p.StartInfo.Arguments}");
    37.             p.StartInfo.RedirectStandardOutput = true;
    38.             p.StartInfo.RedirectStandardError = true;
    39.          
    40.             p.Start();
    41.             p.WaitForExit();
    42.             int ExitCode = p.ExitCode;
    43.          
    44.             Debug.Log($"stdout: {p.StandardOutput.ReadToEnd()}");
    45.             Debug.Log($"stderr: {p.StandardError.ReadToEnd()}");
    46.             Debug.Log($"Exit code: {p.ExitCode}");
    47.         }
    48.         catch (Exception e)
    49.         {
    50.             Debug.LogError(e);
    51.         }
    52.  
    53.     }
     
    StarManta likes this.
  47. JulesVerny

    JulesVerny

    Joined:
    Dec 21, 2015
    Posts:
    39
    Is there a simple guide on how to share Unity Builds across to those with Macs? From the above, it seems not.

    I develop, build and test on Windows, but I want to share my game with relatives who only have Macs. (I really want to avoid the Apple Store etc). So I can create Mac builds, which spit out a buildname.app folder structure. I just want to pass simple instructions to my relatives on how they can download my game (from my Google Drive) and install.
    They are not computer geeks so will not understand chmod etc.

    I also have Linux, with unity installed on Linux (and WSL on Windows) : perhaps I should build the Mac build on my Linux machine. Would that avoid hassle with file protections and avoid my relatives having to do this chmod stuff?

    Or if I remain on Windows, with WSL: Which files and folders do I then have to apply this chmod stuff to ? Can I then copy up to Google Drive, and be confident that my users on Macs, can then just click on buildname.app to install the game on their Mac ?

    Sorry I do not understand the Mac install process. (Since I do not ever have a Mac)

    Cheers