Search Unity

Question (MacOS) When Unity create the info.plist and code sign MacOS builds in the build cycle?

Discussion in 'Editor & General Support' started by BearCannoli, Aug 3, 2021.

  1. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    At what point does Unity code sign MacOS builds in the build cycle? Is it before, during or after the post build process?

    I'm modifying the info.plist with a PostBuildProcess script - but it seems to be changing it after the app is already code signed. This causes MacOS gatekeeper to no longer read the Mic and Camera usage descriptions for my app - which prevents players from using those peripherals.

    Does anyone know if the info.plist can be modified before Unity code signs the app?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The build gets signed before postprocess script step, but you can resign it after you modify your plist file using UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle("/path/to/game.app").

    You can also set Microphone and Camera usage descriptors in the player settings - you shouldn't have to modify the plist file manually for them.
     
  3. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    Thank you for the information!

    I'm editing the info.plist to add URI scheme for deeplink capabilities. The usage descriptions are set in the player settings as you described.

    The problem is that since the build gets signed then afterward the info.plist gets modified, codesign --verify --verbose will state that the info.plist is invalid. The app will still run, but any info.plist key/values that enable the OS to ask for user permissions for Camera/Mic seem get disables.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I see. Yeah, if you just resign it after modifying the plist file, everything should work fine.
     
  5. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    Thanks for the help!

    I'm running into the issue where UnityEditor.OSXStandalone does not exist? I also can't seem to find any documentation about this namespace. Is there a resource to look at for this?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    What Unity version are you on? Is MacOS the active build target? Is your script in an "Editor" folder?

    This should work:

    Code (csharp):
    1. public class MyPostprocessor : IPostprocessBuildWithReport
    2. {
    3.     public int callbackOrder => 0;
    4.     public void OnPostprocessBuild(BuildReport report)
    5.     {
    6. #if UNITY_STANDALONE_OSX
    7.         UnityEditor.OSXStandalone.MacOSCodeSigning.CodeSignAppBundle(report.summary.outputPath);
    8. #endif
    9.     }
    10. }
     
  7. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    Apologies! I accidentally put the script with the regular scripts folder.

    I know there is callbackOrder int to define the ordering the the PostprocessBuild scripts - but I'm wondering if there is a way to force one the order of one script to be the very last. Unfortunately I don't have access to the source code for the plugin that is implementing the other PostprocessBuild scripts.

    I do know that the plugin is using the older style of PostprocessBuild that utilizes the (BuildTarget target, string output) parameters.

    So is there a way to to force the callbackorder to be last without knowing if a callbacker order # is set on the other scripts?
     
  8. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    I found a solution that works for now... I set the callbackOrder to int.MaxValue

    Code (CSharp):
    1. public int callbackOrder => int.MaxValue;
    For now, this works. I appreciate all the help!
     
  9. MaxwellDexter

    MaxwellDexter

    Joined:
    Sep 28, 2018
    Posts:
    15
    Hi there, how are you accessing the info.plist?
    I can only find that there is plist support in the iOS package as described here.
    But my app is only for Mac, do I need to install the iOS build support to edit plists?
    I've found this post for editing plists but it uses the UnityEditor.iOS.Xcode package.
     
  10. BearCannoli

    BearCannoli

    Joined:
    May 12, 2020
    Posts:
    9
    I access it during the PostBuildScript process. I manually add the fields needed in that process and save the updated info.plist and then code-sign it as mentioned in the above responses.