Пример #1
0
        public static PBXContainerItemProxy Create(string containerRef, string proxyType,
                                                   string remoteGlobalGUID, string remoteInfo)
        {
            var res = new PBXContainerItemProxy();

            res.guid = PBXGUID.Generate();
            res.m_Properties["isa"]                  = "PBXContainerItemProxy";
            res.m_Properties["containerPortal"]      = containerRef;
            res.m_Properties["proxyType"]            = proxyType;
            res.m_Properties["remoteGlobalIDString"] = remoteGlobalGUID;
            res.m_Properties["remoteInfo"]           = remoteInfo;
            return(res);
        }
Пример #2
0
 public static PBXContainerItemProxy Create(string containerRef, string proxyType,
                                            string remoteGlobalGUID, string remoteInfo)
 {
     var res = new PBXContainerItemProxy();
     res.guid = PBXGUID.Generate();
     res.m_Properties["isa"] = "PBXContainerItemProxy";
     res.m_Properties["containerPortal"] = containerRef;
     res.m_Properties["proxyType"] = proxyType;
     res.m_Properties["remoteGlobalIDString"] = remoteGlobalGUID;
     res.m_Properties["remoteInfo"] = remoteInfo;
     return res;
 }
Пример #3
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);
        }
Пример #4
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);
        }