public void AddCapability(PBXCapabilityType capability, string entitlementsFilePath = null, bool addOptionalFramework = false)
 {
     Debug.Log(string.Format("{0}: Begin Add Capability : {1}, EntitlementsFilePath : {2}, AddOptionalFramework : {3}", TAG, capability.id, entitlementsFilePath, addOptionalFramework));
     if (string.IsNullOrEmpty(entitlementsFilePath))
     {
         mProj.AddCapability(mTargetGuid, capability);
     }
     else
     {
         string mTargetEntitlementPath = entitlementsFilePath;
         string xcodeEntitlementPath   = entitlementsFilePath;
         string packToolsPath          = Application.dataPath.Replace("/YL/Assets", "/ProjectBuilder/PackTools/ExportOptions");
         string entitlement            = Path.Combine(packToolsPath, entitlementsFilePath);
         if (File.Exists(entitlement))
         {
             mTargetEntitlementPath = mTargetName + "/" + entitlementsFilePath;
             xcodeEntitlementPath   = Path.Combine(mBuildProjectPath, mTargetName + "/" + entitlementsFilePath);
             File.Copy(entitlement, xcodeEntitlementPath, true);
         }
         //mProj.AddFile(mTargetEntitlementPath, Path.GetFileName(entitlementsFilePath));
         //mProj.AddBuildProperty(mTargetGuid, "CODE_SIGN_ENTITLEMENTS", mTargetEntitlementPath);
         mProj.AddCapability(mTargetGuid, capability, mTargetEntitlementPath, addOptionalFramework);
     }
     Debug.Log(string.Format("{0}: Adding Capability : {1}, EntitlementsFilePath : {2}, AddOptionalFramework : {3}", TAG, capability.id, entitlementsFilePath, addOptionalFramework));
 }
        private static void AddNFCCapability(string path)
        {
            string projectPath = PBXProject.GetPBXProjectPath(path);
            //PBXProject project = new PBXProject();
            //project.ReadFromFile(projectPath);

            String packageName         = UnityEngine.Application.identifier;
            String name                = packageName.Substring(packageName.LastIndexOf('.') + 1);
            String entitlementFileName = name + ".entitlements";
            String entitlementPath     = Path.Combine(path, entitlementFileName);
            ProjectCapabilityManager projectCapabilityManager = new ProjectCapabilityManager(projectPath, entitlementFileName, PBXProject.GetUnityTargetName());
            PlistDocument            entitlementDocument      = AddNFCEntitlement(projectCapabilityManager);

            entitlementDocument.WriteToFile(entitlementPath);

            var        projectInfo = projectCapabilityManager.GetType().GetField("project", BindingFlags.NonPublic | BindingFlags.Instance);
            PBXProject project     = (PBXProject)projectInfo.GetValue(projectCapabilityManager);

            string            target        = project.TargetGuidByName(PBXProject.GetUnityTargetName());
            var               constructor   = typeof(PBXCapabilityType).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(bool), typeof(string), typeof(bool) }, null);
            PBXCapabilityType nfcCapability = (PBXCapabilityType)constructor.Invoke(new object[] { "com.apple.NearFieldCommunicationTagReading", true, "", false });

            project.AddCapability(target, nfcCapability, entitlementFileName);

            projectCapabilityManager.WriteToFile();
        }
示例#3
0
        static void SetSystemCapabilities()
        {
            List <iOSCapabilityType> capabilitys = BuildProjectSetting.instance.capabilitys;

            if (capabilitys != null)
            {
                for (int i = 0; i < capabilitys.Count; ++i)
                {
                    PBXCapabilityType type = iOSCapabilityTypeHelper.GetPBXCapabilityType(capabilitys[i]);
                    if (type != null)
                    {
                        pbxProject.AddCapability(targetGuid,
                                                 iOSCapabilityTypeHelper.GetPBXCapabilityType(capabilitys[i]), xcodeEntitlementsFilePath);
                    }
                }
            }
        }
 public TargetCapabilityPair(string guid, PBXCapabilityType type)
 {
     targetGuid = guid;
     capability = type;
 }
示例#5
0
 public static void AddMyCapability(this PBXProject pbxProject, PBXCapabilityType capabilityType)
 {
     pbxProject.AddCapability(pbxProject.UnityTargetGuid(), capabilityType, EntitlementsFileName, true);
 }
示例#6
0
        public override void UpdateVars()
        {
            projectReferences = new List <ProjectReference>();
            if (m_Properties.Contains("projectReferences"))
            {
                var el = m_Properties["projectReferences"].AsArray();
                foreach (var value in el.values)
                {
                    PBXElementDict dict = value.AsDict();
                    if (dict.Contains("ProductGroup") && dict.Contains("ProjectRef"))
                    {
                        string group      = dict["ProductGroup"].AsString();
                        string projectRef = dict["ProjectRef"].AsString();
                        projectReferences.Add(ProjectReference.Create(group, projectRef));
                    }
                }
            }
            targets         = GetPropertyList("targets");
            buildConfigList = GetPropertyString("buildConfigurationList");

            // update knownAssetTags
            knownAssetTags = new List <string>();
            if (m_Properties.Contains("attributes"))
            {
                var el = m_Properties["attributes"].AsDict();
                if (el.Contains("knownAssetTags"))
                {
                    var tags = el["knownAssetTags"].AsArray();
                    foreach (var tag in tags.values)
                    {
                        knownAssetTags.Add(tag.AsString());
                    }
                }

                capabilities = new List <PBXCapabilityType.TargetCapabilityPair>();
                teamIDs      = new Dictionary <string, string>();

                if (el.Contains("TargetAttributes"))
                {
                    var targetAttr = el["TargetAttributes"].AsDict();
                    foreach (var attr in targetAttr.values)
                    {
                        if (attr.Key == "DevelopmentTeam")
                        {
                            teamIDs.Add(attr.Key, attr.Value.AsString());
                        }

                        if (attr.Key == "SystemCapabilities")
                        {
                            var caps = el["SystemCapabilities"].AsDict();
                            foreach (var cap in caps.values)
                            {
                                capabilities.Add(new PBXCapabilityType.TargetCapabilityPair(attr.Key, PBXCapabilityType.StringToPBXCapabilityType(cap.Value.AsString())));
                            }
                        }
                    }
                }
            }
        }
 public TargetCapabilityPair(string guid, PBXCapabilityType type, bool isEnabled = false)
 {
     targetGuid = guid;
     capability = type;
     enabled    = isEnabled;
 }
示例#8
0
        public override void UpdateVars()
        {
            this.projectReferences = new List <ProjectReference>();
            if (this.m_Properties.Contains("projectReferences"))
            {
                foreach (PBXElement pbxElement in this.m_Properties["projectReferences"].AsArray().values)
                {
                    PBXElementDict pbxElementDict = pbxElement.AsDict();
                    if (pbxElementDict.Contains("ProductGroup") && pbxElementDict.Contains("ProjectRef"))
                    {
                        this.projectReferences.Add(ProjectReference.Create(pbxElementDict["ProductGroup"].AsString(), pbxElementDict["ProjectRef"].AsString()));
                    }
                }
            }
            this.targets         = this.GetPropertyList("targets");
            this.buildConfigList = this.GetPropertyString("buildConfigurationList");
            this.knownAssetTags  = new List <string>();
            if (!this.m_Properties.Contains("attributes"))
            {
                return;
            }
            PBXElementDict pbxElementDict1 = this.m_Properties["attributes"].AsDict();

            if (pbxElementDict1.Contains("knownAssetTags"))
            {
                foreach (PBXElement pbxElement in pbxElementDict1["knownAssetTags"].AsArray().values)
                {
                    this.knownAssetTags.Add(pbxElement.AsString());
                }
            }
            this.capabilities = new List <PBXCapabilityType.TargetCapabilityPair>();
            this.teamIDs      = new Dictionary <string, string>();
            if (pbxElementDict1.Contains("TargetAttributes"))
            {
                foreach (KeyValuePair <string, PBXElement> keyValuePair1 in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1["TargetAttributes"].AsDict().values)
                {
                    if (keyValuePair1.Key == "DevelopmentTeam")
                    {
                        this.teamIDs.Add(keyValuePair1.Key, keyValuePair1.Value.AsString());
                    }
                    if (keyValuePair1.Key == "SystemCapabilities")
                    {
                        foreach (KeyValuePair <string, PBXElement> keyValuePair2 in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1["SystemCapabilities"].AsDict().values)
                        {
                            this.capabilities.Add(new PBXCapabilityType.TargetCapabilityPair(keyValuePair1.Key, PBXCapabilityType.StringToPBXCapabilityType(keyValuePair2.Value.AsString())));
                        }
                    }
                }
            }
        }