Inheritance: PBXFileElement
Exemplo n.º 1
0
 /// <summary>
 ///   Adds the project reference.
 /// </summary>
 /// <param name = "group">The group.</param>
 /// <param name = "file">The file.</param>
 public void AddProjectReference(PBXGroup group, PBXFileReference file)
 {
     Dictionary<String, IPBXElement> reference = (from pr in this.projectReferences
                                                  where pr["ProjectRef"] == file
                                                  select pr).FirstOrDefault();
     if (reference != null)
     {
         return;
     }
     reference = new Dictionary<String, IPBXElement>();
     reference["ProductGroup"] = group;
     reference["ProjectRef"] = file;
     this.projectReferences.Add(reference);
 }
Exemplo n.º 2
0
        /// <summary>
        ///   Removes the group.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <returns></returns>
        public PBXGroup RemoveGroup(String groups)
        {
            lock (this.syncRoot) {
                // Only keep the n-1 groups
                List<String> parts = groups.Split (new[] {'/'}, StringSplitOptions.RemoveEmptyEntries).ToList ();
                String last = parts.Last ();
                parts.RemoveAt (parts.Count - 1);

                // Go to the parent group
                PBXGroup g, group = this.Document.Project.MainGroup;
                foreach (String part in parts) {
                    g = group.FindGroup (part);
                    if (g == null) {
                        // For each group not found, create it
                        g = new PBXGroup (part);
                        group.AddChild (g);
                    }
                    group = g;
                }

                // If the group to delete exists, remove it
                g = group.FindGroup (last);
                if (g != null) {
                    group.RemoveChild (g);
                }

                return g;
            }
        }
        public void TestProjectGeneration001()
        {
            // Create the document
            PBXDocument document = new PBXDocument();
            PBXProject project = document.Project;

            PBXFileReference file1 = new PBXFileReference();
            file1.LastKnownFileType = PBXFileType.WrapperFramework;
            file1.Name = "Cocoa.framework";
            file1.Path = "/System/Library/Frameworks/Cocoa.framework";
            file1.LastKnownFileType = PBXFileType.WrapperFramework;
            file1.SourceTree = PBXSourceTree.SdkRoot;

            PBXFileReference file2 = new PBXFileReference();
            file2.LastKnownFileType = PBXFileType.WrapperFramework;
            file2.Name = "SurrogateTestAppDelegate.h";
            file2.Path = "SurrogateTestAppDelegate.h";
            file2.LastKnownFileType = PBXFileType.SourcecodeCH;
            file2.SourceTree = PBXSourceTree.Group;

            PBXFileReference file3 = new PBXFileReference();
            file3.LastKnownFileType = PBXFileType.WrapperFramework;
            file3.Name = "en";
            file3.Path = "en.lproj/MainMenu.xib";
            file3.LastKnownFileType = PBXFileType.FileXib;
            file3.SourceTree = PBXSourceTree.Group;

            PBXFileReference file4 = new PBXFileReference();
            file4.LastKnownFileType = PBXFileType.WrapperFramework;
            file4.Name = "fr";
            file4.Path = "fr.lproj/MainMenu.xib";
            file4.LastKnownFileType = PBXFileType.FileXib;
            file4.SourceTree = PBXSourceTree.Group;

            PBXVariantGroup variantGroup = new PBXVariantGroup("MainMenu.xib");
            variantGroup.SourceTree = PBXSourceTree.Group;
            variantGroup.AddChild(file3);
            variantGroup.AddChild(file4);

            PBXGroup group1 = new PBXGroup("Products");
            group1.SourceTree = PBXSourceTree.Group;

            PBXGroup group2 = new PBXGroup("Frameworks");
            group2.SourceTree = PBXSourceTree.Group;
            group2.AddChild(file1);

            PBXGroup group3 = new PBXGroup("Classes");
            group3.SourceTree = PBXSourceTree.Group;
            group3.AddChild(file2);

            PBXGroup group4 = new PBXGroup("Resources");
            group4.SourceTree = PBXSourceTree.Group;
            group4.AddChild(variantGroup);

            PBXGroup group5 = document.Project.MainGroup;
            group5.SourceTree = PBXSourceTree.Group;
            group5.AddChild(group3);
            group5.AddChild(group4);
            group5.AddChild(group2);
            group5.AddChild(group1);

            document.Project.ProductRefGroup = group1;

            // Add build configuration "Release"
            XCBuildConfiguration releaseConfiguration = new XCBuildConfiguration();
            releaseConfiguration.Name = "Release";
            project.BuildConfigurationList.AddBuildConfiguration(releaseConfiguration);
            project.BuildConfigurationList.DefaultConfigurationName = "Release";

            document.WriteToFile("project-001.pbxproj");
        }
Exemplo n.º 4
0
 /// <summary>
 ///   Adds the group.
 /// </summary>
 /// <param name = "groups">The group path.</param>
 /// <returns></returns>
 public PBXGroup AddGroup(String groups)
 {
     lock (this.syncRoot) {
         // Split the group paths
         List<string> parts = groups.Split (new[] {'/'}, StringSplitOptions.RemoveEmptyEntries).ToList ();
         PBXGroup group = this.Document.Project.MainGroup;
         foreach (String part in parts) {
             PBXGroup g = group.FindGroup (part);
             if (g == null) {
                 // For each group not found, create it
                 g = new PBXGroup (part);
                 group.AddChild (g);
             }
             group = g;
         }
         return group;
     }
 }