Ejemplo n.º 1
0
        /// Interprets the value of the given property as a set of space-delimited strings, then
        /// removes strings equal to items to removeValues and adds strings in addValues.
        public void UpdateBuildProperty(string targetGuid, string name, string[] addValues, string[] removeValues)
        {
            PBXNativeTarget target = nativeTargets[targetGuid];

            foreach (string guid in configs[target.buildConfigList].buildConfig)
            {
                buildConfigs[guid].UpdateProperties(name, addValues, removeValues);
            }
        }
Ejemplo n.º 2
0
        public void SetBuildProperty(string targetGuid, string name, string value)
        {
            PBXNativeTarget target = nativeTargets[targetGuid];

            foreach (string guid in configs[target.buildConfigList].buildConfig)
            {
                buildConfigs[guid].SetProperty(name, value);
            }
        }
Ejemplo n.º 3
0
 string GetBuildFileForFileRef(PBXNativeTarget target, string fileRefGuid, string ext)
 {
     foreach (var guid in BuildSection(target, ext).file)
     {
         var buildFile = buildFiles[guid];
         if (buildFile != null && buildFile.fileRef == fileRefGuid)
         {
             return(guid);
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags)
        {
            PBXNativeTarget target = nativeTargets[targetGuid];
            string          ext    = Path.GetExtension(fileRefs[fileGuid].path);

            if (FileTypeUtils.IsBuildable(ext) &&
                GetBuildFileForFileRef(target, fileGuid, ext) == null)
            {
                PBXBuildFile buildFile = PBXBuildFile.CreateFromFile(fileGuid, weak, compileFlags);
                buildFiles.AddEntry(buildFile);
                BuildSection(target, ext).AddGUID(buildFile.guid);
            }
        }
Ejemplo n.º 5
0
        public string BuildConfigByName(string targetGuid, string name)
        {
            PBXNativeTarget target = nativeTargets[targetGuid];

            foreach (string guid in configs[target.buildConfigList].buildConfig)
            {
                var buildConfig = buildConfigs[guid];
                if (buildConfig != null && buildConfig.name == name)
                {
                    return(buildConfig.guid);
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        FileGUIDListBase BuildSection(PBXNativeTarget target, string path)
        {
            string ext   = Path.GetExtension(path);
            var    phase = FileTypeUtils.GetFileType(ext);

            switch (phase)
            {
            case PBXFileType.Framework:
                foreach (var guid in target.phase)
                {
                    if (frameworks.entry.ContainsKey(guid))
                    {
                        return(frameworks.entry[guid]);
                    }
                }
                break;

            case PBXFileType.Resource:
                foreach (var guid in target.phase)
                {
                    if (resources.entry.ContainsKey(guid))
                    {
                        return(resources.entry[guid]);
                    }
                }
                break;

            case PBXFileType.Source:
                foreach (var guid in target.phase)
                {
                    if (sources.entry.ContainsKey(guid))
                    {
                        return(sources.entry[guid]);
                    }
                }
                break;

            case PBXFileType.CopyFile:
                foreach (var guid in target.phase)
                {
                    if (copyFiles.entry.ContainsKey(guid))
                    {
                        return(copyFiles.entry[guid]);
                    }
                }
                break;
            }
            return(null);
        }
Ejemplo n.º 7
0
        public static PBXNativeTarget Create(string name, string productRef, string productType, string buildConfigList)
        {
            var res = new PBXNativeTarget();

            res.guid = PBXGUID.Generate();
            res.m_Properties["isa"] = "PBXNativeTarget";
            res.m_Properties["buildConfigurationList"] = buildConfigList;
            res.m_ListProperties["buildPhases"]        = new List <string>();
            res.m_ListProperties["buildRules"]         = new List <string>();
            res.m_ListProperties["dependencies"]       = new List <string>();
            res.m_Properties["name"]             = name;
            res.m_Properties["productName"]      = name;
            res.m_Properties["productReference"] = productRef;
            res.m_Properties["productType"]      = productType;
            return(res);
        }
Ejemplo n.º 8
0
 public static PBXNativeTarget Create(string name, string productRef, string productType, string buildConfigList)
 {
     var res = new PBXNativeTarget();
     res.guid = PBXGUID.Generate();
     res.m_Properties["isa"] = "PBXNativeTarget";
     res.m_Properties["buildConfigurationList"] = buildConfigList;
     res.m_ListProperties["buildPhases"] = new List<string>();
     res.m_ListProperties["buildRules"] = new List<string>();
     res.m_ListProperties["dependencies"] = new List<string>();
     res.m_Properties["name"] = name;
     res.m_Properties["productName"] = name;
     res.m_Properties["productReference"] = productRef;
     res.m_Properties["productType"] = productType;
     return res;
 }
Ejemplo n.º 9
0
 private FileGUIDListBase BuildSection(PBXNativeTarget target, string path)
 {
     string ext = Path.GetExtension(path);
     var phase = FileTypeUtils.GetFileType(ext);
     switch (phase) {
     case PBXFileType.Framework:
         foreach (var guid in target.phase)
             if (frameworks.entry.ContainsKey(guid))
                 return frameworks.entry[guid];
         break;
     case PBXFileType.Resource:
         foreach (var guid in target.phase)
             if (resources.entry.ContainsKey(guid))
                 return resources.entry[guid];
         break;
     case PBXFileType.Source:
         foreach (var guid in target.phase)
             if (sources.entry.ContainsKey(guid))
                 return sources.entry[guid];
         break;
     case PBXFileType.CopyFile:
         foreach (var guid in target.phase)
             if (copyFiles.entry.ContainsKey(guid))
                 return copyFiles.entry[guid];
         break;
     }
     return null;
 }
Ejemplo n.º 10
0
        // Returns the guid of the new target
        internal string AddAppExtension(string mainTarget, string name, string infoPlistPath)
        {
            const string ext            = ".appex";
            string       fullName       = name + ext;
            var          productFileRef = PBXFileReference.CreateFromFile("Products/" + fullName, "Products/" + fullName,
                                                                          PBXSourceTree.Group);
            var releaseBuildConfig = XCBuildConfiguration.Create("Release");

            buildConfigs.AddEntry(releaseBuildConfig);
            SetDefaultAppExtensionReleaseBuildFlags(releaseBuildConfig, infoPlistPath);

            var debugBuildConfig = XCBuildConfiguration.Create("Debug");

            buildConfigs.AddEntry(debugBuildConfig);
            SetDefaultAppExtensionDebugBuildFlags(debugBuildConfig, infoPlistPath);

            var buildConfigList = XCConfigurationList.Create();

            configs.AddEntry(buildConfigList);
            buildConfigList.buildConfig.Add(releaseBuildConfig.guid);
            buildConfigList.buildConfig.Add(debugBuildConfig.guid);

            var newTarget = PBXNativeTarget.Create(name, productFileRef.guid, "com.apple.product-type.app-extension", buildConfigList.guid);

            nativeTargets.AddEntry(newTarget);
            project.project.targets.Add(newTarget.guid);

            var sourcesBuildPhase = PBXSourcesBuildPhase.Create();

            sources.AddEntry(sourcesBuildPhase);
            newTarget.phase.Add(sourcesBuildPhase.guid);

            var resourcesBuildPhase = PBXResourcesBuildPhase.Create();

            resources.AddEntry(resourcesBuildPhase);
            newTarget.phase.Add(resourcesBuildPhase.guid);

            var frameworksBuildPhase = PBXFrameworksBuildPhase.Create();

            frameworks.AddEntry(frameworksBuildPhase);
            newTarget.phase.Add(frameworksBuildPhase.guid);

            var copyFilesBuildPhase = PBXCopyFilesBuildPhase.Create("Embed App Extensions", "13");

            copyFiles.AddEntry(copyFilesBuildPhase);
            nativeTargets[mainTarget].phase.Add(copyFilesBuildPhase.guid);

            var containerProxy = PBXContainerItemProxy.Create(project.project.guid, "1", newTarget.guid, name);

            containerItems.AddEntry(containerProxy);

            var targetDependency = PBXTargetDependency.Create(newTarget.guid, containerProxy.guid);

            targetDependencies.AddEntry(targetDependency);

            nativeTargets[mainTarget].dependencies.Add(targetDependency.guid);

            AddFile(fullName, "Products/" + fullName, PBXSourceTree.Build);
            var buildAppCopy = PBXBuildFile.CreateFromFile(FindFileGuidByProjectPath("Products/" + fullName), false, "");

            buildFiles.AddEntry(buildAppCopy);
            copyFilesBuildPhase.file.Add(buildAppCopy.guid);

            AddFile(infoPlistPath, name + "/Supporting Files/Info.plist", PBXSourceTree.Group);

            return(newTarget.guid);
        }
Ejemplo n.º 11
0
        /** This function must be called only after the project the library is in has
         *  been added as a dependency via AddExternalProjectDependency. projectPath must be
         *  the same as the 'path' parameter passed to the AddExternalProjectDependency.
         *  remoteFileGuid must be the guid of the referenced file as specified in
         *  PBXFileReference section of the external project
         *
         *  TODO: wtf. is remoteInfo entry in PBXContainerItemProxy? Is in referenced project name or
         *  referenced library name without extension?
         */
        public void AddExternalLibraryDependency(string targetGuid, string filename, string remoteFileGuid, string projectPath,
                                                 string remoteInfo)
        {
            PBXNativeTarget target = nativeTargets[targetGuid];

            filename    = FixSlashesInPath(filename);
            projectPath = FixSlashesInPath(projectPath);

            // find the products group to put the new library in
            string projectGuid = FindFileGuidByRealPath(projectPath);

            if (projectGuid == null)
            {
                throw new Exception("No such project");
            }

            string productsGroupGuid = null;

            foreach (var proj in project.project.projectReferences)
            {
                if (proj.projectRef == projectGuid)
                {
                    productsGroupGuid = proj.group;
                    break;
                }
            }

            if (productsGroupGuid == null)
            {
                throw new Exception("Malformed project: no project in project references");
            }

            PBXGroup productGroup = groups[productsGroupGuid];

            // verify file extension
            string ext = Path.GetExtension(filename);

            if (!FileTypeUtils.IsBuildable(ext))
            {
                throw new Exception("Wrong file extension");
            }

            // create ContainerItemProxy object
            var container = PBXContainerItemProxy.Create(projectGuid, "2", remoteFileGuid, remoteInfo);

            containerItems.AddEntry(container);

            // create a reference and build file for the library
            string typeName = FileTypeUtils.GetTypeName(ext);

            var libRef = PBXReferenceProxy.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR");

            references.AddEntry(libRef);
            PBXBuildFile libBuildFile = PBXBuildFile.CreateFromFile(libRef.guid, false, null);

            buildFiles.AddEntry(libBuildFile);
            BuildSection(target, ext).AddGUID(libBuildFile.guid);

            // add to products folder
            productGroup.AddGUID(libRef.guid);
        }