Incorrect CODE_SIGN_ENTITLEMENTS when using ProjectCapabilityManager in Unity to add entitlements to Xcode output

Viewed 1070

I'm using ProjectCapabilityManager OnPostprocessBuildIOS to automate the process of enabling capabilities, "Associated Domains" specifically, and adding applinks:mydomain.xxx as an associated domain for my iOS game in Unity3d.

This is the code (with little modification to string values) that I'm using:

    string pbxPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
    string entitlementsFileName = "myproject.entitlements";
    var entitlements = new ProjectCapabilityManager(pbxPath, entitlementsFileName, PBXProject.GetUnityTargetName());      
    entitlements.AddAssociatedDomains(new string[] { "applinks:mydomain.xxx" });
    entitlements.WriteToFile();

The problem is the project in Xcode will end up having two entitlement file addresses separated by an space as the value for CODE_SIGN_ENTITLEMENTS, something like:

myproject.entitlements Unity-iPhone/Unity-iPhone.entitlements

and Xcode says Verify the value of the CODE_SIGN_ENTITLEMENTS build setting for target "Unity-iPhone" is correct and that the file exists on disk. If I remove any of the two files from CODE_SIGN_ENTITLEMENTS there is not an error anymore.

How should I solve this?

0 Answers
Related