Пример #1
0
        public override void UpdateProps()
        {
            string ext = null;

            if (m_ExplicitFileType != null)
            {
                SetPropertyString("explicitFileType", m_ExplicitFileType);
            }
            else if (m_LastKnownFileType != null)
            {
                SetPropertyString("lastKnownFileType", m_LastKnownFileType);
            }
            else
            {
                if (name != null)
                {
                    ext = Path.GetExtension(name);
                }
                else if (m_Path != null)
                {
                    ext = Path.GetExtension(m_Path);
                }
                if (ext != null)
                {
                    if (FileTypeUtils.IsFileTypeExplicit(ext))
                    {
                        SetPropertyString("explicitFileType", FileTypeUtils.GetTypeName(ext));
                    }
                    else
                    {
                        SetPropertyString("lastKnownFileType", FileTypeUtils.GetTypeName(ext));
                    }
                }
            }
            if (m_Path == name)
            {
                SetPropertyString("name", null);
            }
            else
            {
                SetPropertyString("name", name);
            }
            if (m_Path == null)
            {
                SetPropertyString("path", "");
            }
            else
            {
                SetPropertyString("path", m_Path);
            }
            SetPropertyString("sourceTree", FileTypeUtils.SourceTreeDesc(tree));
        }
Пример #2
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: what. 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)
        {
            PBXNativeTargetData target = nativeTargets[targetGuid];
            filename = Utils.FixSlashesInPath(filename);
            projectPath = Utils.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");

            PBXGroupData productGroup = GroupsGet(productsGroupGuid);

            // verify file extension
            string ext = Path.GetExtension(filename);
            if (!FileTypeUtils.IsBuildableFile(ext))
                throw new Exception("Wrong file extension");

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

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

            var libRef = PBXReferenceProxyData.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR");
            references.AddEntry(libRef);
            PBXBuildFileData libBuildFile = PBXBuildFileData.CreateFromFile(libRef.guid, false, null);
            BuildFilesAdd(targetGuid, libBuildFile);
            BuildSectionAny(target, ext, false).files.AddGUID(libBuildFile.guid);

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