상속: PBXElement
예제 #1
0
        /// <summary>
        ///   Adds the framework.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <param name = "framework">The framework.</param>
        /// <param name = "targetName">Name of the target.</param>
        /// <returns></returns>
        public PBXBuildFile AddFramework(String groups, String framework, String targetName)
        {
            lock (this.syncRoot) {
                // Test for presence in System
                String path = String.Format(CultureInfo.CurrentCulture, "/System/Library/Frameworks/{0}.framework/{0}", framework);
                if (File.Exists(path))
                {
                    goto bail;
                }

                // Test for presence in Library
                path = String.Format(CultureInfo.CurrentCulture, "/Library/Frameworks/{0}.framework/{0}", framework);
                if (File.Exists(path))
                {
                    goto bail;
                }

                // Fallback: Assume it is a system framework
                path = String.Format(CultureInfo.CurrentCulture, "/System/Library/Frameworks/{0}.framework/{0}", framework);

bail:
                String file = Path.GetDirectoryName(path);
                PBXTarget      target      = this.GetTarget(targetName);
                PBXBuildPhase  phase       = GetTargetPhase <PBXFrameworksBuildPhase> (target);
                PBXFileElement fileElement = this.AddFile(groups, file, PBXSourceTree.Absolute);
                PBXBuildFile   buildFile   = phase.FindFile(fileElement);
                if (buildFile == null)
                {
                    buildFile = new PBXBuildFile(fileElement);
                    phase.AddFile(buildFile);
                }
                return(buildFile);
            }
        }
예제 #2
0
        /// <summary>
        ///   Adds the file.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <param name = "file">The file.</param>
        /// <param name = "targetName">Name of the target.</param>
        /// <returns></returns>
        public PBXBuildFile AddFile(String groups, String file, String targetName)
        {
            lock (this.syncRoot) {
                PBXFileElement fileElement = this.AddFile(groups, file);

                PBXTarget target = this.GetTarget(targetName);
                if (target == null)
                {
                    return(null);
                }

                PBXBuildPhase phase = GetTargetPhase(target, file);
                if (phase == null)
                {
                    return(null);
                }

                PBXBuildFile buildFile = phase.FindFile(fileElement);
                if (buildFile == null)
                {
                    buildFile = new PBXBuildFile(fileElement);
                    phase.AddFile(buildFile);
                }

                return(buildFile);
            }
        }
예제 #3
0
 /// <summary>
 ///   Adds the library.
 /// </summary>
 /// <param name = "groups">The groups.</param>
 /// <param name = "library">The library.</param>
 /// <param name = "targetName">Name of the target.</param>
 /// <returns></returns>
 public PBXBuildFile AddLibrary(String groups, String library, String targetName)
 {
     lock (this.syncRoot) {
         PBXTarget      target      = this.GetTarget(targetName);
         PBXBuildPhase  phase       = GetTargetPhase <PBXFrameworksBuildPhase> (target);
         PBXFileElement fileElement = this.AddFile(groups, library, PBXSourceTree.Group);
         PBXBuildFile   buildFile   = phase.FindFile(fileElement);
         if (buildFile == null)
         {
             buildFile = new PBXBuildFile(fileElement);
             phase.AddFile(buildFile);
         }
         return(buildFile);
     }
 }
예제 #4
0
        /// <summary>
        ///   Removes the file.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <param name = "file">The file.</param>
        /// <returns></returns>
        public PBXFileReference RemoveFile(String groups, String file)
        {
            lock (this.syncRoot) {
                // Prepare the group that contains the file
                PBXGroup         group         = this.GetGroup(groups);
                PBXFileReference fileReference = null;
                PBXFileElement   result        = null;

                // Extract information
                String name      = Path.GetFileName(file);
                String parentDir = Path.GetDirectoryName(file);

                // If the file is localized, search for the variant group
                if (Path.GetExtension(parentDir).Equals(".lproj"))
                {
                    PBXVariantGroup variantGroup = group.FindVariantGroup(name);
                    if (variantGroup != null)
                    {
                        // The file is named like the language
                        name = Path.GetFileNameWithoutExtension(parentDir);
                    }
                    group  = variantGroup;
                    result = variantGroup;
                }

                if (group != null)
                {
                    // Search for the file and remove it
                    fileReference = group.FindFileReference(name);
                    if (fileReference != null)
                    {
                        group.RemoveChild(fileReference);
                    }
                }

                if (result == null)
                {
                    result = fileReference;
                }
                return(fileReference);
            }
        }
예제 #5
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "PBXBuildFile" /> class.
 /// </summary>
 /// <param name = "fileRef">The file ref.</param>
 public PBXBuildFile(PBXFileElement fileRef)
 {
     this.FileRef = fileRef;
 }
예제 #6
0
 public PBXBuildFile FindFile(PBXFileElement file)
 {
     return this.files.FirstOrDefault(f => f.FileRef == file);
 }
예제 #7
0
 /// <summary>
 ///   Removes the child.
 /// </summary>
 /// <param name = "element">The element.</param>
 public void RemoveChild(PBXFileElement element)
 {
     this.children.Remove(element);
 }
예제 #8
0
 /// <summary>
 ///   Adds the child.
 /// </summary>
 /// <param name = "element">The element.</param>
 public void AddChild(PBXFileElement element)
 {
     this.children.Add(element);
 }
예제 #9
0
 /// <summary>
 ///   Removes the child.
 /// </summary>
 /// <param name = "element">The element.</param>
 public void RemoveChild(PBXFileElement element)
 {
     this.children.Remove(element);
 }
예제 #10
0
 /// <summary>
 ///   Adds the child.
 /// </summary>
 /// <param name = "element">The element.</param>
 public void AddChild(PBXFileElement element)
 {
     this.children.Add(element);
 }
예제 #11
0
 public PBXBuildFile FindFile(PBXFileElement file)
 {
     return(this.files.FirstOrDefault(f => f.FileRef == file));
 }
예제 #12
0
        /// <summary>
        ///   Adds the file.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <param name = "file">The file.</param>
        /// <param name = "sourceTree">The source tree.</param>
        /// <returns></returns>
        public PBXFileElement AddFile(String groups, String file, PBXSourceTree sourceTree)
        {
            lock (this.syncRoot) {
                // Prepare the group that will contain the file
                PBXGroup         group         = this.GetGroup(groups);
                PBXFileReference fileReference = null;
                PBXFileElement   result        = null;

                // Extract information
                String name    = Path.GetFileName(file);
                String path    = Path.GetFullPath(file);
                String rootDir = Path.GetFullPath(this.Dir);
                if (!String.IsNullOrEmpty(this.BaseDir))
                {
                    rootDir = Path.Combine(rootDir, this.BaseDir);
                    rootDir = Path.GetFullPath(rootDir);
                }
                String parentDir = Path.GetDirectoryName(file);

                // If the file is localized, then add it to a variant group
                if (Path.GetExtension(parentDir).Equals(".lproj"))
                {
                    // The variant group may exists to search for it
                    PBXVariantGroup variantGroup = group.FindVariantGroup(name);
                    if (variantGroup == null)
                    {
                        variantGroup = new PBXVariantGroup(name);
                        group.AddChild(variantGroup);
                    }

                    // The file is named like the language
                    name   = Path.GetFileNameWithoutExtension(parentDir);
                    group  = variantGroup;
                    result = variantGroup;
                }

                // Check if the file already exists
                fileReference = group.FindFileReference(name);
                if (fileReference == null)
                {
                    // Create a file reference
                    fileReference = new PBXFileReference(name);

                    // Set the source tree if none specified
                    if (sourceTree != PBXSourceTree.None)
                    {
                        fileReference.SourceTree = sourceTree;
                    }
                    else
                    {
                        if (path.StartsWith(rootDir))
                        {
                            path = path.Substring(rootDir.Length + 1);
                            fileReference.SourceTree = PBXSourceTree.Group;
                        }
                        else
                        {
                            fileReference.SourceTree = PBXSourceTree.Absolute;
                        }
                    }
                    fileReference.Path = path;
                    fileReference.LastKnownFileType = GetFileType(file);

                    // Add it to the group
                    group.AddChild(fileReference);
                }

                return(result ?? fileReference);
            }
        }
예제 #13
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "PBXBuildFile" /> class.
 /// </summary>
 /// <param name = "fileRef">The file ref.</param>
 public PBXBuildFile(PBXFileElement fileRef)
 {
     this.FileRef = fileRef;
 }