Inheritance: UnityEditor.XCodeEditor.PBXObject
Ejemplo n.º 1
0
		public PBXBuildFile( PBXFileReference fileRef, bool weak = false ) : base()
		{
			this.Add( FILE_REF_KEY, fileRef.guid );
			SetWeakLink( weak );
			
			if (!string.IsNullOrEmpty(fileRef.compilerFlags))
			{
				foreach (var flag in fileRef.compilerFlags.Split(','))
					AddCompilerFlag(flag);
			}
		}
        public PBXBuildFile( PBXFileReference fileRef, bool weak = false )
            : base()
        {
            this.Add( FILE_REF_KEY, fileRef.guid );
            SetWeakLink( weak );

            //    def Create(cls, file_ref, weak=False):
            //        if isinstance(file_ref, PBXFileReference):
            //            file_ref = file_ref.id
            //
            //        bf = cls()
            //        bf.id = cls.GenerateId()
            //        bf['fileRef'] = file_ref
            //
            //        if weak:
            //            bf.set_weak_link(True)
            //
            //        return bf
        }
Ejemplo n.º 3
0
 public PBXBuildFile( PBXFileReference fileRef, bool weak = false )
     : base()
 {
     this.Add( FILE_REF_KEY, fileRef.guid );
     SetWeakLink( weak );
 }
Ejemplo n.º 4
0
		public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false )
		{
			PBXDictionary results = new PBXDictionary();
			string absPath = string.Empty;

			if( Path.IsPathRooted( filePath ) ) {
				absPath = filePath;
			}
			else if( tree.CompareTo( "SDKROOT" ) != 0) {
				absPath = Path.Combine(Path.GetFullPath(Application.dataPath), filePath);
			}

			if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
				System.Uri fileURI = new System.Uri( absPath );
				System.Uri rootURI = new System.Uri( ( projectRootPath + "/." ) );
				filePath = rootURI.MakeRelativeUri( fileURI ).ToString();
			}

			if( parent == null ) {
				parent = _rootGroup;
			}

			// TODO: Aggiungere controllo se file già presente
			PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( filePath ) );
			if( fileReference != null ) {
				return null;
			}

			fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) );
			parent.AddChild( fileReference );
			fileReferences.Add( fileReference );
			results.Add( fileReference.guid, fileReference );

			//Create a build file for reference
			if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {
				PBXBuildFile buildFile;
				switch( fileReference.buildPhase ) {
					case "PBXFrameworksBuildPhase":
						foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
							buildFile = new PBXBuildFile( fileReference, weak );
							buildFiles.Add( buildFile );
							currentObject.Value.AddBuildFile( buildFile );
						}
						if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) && File.Exists( absPath ) ) {
							string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
							this.AddLibrarySearchPaths( new PBXList( libraryPath ) );
						}
						break;
					case "PBXResourcesBuildPhase":
						foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
							buildFile = new PBXBuildFile( fileReference, weak );
							buildFiles.Add( buildFile );
							currentObject.Value.AddBuildFile( buildFile );
						}
						break;
					case "PBXShellScriptBuildPhase":
						foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
							buildFile = new PBXBuildFile( fileReference, weak );
							buildFiles.Add( buildFile );
							currentObject.Value.AddBuildFile( buildFile );
						}
						break;
					case "PBXSourcesBuildPhase":
						foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
							buildFile = new PBXBuildFile( fileReference, weak );
							buildFiles.Add( buildFile );
							currentObject.Value.AddBuildFile( buildFile );
						}
						break;
					case "PBXCopyFilesBuildPhase":
						foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
							buildFile = new PBXBuildFile( fileReference, weak );
							buildFiles.Add( buildFile );
							currentObject.Value.AddBuildFile( buildFile );
						}
						break;
					case null:
						Debug.LogWarning( "fase non supportata null" );
						break;
					default:
						Debug.LogWarning( "fase non supportata def" );
						return null;
				}
			}

			return results;

		}
Ejemplo n.º 5
0
        //        public PBXDictionary<PBXBuildPhase> GetBuildPhase( string buildPhase )
        //        {
        //            switch( buildPhase ) {
        //                case "PBXFrameworksBuildPhase":
        //                    return (PBXDictionary<PBXBuildPhase>)frameworkBuildPhases;
        //                case "PBXResourcesBuildPhase":
        //                    return (PBXDictionary<PBXBuildPhase>)resourcesBuildPhases;
        //                case "PBXShellScriptBuildPhase":
        //                    return (PBXDictionary<PBXBuildPhase>)shellScriptBuildPhases;
        //                case "PBXSourcesBuildPhase":
        //                    return (PBXDictionary<PBXBuildPhase>)sourcesBuildPhases;
        //                case "PBXCopyFilesBuildPhase":
        //                    return (PBXDictionary<PBXBuildPhase>)copyBuildPhases;
        //                default:
        //                    return default(T);
        //            }
        //        }
        public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false )
        {
            PBXDictionary results = new PBXDictionary();
            string absPath = string.Empty;

            if( Path.IsPathRooted( filePath ) ) {
                absPath = filePath;
            //				Debug.Log( "Is rooted: " + absPath );
            }
            else if( tree.CompareTo( "SDKROOT" ) != 0) {
                absPath = Path.Combine( Application.dataPath, filePath );
            //				Debug.Log( "RElative: " + absPath );
            }

            if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
                Debug.Log( "Missing file: " + filePath );
                return results;
            }
            else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
                System.Uri fileURI = new System.Uri( absPath );
                System.Uri rootURI = new System.Uri( ( projectRootPath + "/." ) );
                filePath = rootURI.MakeRelativeUri( fileURI ).ToString();
            }
            //			else {
            //				tree = "<absolute>";
            //				Debug.Log( "3: " + filePath );
            //			}
            //			Debug.Log( "Add file result path: " + filePath );

            if( parent == null ) {
                parent = _rootGroup;
            }

            // TODO: Aggiungere controllo se file già presente
            PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( filePath ) );
            if( fileReference != null ) {
            //				Debug.Log( "File già presente." );
                return null;
            }

            fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) );
            parent.AddChild( fileReference );
            fileReferences.Add( fileReference );
            results.Add( fileReference.guid, fileReference );

            //Create a build file for reference
            if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {
            //				PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase );
                PBXBuildFile buildFile;
                switch( fileReference.buildPhase ) {
                    case "PBXFrameworksBuildPhase":
                        foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
                            buildFile = new PBXBuildFile( fileReference, weak );
                            buildFiles.Add( buildFile );
                            currentObject.Value.AddBuildFile( buildFile );
                        }
                        if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) && (Directory.Exists( absPath ) || File.Exists( absPath )) ) {
                            string searchPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
                            if(filePath.IndexOf(".framework") != -1) {
                                this.AddFrameworkSearchPaths( new PBXList( searchPath ) );
                            }
                            else {
                                this.AddLibrarySearchPaths( new PBXList( searchPath ) );
                            }
                        }
                        break;
                    case "PBXResourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
                            buildFile = new PBXBuildFile( fileReference, weak );
                            buildFiles.Add( buildFile );
                            currentObject.Value.AddBuildFile( buildFile );
                        }
                        break;
                    case "PBXShellScriptBuildPhase":
                        foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
                            buildFile = new PBXBuildFile( fileReference, weak );
                            buildFiles.Add( buildFile );
                            currentObject.Value.AddBuildFile( buildFile );
                        }
                        break;
                    case "PBXSourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
                            buildFile = new PBXBuildFile( fileReference, weak );
                            buildFiles.Add( buildFile );
                            currentObject.Value.AddBuildFile( buildFile );
                        }
                        break;
                    case "PBXCopyFilesBuildPhase":
                        foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
                            buildFile = new PBXBuildFile( fileReference, weak );
                            buildFiles.Add( buildFile );
                            currentObject.Value.AddBuildFile( buildFile );
                        }
                        break;
                    case null:
                        Debug.LogWarning( "fase non supportata null" );
                        break;
                    default:
                        Debug.LogWarning( "fase non supportata def" );
                        return null;
                }
            }

            //			Debug.Log( "Results " + results.Count + " - " );
            //			foreach( KeyValuePair<string, object> obj in results ){
            //				Debug.Log( obj.Key + " - " + obj.Value.GetType().Name );
            //			}
            return results;

            //		def add_file(self, f_path, parent=None, tree='SOURCE_ROOT', create_build_files=True, weak=False):
            //        results = []
            //
            //        abs_path = ''
            //
            //        if os.path.isabs(f_path):
            //            abs_path = f_path
            //
            //            if not os.path.exists(f_path):
            //                return results
            //            elif tree == 'SOURCE_ROOT':
            //                f_path = os.path.relpath(f_path, self.source_root)
            //            else:
            //                tree = '<absolute>'
            //
            //        if not parent:
            //            parent = self.root_group
            //        elif not isinstance(parent, PBXGroup):
            //            # assume it's an id
            //            parent = self.objects.get(parent, self.root_group)
            //
            //        file_ref = PBXFileReference.Create(f_path, tree)
            //        parent.add_child(file_ref)
            //        results.append(file_ref)
            //        # create a build file for the file ref
            //        if file_ref.build_phase and create_build_files:
            //            phases = self.get_build_phases(file_ref.build_phase)
            //
            //            for phase in phases:
            //                build_file = PBXBuildFile.Create(file_ref, weak=weak)
            //
            //                phase.add_build_file(build_file)
            //                results.append(build_file)
            //
            //            if abs_path and tree == 'SOURCE_ROOT' and os.path.isfile(abs_path)\
            //                and file_ref.build_phase == 'PBXFrameworksBuildPhase':
            //
            //                library_path = os.path.join('$(SRCROOT)', os.path.split(f_path)[0])
            //
            //                self.add_library_search_paths([library_path], recursive=False)
            //
            //        for r in results:
            //            self.objects[r.id] = r
            //
            //        if results:
            //            self.modified = True
            //
            //        return results
        }
Ejemplo n.º 6
0
        public static string AddNewFileReference(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if(CurrentFileRef.Value.name == Filename)
                    {
                        IgorDebug.Log(ModuleInst, "The file " + Filename + " is already referenced in the XCodeProj.");

                        return CurrentFileRef.Value.guid;
                    }
                }

                PBXFileReference NewFile = new PBXFileReference(Filename, TreeBase);

                if(Path != "")
                {
                    if(NewFile.ContainsKey("path"))
                    {
                        NewFile.Remove("path");
                    }

                    NewFile.Add("path", Path);
                }

                if(FileEncoding != -1)
                {
                    if(NewFile.ContainsKey("fileEncoding"))
                    {
                        NewFile.Remove("fileEncoding");
                    }

                    NewFile.Add("fileEncoding", FileEncoding);
                }

                if(LastKnownFileType != "")
                {
                    if(NewFile.ContainsKey("lastKnownFileType"))
                    {
                        NewFile.Remove("lastKnownFileType");
                    }

                    NewFile.Add("lastKnownFileType", LastKnownFileType);
                }

                if(Name != "")
                {
                    if(NewFile.ContainsKey("name"))
                    {
                        NewFile.Remove("name");
                    }

                    NewFile.Add("name", Name);
                }

                CurrentProject.fileReferences.Add(NewFile);

                IgorDebug.Log(ModuleInst, "File " + Filename + " has been added to the XCodeProj.");

                CurrentProject.Save();

                return NewFile.guid;
            }

            return "";
        }
Ejemplo n.º 7
0
        public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string compilerFlags = "")
        {
            //Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );

            var pathExplode = filePath.Split(':');

            if (pathExplode.Length > 1)
            {
                filePath = pathExplode[0];
                compilerFlags = pathExplode[1];
            }

            PBXDictionary results = new PBXDictionary();
            if (filePath == null) {
                Debug.LogError ("AddFile called with null filePath");
                return results;
            }

            string absPath = string.Empty;

            if( Path.IsPathRooted( filePath ) ) {
                absPath = filePath;
            }
            else if( tree.CompareTo( "SDKROOT" ) != 0) {
                absPath = Path.Combine( Application.dataPath, filePath );
            }

            if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
                Debug.Log( "Missing file: " + filePath );
                return results;
            }
            else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
                System.Uri fileURI = new System.Uri( absPath );
                System.Uri rootURI = new System.Uri( ( projectRootPath + "/." ) );
                filePath = rootURI.MakeRelativeUri( fileURI ).ToString();
            }

            if( parent == null ) {
                parent = _rootGroup;
            }

            //Check if there is already a file
            PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( filePath ) );
            if( fileReference != null ) {
                Debug.Log("File already exists: " + filePath); //not a warning, because this is normal for most builds!
                return null;
            }

            fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) );
            fileReference.compilerFlags = compilerFlags;
            parent.AddChild( fileReference );
            fileReferences.Add( fileReference );
            results.Add( fileReference.guid, fileReference );

            //Create a build file for reference
            if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {

                switch( fileReference.buildPhase ) {
                    case "PBXFrameworksBuildPhase":
                        foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 )) {
                            string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
                            if (File.Exists(absPath)) {
                                this.AddLibrarySearchPaths( new PBXList( libraryPath ) );
                            } else {
                                this.AddFrameworkSearchPaths( new PBXList( libraryPath ) );
                            }

                        }
                        break;
                    case "PBXResourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXShellScriptBuildPhase":
                        foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXSourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXCopyFilesBuildPhase":
                        foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case null:
                        Debug.LogWarning( "File Not Supported: " + filePath );
                        break;
                    default:
                        Debug.LogWarning( "File Not Supported." );
                        return null;
                }
            }
            return results;
        }
Ejemplo n.º 8
0
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string compilerFlag = null)
        {
            //Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );

            PBXDictionary results = new PBXDictionary();

            if (filePath == null)
            {
                Debug.LogError("AddFile called with null filePath");
                return(results);
            }

            string absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                Debug.Log("Path is Rooted");
                absPath = filePath;
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Application.dataPath, filePath);
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
                Debug.Log("Missing file: " + filePath);
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
                //Debug.Log( "Source Root File" );
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }
            else if (tree.CompareTo("GROUP") == 0)
            {
                Debug.Log("Group File");
                filePath = System.IO.Path.GetFileName(filePath);
            }

            if (parent == null)
            {
                parent = _rootGroup;
            }

            //Check if there is already a file
            PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath));

            if (fileReference != null)
            {
                Debug.LogWarning("File is already exists: " + filePath);
                return(null);
            }
            //to do............................................... folder file with same name

            fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            if (compilerFlag != null)
            {
                fileReference.compilerFlags = compilerFlag;
            }
            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        if (File.Exists(absPath))
                        {
                            this.AddLibrarySearchPaths(new PBXList(libraryPath));
                        }
                        else
                        {
                            this.AddFrameworkSearchPaths(new PBXList(libraryPath));
                        }
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        //Debug.Log( "Adding Resources Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        //Debug.Log( "Adding Script Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        //Debug.Log( "Adding Source Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        //Debug.Log( "Adding Copy Files Build Phase" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case null:
                    Debug.LogWarning("File Not Supported: " + filePath);
                    break;

                default:
                    Debug.LogWarning("File Not Supported.");
                    return(null);
                }
            }
            return(results);
        }
Ejemplo n.º 9
0
 public PBXBuildFile(PBXFileReference fileRef, bool weak = false) : base()
 {
     this.Add(FILE_REF_KEY, fileRef.guid);
     SetWeakLink(weak);
 }
Ejemplo n.º 10
0
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false,
                                     // Kanglai: for `InfoPlist.string`, ignore same name
                                     bool ignoreSameFilename = true)
        {
            //Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );

            PBXDictionary results = new PBXDictionary();

            if (filePath == null)
            {
                Debug.LogError("AddFile called with null filePath");
                return(results);
            }

            string absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                Debug.Log("Path is Rooted");
                absPath = filePath;
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                // Application.dataPath: `D:\Projects\unity-playground\Assets`
                // filePath: `Assets/Plugins/iOS/xxx`
                string parentPath = Application.dataPath;
                parentPath = parentPath.Substring(0, parentPath.Length - 7);
                absPath    = Path.Combine(parentPath, filePath);
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
                Debug.Log("Missing file: " + filePath);
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
                Debug.Log("Source Root File");
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }
            else if (tree.CompareTo("GROUP") == 0)
            {
                Debug.Log("Group File");
                filePath = System.IO.Path.GetFileName(filePath);
            }

            if (parent == null)
            {
                parent = _rootGroup;
            }

            //Check if there is already a file
            PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath));

            if (ignoreSameFilename && fileReference != null)
            {
                Debug.Log("File already exists: " + filePath);                 //not a warning, because this is normal for most builds!
                return(null);
            }

            fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        if (File.Exists(absPath))
                        {
                            this.AddLibrarySearchPaths(new PBXList(libraryPath));
                        }
                        else
                        {
                            this.AddFrameworkSearchPaths(new PBXList(libraryPath));
                        }
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        Debug.Log("Adding Resources Build File");
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        Debug.Log("Adding Script Build File");
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        Debug.Log("Adding Source Build File");
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        Debug.Log("Adding Copy Files Build Phase");
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case null:
                    Debug.LogWarning("File Not Supported: " + filePath);
                    break;

                default:
                    Debug.LogWarning("File Not Supported.");
                    return(null);
                }
            }
            return(results);
        }
Ejemplo n.º 11
0
        public void ApplyMod(XCMod mod)
        {
            PBXGroup modGroup = this.GetGroup(mod.group);

            if (mod.libs != null)
            {
                Debug.Log("Adding libraries...");
                foreach (XCModFile libRef in mod.libs)
                {
                    string completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
                    Debug.Log("Adding library " + completeLibPath);
                    this.AddFile(completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak);
                }
            }

            if (mod.frameworks != null)
            {
                Debug.Log("Adding frameworks...");
                PBXGroup frameworkGroup = this.GetGroup("Frameworks");
                foreach (string framework in mod.frameworks)
                {
                    string[] filename     = framework.Split(':');
                    bool     isWeak       = (filename.Length > 1) ? true : false;
                    string   completePath = System.IO.Path.Combine("System/Library/Frameworks", filename[0]);
                    this.AddFile(completePath, frameworkGroup, "SDKROOT", true, isWeak);
                }
            }

            if (mod.files != null)
            {
                Debug.Log("Adding files...");
                foreach (string filePath in mod.files)
                {
                    string absoluteFilePath = combinePathWithCheck(mod.path, filePath);
                    this.AddFile(absoluteFilePath, modGroup);
                }
            }

            if (mod.embed_binaries != null)
            {
                Debug.Log("Adding embed binaries...");
                //1. Add LD_RUNPATH_SEARCH_PATHS for embed framework
                this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Release");
                this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Debug");

                foreach (string binary in mod.embed_binaries)
                {
                    string absoluteFilePath = System.IO.Path.Combine(mod.path, binary);
                    this.AddEmbedFramework(absoluteFilePath);
                }
            }

            if (mod.folders != null)
            {
                Debug.Log("Adding folders...");
                foreach (string folderPath in mod.folders)
                {
                    string parentPath = Application.dataPath;
                    parentPath = parentPath.Substring(0, parentPath.Length - 7);

                    string absoluteFolderPath = System.IO.Path.Combine(parentPath, System.IO.Path.Combine(mod.path, folderPath));
                    Debug.Log("Adding folder " + absoluteFolderPath);
                    this.AddFolder(absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray(typeof(string)));
                }
            }

            if (mod.headerpaths != null)
            {
                Debug.Log("Adding headerpaths...");
                foreach (string headerpath in mod.headerpaths)
                {
                    if (headerpath.Contains("$(inherited)"))
                    {
                        Debug.Log("not prepending a path to " + headerpath);
                        this.AddHeaderSearchPaths(headerpath);
                    }
                    else
                    {
                        string absoluteHeaderPath = System.IO.Path.Combine(mod.path, headerpath);
                        this.AddHeaderSearchPaths(absoluteHeaderPath);
                    }
                }
            }

            if (mod.compiler_flags != null)
            {
                Debug.Log("Adding compiler flags...");
                foreach (string flag in mod.compiler_flags)
                {
                    this.AddOtherCFlags(flag);
                }
            }

            if (mod.linker_flags != null)
            {
                Debug.Log("Adding linker flags...");
                foreach (string flag in mod.linker_flags)
                {
                    this.AddOtherLinkerFlags(flag);
                }
            }

            Debug.Log("Adding plist items...");
            string  plistPath = this.projectRootPath + "/Info.plist";
            XCPlist plist     = new XCPlist(plistPath);

            plist.Process(mod.plist);

            // Kanglai: for localization
            if (mod.variants != null)
            {
                foreach (string variantPath in mod.variants)
                {
                    string absoluteFolderPath = System.IO.Path.Combine(mod.path, variantPath);
                    if (!Directory.Exists(absoluteFolderPath))
                    {
                        Debug.LogWarning("VariantGroup: folder not exists");
                        continue;
                    }
                    DirectoryInfo directory   = new DirectoryInfo(absoluteFolderPath);
                    string        variantName = directory.Name;

                    var variant = new PBXVariantGroup(variantName, null, "GROUP");
                    // mark variants
                    variantGroups.Add(variant);
                    // add variant to project
                    _rootGroup.AddChild(variant);
                    // add variant in build process
                    PBXBuildFile buildFile = new PBXBuildFile(variant);
                    buildFiles.Add(buildFile);
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        currentObject.Value.AddBuildFile(buildFile);
                    }

                    foreach (var dir in directory.GetDirectories())
                    {
                        string dirName = dir.Name;
                        int    split   = dirName.Length - 6;
                        if (split <= 0 || !dirName.Substring(split).Equals(".lproj"))
                        {
                            Debug.LogWarning("VariantGroup: folder should end with .lproj");
                            continue;
                        }
                        string languangeName   = dirName.Substring(0, split);
                        string variantFilePath = System.IO.Path.Combine(dir.FullName, variantName);
                        if (!File.Exists(variantFilePath))
                        {
                            Debug.LogWarning("VariantGroup: file under folder not exists");
                            continue;
                        }

                        var result = AddFile(variantFilePath, variant, createBuildFiles: false, ignoreSameFilename: false);
                        PBXFileReference fileReference = (PBXFileReference)result.Values.First();
                        fileReference.Remove("name");
                        fileReference.Add("name", languangeName);
                    }
                }
            }

            this.Consolidate();
        }
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false)
        {
            PBXDictionary results = new PBXDictionary();
            string        absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                absPath = filePath;
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Path.GetFullPath(Application.dataPath), filePath);
            }

            if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }

            if (parent == null)
            {
                parent = _rootGroup;
            }

            // TODO: Aggiungere controllo se file già presente
            PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath));

            if (fileReference != null)
            {
                return(null);
            }

            fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
                PBXBuildFile buildFile;
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0) && File.Exists(absPath))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddLibrarySearchPaths(new PBXList(libraryPath));
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case null:
                    Debug.LogWarning("fase non supportata null");
                    break;

                default:
                    Debug.LogWarning("fase non supportata def");
                    return(null);
                }
            }

            return(results);
        }
//		public PBXDictionary<PBXBuildPhase> GetBuildPhase( string buildPhase )
//		{
//			switch( buildPhase ) {
//				case "PBXFrameworksBuildPhase":
//					return (PBXDictionary<PBXBuildPhase>)frameworkBuildPhases;
//				case "PBXResourcesBuildPhase":
//					return (PBXDictionary<PBXBuildPhase>)resourcesBuildPhases;
//				case "PBXShellScriptBuildPhase":
//					return (PBXDictionary<PBXBuildPhase>)shellScriptBuildPhases;
//				case "PBXSourcesBuildPhase":
//					return (PBXDictionary<PBXBuildPhase>)sourcesBuildPhases;
//				case "PBXCopyFilesBuildPhase":
//					return (PBXDictionary<PBXBuildPhase>)copyBuildPhases;
//				default:
//					return default(T);
//			}
//		}

        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false)
        {
            PBXDictionary results = new PBXDictionary();
            string        absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                absPath = filePath;
//				Debug.Log( "Is rooted: " + absPath );
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Application.dataPath, filePath);
//				Debug.Log( "RElative: " + absPath );
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
                Debug.Log("Missing file: " + filePath);
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }
//			else {
//				tree = "<absolute>";
//				Debug.Log( "3: " + filePath );
//			}
//			Debug.Log( "Add file result path: " + filePath );

            if (parent == null)
            {
                parent = _rootGroup;
            }

            // TODO: Aggiungere controllo se file già presente
            PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath));

            if (fileReference != null)
            {
//				Debug.Log( "File già presente." );
                return(null);
            }

            fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
//				PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase );
                PBXBuildFile buildFile;
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0) && File.Exists(absPath))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddLibrarySearchPaths(new PBXList(libraryPath));
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case null:
                    Debug.LogWarning("fase non supportata null");
                    break;

                default:
                    Debug.LogWarning("fase non supportata def");
                    return(null);
                }
            }

//			Debug.Log( "Results " + results.Count + " - " );
//			foreach( KeyValuePair<string, object> obj in results ){
//				Debug.Log( obj.Key + " - " + obj.Value.GetType().Name );
//			}
            return(results);

//		def add_file(self, f_path, parent=None, tree='SOURCE_ROOT', create_build_files=True, weak=False):
//        results = []
//
//        abs_path = ''
//
//        if os.path.isabs(f_path):
//            abs_path = f_path
//
//            if not os.path.exists(f_path):
//                return results
//            elif tree == 'SOURCE_ROOT':
//                f_path = os.path.relpath(f_path, self.source_root)
//            else:
//                tree = '<absolute>'
//
//        if not parent:
//            parent = self.root_group
//        elif not isinstance(parent, PBXGroup):
//            # assume it's an id
//            parent = self.objects.get(parent, self.root_group)
//
//        file_ref = PBXFileReference.Create(f_path, tree)
//        parent.add_child(file_ref)
//        results.append(file_ref)
//        # create a build file for the file ref
//        if file_ref.build_phase and create_build_files:
//            phases = self.get_build_phases(file_ref.build_phase)
//
//            for phase in phases:
//                build_file = PBXBuildFile.Create(file_ref, weak=weak)
//
//                phase.add_build_file(build_file)
//                results.append(build_file)
//
//            if abs_path and tree == 'SOURCE_ROOT' and os.path.isfile(abs_path)\
//                and file_ref.build_phase == 'PBXFrameworksBuildPhase':
//
//                library_path = os.path.join('$(SRCROOT)', os.path.split(f_path)[0])
//
//                self.add_library_search_paths([library_path], recursive=False)
//
//        for r in results:
//            self.objects[r.id] = r
//
//        if results:
//            self.modified = True
//
//        return results
        }
Ejemplo n.º 14
0
        private bool SerializeDictionary(Dictionary <string, object> dictionary, StringBuilder builder, bool readable = false, int indent = 0)
        {
            builder.Append(DICTIONARY_BEGIN_TOKEN);
            if (readable && dictionary.Count > 0)
            {
                Endline(builder);
            }

            foreach (KeyValuePair <string, object> pair in dictionary)
            {
                // output section banner if necessary
                if (readable && indent == 1)
                {
                    MarkSection(builder, pair.Value.GetType().Name);
                }

                // indent KEY
                if (readable)
                {
                    Indent(builder, indent + 1);
                }

                // KEY
                SerializeString(pair.Key, builder, false, readable);

                // output file name
                if (readable && pair.Value is PBXBuildFile)
                {
                    PBXFileReference fileRef = (PBXFileReference)dictionary[((PBXBuildFile)pair.Value).fileRef];
                    if (fileRef != null)
                    {
                        builder.Append(String.Format(" /* {0} */", fileRef.name != null ? fileRef.name : fileRef.path));
                    }
                }

                // =
                if (readable)
                {
                    builder.Append(" " + DICTIONARY_ASSIGN_TOKEN + " ");
                }
                else
                {
                    builder.Append(DICTIONARY_ASSIGN_TOKEN);
                }

                // VALUE
                // do not pretty-print PBXBuildFile or PBXFileReference as Xcode does
                SerializeValue(pair.Value, builder, (readable &&
                                                     (pair.Value.GetType() != typeof(PBXBuildFile)) &&
                                                     (pair.Value.GetType() != typeof(PBXFileReference))
                                                     ), indent + 1);

                // end statement
                builder.Append(DICTIONARY_ITEM_DELIMITER_TOKEN);

                if (readable)
                {
                    Endline(builder);
                }
            }

            // output last section banner
            if (readable && indent == 1)
            {
                MarkSection(builder, null);
            }

            // indent }
            if (readable && dictionary.Count > 0)
            {
                Indent(builder, indent);
            }

            builder.Append(DICTIONARY_END_TOKEN);

            return(true);
        }
Ejemplo n.º 15
0
        public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false )
        {
            PBXDictionary results = new PBXDictionary();
            string absPath = string.Empty;

            if( Path.IsPathRooted( filePath ) ) {
                absPath = filePath;
            }
            else if( tree.CompareTo( "SDKROOT" ) != 0) {
                absPath = Path.Combine( Application.dataPath, filePath );
            }

            if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
                Debug.Log( "Missing file: " + filePath );
                return results;
            }
            else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
                System.Uri fileURI = new System.Uri( absPath );
                System.Uri rootURI = new System.Uri( ( projectRootPath + "/." ) );
                filePath = rootURI.MakeRelativeUri( fileURI ).ToString();
            }

            if( parent == null ) {
                parent = _rootGroup;
            }

            //Check if there is already a file
            PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( filePath ) );
            if( fileReference != null ) {
                Debug.LogWarning("File is already exists: " + filePath);
                return null;
            }

            fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) );
            parent.AddChild( fileReference );
            fileReferences.Add( fileReference );
            results.Add( fileReference.guid, fileReference );

            //Create a build file for reference
            if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {

                switch( fileReference.buildPhase ) {
                    case "PBXFrameworksBuildPhase":
                        foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 )) {
                            string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
                            if (File.Exists(absPath)) {
                                this.AddLibrarySearchPaths( new PBXList( libraryPath ) );
                            } else {
                                this.AddFrameworkSearchPaths( new PBXList( libraryPath ) );
                            }

                        }
                        break;
                    case "PBXResourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXShellScriptBuildPhase":
                        foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXSourcesBuildPhase":
                        foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case "PBXCopyFilesBuildPhase":
                        foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
                            BuildAddFile(fileReference,currentObject,weak);
                        }
                        break;
                    case null:
                        Debug.LogWarning( "File Not Support: " + filePath );
                        break;
                    default:
                        Debug.LogWarning( "File Not Support." );
                        return null;
                }
            }
            return results;
        }
Ejemplo n.º 16
0
        public string ResolveName(string guid)
        {
            if (!this.objects.ContainsKey(guid))
            {
                Debug.LogWarning(this + " ResolveName could not resolve " + guid);
                return(string.Empty);                //"UNRESOLVED GUID:" + guid;
            }

            object entity = this.objects[guid];

            if (entity is PBXBuildFile)
            {
                return(ResolveName(((PBXBuildFile)entity).fileRef));
            }
            else if (entity is PBXFileReference)
            {
                PBXFileReference casted = (PBXFileReference)entity;
                return(casted.name != null ? casted.name : casted.path);
            }
            else if (entity is PBXGroup)
            {
                PBXGroup casted = (PBXGroup)entity;
                return(casted.name != null ? casted.name : casted.path);
            }
            else if (entity is PBXProject || guid == this.rootObject)
            {
                return("Project object");
            }
            else if (entity is PBXFrameworksBuildPhase)
            {
                return("Frameworks");
            }
            else if (entity is PBXResourcesBuildPhase)
            {
                return("Resources");
            }
            else if (entity is PBXShellScriptBuildPhase)
            {
                return("ShellScript");
            }
            else if (entity is PBXSourcesBuildPhase)
            {
                return("Sources");
            }
            else if (entity is PBXCopyFilesBuildPhase)
            {
                return("CopyFiles");
            }
            else if (entity is XCConfigurationList)
            {
                XCConfigurationList casted = (XCConfigurationList)entity;
                //Debug.LogWarning ("XCConfigurationList " + guid + " " + casted.ToString());

                if (casted.data.ContainsKey("defaultConfigurationName"))
                {
                    //Debug.Log ("XCConfigurationList " + (string)casted.data[ "defaultConfigurationName" ] + " " + guid);
                    return((string)casted.data["defaultConfigurationName"]);
                }

                return(null);
            }
            else if (entity is PBXNativeTarget)
            {
                PBXNativeTarget obj = (PBXNativeTarget)entity;
                //Debug.LogWarning ("PBXNativeTarget " + guid + " " + obj.ToString());

                if (obj.data.ContainsKey("name"))
                {
                    //Debug.Log ("PBXNativeTarget " + (string)obj.data[ "name" ] + " " + guid);
                    return((string)obj.data["name"]);
                }

                return(null);
            }
            else if (entity is XCBuildConfiguration)
            {
                XCBuildConfiguration obj = (XCBuildConfiguration)entity;
                //Debug.LogWarning ("XCBuildConfiguration UNRESOLVED GUID:" + guid + " " + (obj==null?"":obj.ToString()));

                if (obj.data.ContainsKey("name"))
                {
                    //Debug.Log ("XCBuildConfiguration " + (string)obj.data[ "name" ] + " " + guid + " " + (obj==null?"":obj.ToString()));
                    return((string)obj.data["name"]);
                }
            }
            else if (entity is PBXObject)
            {
                PBXObject obj = (PBXObject)entity;

                if (obj.data.ContainsKey("name"))
                {
                    Debug.Log("PBXObject " + (string)obj.data["name"] + " " + guid + " " + (obj == null?"":obj.ToString()));
                }
                return((string)obj.data["name"]);
            }

            //return "UNRESOLVED GUID:" + guid;
            Debug.LogWarning("UNRESOLVED GUID:" + guid);
            return(null);
        }
Ejemplo n.º 17
0
 private void BuildAddFile(PBXFileReference fileReference, KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject,bool weak)
 {
     PBXBuildFile buildFile = new PBXBuildFile( fileReference, weak );
     buildFiles.Add( buildFile );
     currentObject.Value.AddBuildFile( buildFile );
 }
Ejemplo n.º 18
0
		private void BuildAddFile (PBXFileReference fileReference, KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject,bool weak)
		{
			PBXBuildFile buildFile = new PBXBuildFile( fileReference, weak );
			buildFiles.Add( buildFile );
			currentObject.Value.AddBuildFile( buildFile );
		}