Пример #1
0
        public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true )
        {
            if( !Directory.Exists( folderPath ) )
                return false;
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );

            if( exclude == null )
                exclude = new string[] {};

            //PBXDictionary results = new PBXDictionary();

            if( parent == null )
                parent = rootGroup;

            // Create group
            PBXGroup newGroup = GetGroup( sourceDirectoryInfo.Name, null /*relative path*/, parent );
            //			groups.Add( newGroup );

            foreach( string directory in Directory.GetDirectories( folderPath ) )
            {
            //				special_folders = ['.bundle', '.framework', '.xcodeproj']
                Debug.Log( "DIR: " + directory );
                if( directory.EndsWith( ".bundle" ) ) {
                    // Treath it like a file and copy even if not recursive
                    Debug.LogWarning( "This is a special folder: " + directory );
                    AddFile( directory, newGroup, "SOURCE_ROOT", createBuildFile );
                    Debug.Log( "fatto" );
                    continue;
                }

                if( recursive ) {
                    Debug.Log( "recursive" );
                    AddFolder( directory, newGroup, exclude, recursive, createBuildFile );
                }
            }

            // Adding files.
            string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
            foreach( string file in Directory.GetFiles( folderPath ) ) {
                if( Regex.IsMatch( file, regexExclude ) ) {
                    continue;
                }
            //				Debug.Log( "--> " + file + ", " + newGroup );
                AddFile( file, newGroup, "SOURCE_ROOT", createBuildFile );
            }

            modified = true;
            return modified;
            //		def add_folder(self, os_path, parent=None, excludes=None, recursive=True, create_build_files=True):
            //        if not os.path.isdir(os_path):
            //            return []
            //
            //        if not excludes:
            //            excludes = []
            //
            //        results = []
            //
            //        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)
            //
            //        path_dict = {os.path.split(os_path)[0]:parent}
            //        special_list = []
            //
            //        for (grp_path, subdirs, files) in os.walk(os_path):
            //            parent_folder, folder_name = os.path.split(grp_path)
            //            parent = path_dict.get(parent_folder, parent)
            //
            //            if [sp for sp in special_list if parent_folder.startswith(sp)]:
            //                continue
            //
            //            if folder_name.startswith('.'):
            //                special_list.append(grp_path)
            //                continue
            //
            //            if os.path.splitext(grp_path)[1] in XcodeProject.special_folders:
            //                # if this file has a special extension (bundle or framework mainly) treat it as a file
            //                special_list.append(grp_path)
            //
            //                new_files = self.verify_files([folder_name], parent=parent)
            //
            //                if new_files:
            //                    results.extend(self.add_file(grp_path, parent, create_build_files=create_build_files))
            //
            //                continue
            //
            //            # create group
            //            grp = self.get_or_create_group(folder_name, path=self.get_relative_path(grp_path) , parent=parent)
            //            path_dict[grp_path] = grp
            //
            //            results.append(grp)
            //
            //            file_dict = {}
            //
            //            for f in files:
            //                if f[0] == '.' or [m for m in excludes if re.match(m,f)]:
            //                    continue
            //
            //                kwds = {
            //                    'create_build_files': create_build_files,
            //                    'parent': grp,
            //                    'name': f
            //                }
            //
            //                f_path = os.path.join(grp_path, f)
            //
            //                file_dict[f_path] = kwds
            //
            //            new_files = self.verify_files([n.get('name') for n in file_dict.values()], parent=grp)
            //
            //            add_files = [(k,v) for k,v in file_dict.items() if v.get('name') in new_files]
            //
            //            for path, kwds in add_files:
            //                kwds.pop('name', None)
            //
            //                self.add_file(path, **kwds)
            //
            //            if not recursive:
            //                break
            //
            //        for r in results:
            //            self.objects[r.id] = r
            //
            //        return results
        }
Пример #2
0
        public XCProject(string filePath) : this()
        {
            if (!System.IO.Directory.Exists(filePath))
            {
                Debug.LogWarning("Path does not exists.");
                return;
            }

            if (filePath.EndsWith(".xcodeproj"))
            {
                Debug.Log("Opening project " + filePath);
                this.projectRootPath = Path.GetDirectoryName(filePath);
                this.filePath        = filePath;
            }
            else
            {
                Debug.Log("Looking for xcodeproj files in " + filePath);
                string[] projects = System.IO.Directory.GetDirectories(filePath, "*.xcodeproj");
                if (projects.Length == 0)
                {
                    Debug.LogWarning("Error: missing xcodeproj file");
                    return;
                }

                this.projectRootPath = filePath;
                this.filePath        = projects[0];
            }

            projectFileInfo = new FileInfo(Path.Combine(this.filePath, "project.pbxproj"));
            string contents = projectFileInfo.OpenText().ReadToEnd();

            PBXParser parser = new PBXParser();

            _datastore = parser.Decode(contents);
            if (_datastore == null)
            {
                throw new System.Exception("Project file not found at file path " + filePath);
            }

            if (!_datastore.ContainsKey("objects"))
            {
                Debug.Log("Errore " + _datastore.Count);
                return;
            }

            _objects = (PBXDictionary)_datastore["objects"];
            modified = false;

            _rootObjectKey = (string)_datastore["rootObject"];
            if (!string.IsNullOrEmpty(_rootObjectKey))
            {
                _project   = new PBXProject(_rootObjectKey, (PBXDictionary)_objects[_rootObjectKey]);
                _rootGroup = new PBXGroup(_rootObjectKey, (PBXDictionary)_objects[_project.mainGroupID]);
            }
            else
            {
                Debug.LogWarning("error: project has no root object");
                _project   = null;
                _rootGroup = null;
            }
        }
Пример #3
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
        }
Пример #4
0
        public XCProject( string filePath )
            : this()
        {
            if( !System.IO.Directory.Exists( filePath ) ) {
                Debug.LogWarning( "Path does not exists." );
                return;
            }

            if( filePath.EndsWith( ".xcodeproj" ) ) {
                Debug.Log( "Opening project " + filePath );
                this.projectRootPath = Path.GetDirectoryName( filePath );
                this.filePath = filePath;
            } else {
                Debug.Log( "Looking for xcodeproj files in " + filePath );
                string[] projects = System.IO.Directory.GetDirectories( filePath, "*.xcodeproj" );
                if( projects.Length == 0 ) {
                    Debug.LogWarning( "Error: missing xcodeproj file" );
                    return;
                }

                this.projectRootPath = filePath;
                this.filePath = projects[ 0 ];
            }

            projectFileInfo = new FileInfo( Path.Combine( this.filePath, "project.pbxproj" ) );
            string contents = projectFileInfo.OpenText().ReadToEnd();

            PBXParser parser = new PBXParser();
            _datastore = parser.Decode( contents );
            if( _datastore == null ) {
                throw new System.Exception( "Project file not found at file path " + filePath );
            }

            if( !_datastore.ContainsKey( "objects" ) ) {
                Debug.Log( "Errore " + _datastore.Count );
                return;
            }

            _objects = (PBXDictionary)_datastore["objects"];
            modified = false;

            _rootObjectKey = (string)_datastore["rootObject"];
            if( !string.IsNullOrEmpty( _rootObjectKey ) ) {
                _project = new PBXProject( _rootObjectKey, (PBXDictionary)_objects[ _rootObjectKey ] );
                _rootGroup = new PBXGroup( _rootObjectKey, (PBXDictionary)_objects[ _project.mainGroupID ] );
            }
            else {
                Debug.LogWarning( "error: project has no root object" );
                _project = null;
                _rootGroup = null;
            }
        }
Пример #5
0
        public bool AddFolder(string folderPath, string rootModPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true)
        {
            if (!Directory.Exists(folderPath))
            {
                return(false);
            }
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(folderPath);

            if (exclude == null)
            {
                exclude = new string[] {}
            }
            ;


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

            //Do not create a new group if we are adding the root directory of the current parent
            PBXGroup newGroup = parent;

            if (folderPath != rootModPath)
            {
                newGroup = GetGroup(sourceDirectoryInfo.Name, null /*relative path*/, parent);
            }

            foreach (string directory in Directory.GetDirectories(folderPath))
            {
                if (directory.EndsWith(".bundle"))
                {
                    // Treath it like a file and copy even if not recursive
                    Debug.LogWarning("This is a special folder: " + directory);
                    AddFile(directory, newGroup, "SOURCE_ROOT", createBuildFile);
                    continue;
                }

                if (recursive)
                {
                    Debug.Log("recursive");
                    AddFolder(directory, rootModPath, newGroup, exclude, recursive, createBuildFile);
                }
            }

            // Adding files.
            string regexExclude = string.Format(@"{0}", string.Join("|", exclude));

            foreach (string file in Directory.GetFiles(folderPath))
            {
                if (Regex.IsMatch(file, regexExclude))
                {
                    continue;
                }
                AddFile(file, newGroup, "SOURCE_ROOT", createBuildFile);
            }


            modified = true;
            return(modified);
        }
Пример #6
0
        public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true )
        {
            Debug.Log("Folder PATH: "+folderPath);
            if( !Directory.Exists( folderPath ) ){
                Debug.Log("Directory doesn't exist?");
                return false;
            }

            if (folderPath.EndsWith(".lproj")){
                Debug.Log("Ended with .lproj");
                return AddLocFolder(folderPath, parent, exclude, createBuildFile);
            }

             			DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );

             			if( exclude == null ){
                Debug.Log("Exclude was null");
             				exclude = new string[] {};
            }

             			if( parent == null ){
                Debug.Log("Parent was null");
             				parent = rootGroup;
            }

            // Create group
            PBXGroup newGroup = GetGroup( sourceDirectoryInfo.Name, null /*relative path*/, parent );
            Debug.Log("New Group created");

            foreach( string directory in Directory.GetDirectories( folderPath ) ) {
                Debug.Log( "DIR: " + directory );
                if( directory.EndsWith( ".bundle" ) ) {
                    // Treat it like a file and copy even if not recursive
                    // TODO also for .xcdatamodeld?
                    Debug.LogWarning( "This is a special folder: " + directory );
                    AddFile( directory, newGroup, "SOURCE_ROOT", createBuildFile );
                    continue;
                }

                if( recursive ) {
                    Debug.Log( "recursive" );
                    AddFolder( directory, newGroup, exclude, recursive, createBuildFile );
                }
            }

            // Adding files.
            string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
            foreach( string file in Directory.GetFiles( folderPath ) ) {
                if( Regex.IsMatch( file, regexExclude ) ) {
                    continue;
                }
                Debug.Log("Adding Files for Folder");
                AddFile( file, newGroup, "SOURCE_ROOT", createBuildFile );
            }

            modified = true;
            return modified;
        }
Пример #7
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;
        }
Пример #8
0
		public PBXDictionary AddFile( string filePath, string compilerFlags ,PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false )
		{
			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( filePath + "  Path is Rooted" );
				absPath = filePath;
			}
			else if( tree.CompareTo( "SDKROOT" ) != 0) {
				absPath = Path.Combine( Application.dataPath, filePath );
			}

			Debug.Log ("XCProject AddFile absPath: " + absPath);
			
			if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
				Debug.Log( "XCProject AddFile Missing file: " + filePath );
				return results;
			}
			else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
				Debug.Log( "XCProject AddFile 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( "XCProject AddFile Group File" );
				
				filePath = System.IO.Path.GetFileName( filePath );
			}

			if( parent == null ) {
				parent = _rootGroup;
			}
			
			Debug.Log ("XCProject AddFile filePath1 : " + filePath);
			
			//Check if there is already a file
			string fileName = System.IO.Path.GetFileName( filePath );
			
			Debug.Log ("XCProject AddFile filePath2 : " + filePath);

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

				if (System.IO.Path.GetExtension(filePath) == ".mm")
				{
					DetachRefFile(fileName);
				}
				else
				{
					return null;
				}
			}
			
			fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) )
			{
				compilerFlags = compilerFlags
			};

			Debug.Log("fileReference: " + fileReference.path);
			
			parent.AddChild( fileReference );
			fileReferences.Add( fileReference );
			results.Add( fileReference.guid, fileReference );
			
			//Create a build file for reference
			if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles )
			{
				Debug.Log("XCProject AddFile 3" + fileReference.buildPhase);
				
				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;
		}
Пример #9
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 = CombinePaths("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);
                    string   completePath = CombinePaths("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 = CombinePaths(mod.path, filePath);
                    this.AddFile(absoluteFilePath, modGroup);
                }
            }

            if (mod.folders != null)
            {
                Debug.Log("Adding folders...");

                foreach (string folderPath in mod.folders)
                {
                    string absoluteFolderPath = CombinePaths(Application.dataPath, 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 = CombinePaths(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);
                }
            }

            this.Consolidate();
        }
        public bool AddFolder(string folderPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true)
        {
            if (!Directory.Exists(folderPath))
            {
                return(false);
            }
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(folderPath);

            if (exclude == null)
            {
                exclude = new string[] {}
            }
            ;
            string regexExclude = string.Format(@"{0}", string.Join("|", exclude));

            PBXDictionary results = new PBXDictionary();

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

            // Create group
            PBXGroup newGroup = GetGroup(sourceDirectoryInfo.Name, null /*relative path*/, parent);

//			groups.Add( newGroup );

            foreach (string directory in Directory.GetDirectories(folderPath))
            {
                if (Regex.IsMatch(directory, regexExclude))
                {
                    continue;
                }

//				special_folders = ['.bundle', '.framework', '.xcodeproj']
                Debug.Log("DIR: " + directory);
                if (directory.EndsWith(".bundle"))
                {
                    // Treath it like a file and copy even if not recursive
                    Debug.LogWarning("This is a special folder: " + directory);
                    AddFile(directory, newGroup, "SOURCE_ROOT", createBuildFile);
                    Debug.Log("fatto");
                    continue;
                }

                if (recursive)
                {
                    Debug.Log("recursive");
                    AddFolder(directory, newGroup, exclude, recursive, createBuildFile);
                }
            }
            // Adding files.
            foreach (string file in Directory.GetFiles(folderPath))
            {
                if (Regex.IsMatch(file, regexExclude))
                {
                    continue;
                }
                //Debug.Log( "--> " + file + ", " + newGroup );
                AddFile(file, newGroup, "SOURCE_ROOT", createBuildFile);
            }

            modified = true;
            return(modified);
//		def add_folder(self, os_path, parent=None, excludes=None, recursive=True, create_build_files=True):
//        if not os.path.isdir(os_path):
//            return []
//
//        if not excludes:
//            excludes = []
//
//        results = []
//
//        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)
//
//        path_dict = {os.path.split(os_path)[0]:parent}
//        special_list = []
//
//        for (grp_path, subdirs, files) in os.walk(os_path):
//            parent_folder, folder_name = os.path.split(grp_path)
//            parent = path_dict.get(parent_folder, parent)
//
//            if [sp for sp in special_list if parent_folder.startswith(sp)]:
//                continue
//
//            if folder_name.startswith('.'):
//                special_list.append(grp_path)
//                continue
//
//            if os.path.splitext(grp_path)[1] in XcodeProject.special_folders:
//                # if this file has a special extension (bundle or framework mainly) treat it as a file
//                special_list.append(grp_path)
//
//                new_files = self.verify_files([folder_name], parent=parent)
//
//                if new_files:
//                    results.extend(self.add_file(grp_path, parent, create_build_files=create_build_files))
//
//                continue
//
//            # create group
//            grp = self.get_or_create_group(folder_name, path=self.get_relative_path(grp_path) , parent=parent)
//            path_dict[grp_path] = grp
//
//            results.append(grp)
//
//            file_dict = {}
//
//            for f in files:
//                if f[0] == '.' or [m for m in excludes if re.match(m,f)]:
//                    continue
//
//                kwds = {
//                    'create_build_files': create_build_files,
//                    'parent': grp,
//                    'name': f
//                }
//
//                f_path = os.path.join(grp_path, f)
//
//                file_dict[f_path] = kwds
//
//            new_files = self.verify_files([n.get('name') for n in file_dict.values()], parent=grp)
//
//            add_files = [(k,v) for k,v in file_dict.items() if v.get('name') in new_files]
//
//            for path, kwds in add_files:
//                kwds.pop('name', None)
//
//                self.add_file(path, **kwds)
//
//            if not recursive:
//                break
//
//        for r in results:
//            self.objects[r.id] = r
//
//        return results
        }
        public PBXGroup GetGroup(string name, string path = null, PBXGroup parent = null)
        {
//			Debug.Log( "GetGroup: " + name + ", " + path + ", " + parent );
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

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

            foreach (KeyValuePair <string, PBXGroup> current in groups)
            {
//				Debug.Log( "current: " + current.Value.guid + ", " + current.Value.name + ", " + current.Value.path + " - " + parent.HasChild( current.Key ) );
                if (string.IsNullOrEmpty(current.Value.name))
                {
                    if (current.Value.path.CompareTo(name) == 0 && parent.HasChild(current.Key))
                    {
                        return(current.Value);
                    }
                }
                else if (current.Value.name.CompareTo(name) == 0 && parent.HasChild(current.Key))
                {
                    return(current.Value);
                }
            }

            PBXGroup result = new PBXGroup(name, path);

            groups.Add(result);
            parent.AddChild(result);

            modified = true;
            return(result);

//		def get_or_create_group(self, name, path=None, parent=None):
//        if not name:
//            return None
//
//        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)
//
//        groups = self.get_groups_by_name(name)
//
//        for grp in groups:
//            if parent.has_child(grp.id):
//                return grp
//
//        grp = PBXGroup.Create(name, path)
//        parent.add_child(grp)
//
//        self.objects[grp.id] = grp
//
//        self.modified = True
//
//        return grp
        }
//		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, string compileFlag = " ")
        {
            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.Replace("Assets", ""), filePath);
//				Debug.Log( "RElative: " + absPath );
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
                Debug.Log("Missing file: " + absPath + " > " + filePath);
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0 || tree.CompareTo("GROUP") == 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) && File.Exists(absPath) && tree.CompareTo("SOURCE_ROOT") == 0)
                    {
                        //Debug.LogError(absPath);
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddLibrarySearchPaths(new PBXList(libraryPath));
                    }
                    else if (!string.IsNullOrEmpty(absPath) && Directory.Exists(absPath) && absPath.EndsWith(".framework") && tree.CompareTo("GROUP") == 0)                                 // Annt: Add framework search path for FacebookSDK
                    {
                        string frameworkPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddFrameworkSearchPaths(new PBXList(frameworkPath));
                    }
                    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);
                        //add by suyuancheng
                        if (!compileFlag.Equals(" "))
                        {
                            buildFile.AddCompilerFlag(compileFlag);
                        }
                        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
        }
        public void ApplyMod(XCMod mod)
        {
            PBXGroup modGroup = this.GetGroup(mod.group);

            Debug.Log("Adding libraries...");
            PBXGroup librariesGroup = this.GetGroup("Libraries");

            foreach (XCModFile libRef in mod.libs)
            {
                string completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
                this.AddFile(completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak);
            }

            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);
            }

            Debug.Log("Adding files...");
//			foreach( string filePath in mod.files ) {
            //				string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath );
            //
            //
            //				if( filePath.EndsWith(".framework") )
            //					this.AddFile( absoluteFilePath, frameworkGroup, "GROUP", true, false);
            //				else
            //					this.AddFile( absoluteFilePath, modGroup );
            //			}

            //add by suyuancheng

            foreach (XCModSourceFile filePath in mod.files)
            {
                string absoluteFilePath = System.IO.Path.Combine(mod.path, filePath.filePath);
                //	Debug.Log("============================file path:"+filePath.filePath);
                //	Debug.Log("============================flag:"+filePath.compileFlag);

                if (filePath.filePath.EndsWith(".framework"))
                {
                    this.AddFile(absoluteFilePath, frameworkGroup, "GROUP", true, false);
                }
                else
                {
                    this.AddFile(absoluteFilePath, modGroup, "SOURCE_ROOT", true, false, filePath.compileFlag);
                }
            }

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

            Debug.Log("Adding headerpaths...");
            foreach (string headerpath in mod.headerpaths)
            {
                string absoluteHeaderPath = System.IO.Path.Combine(mod.path, headerpath);
                this.AddHeaderSearchPaths(absoluteHeaderPath);
            }

            Debug.Log("Configure build settings...");
            Hashtable buildSettings = mod.buildSettings;

            if (buildSettings.ContainsKey("OTHER_LDFLAGS"))
            {
                Debug.Log("    Adding other linker flags...");
                ArrayList otherLinkerFlags = (ArrayList)buildSettings["OTHER_LDFLAGS"];
                foreach (string linker in otherLinkerFlags)
                {
                    string _linker = linker;
                    if (!_linker.StartsWith("-"))
                    {
                        _linker = "-" + _linker;
                    }
                    this.AddOtherLDFlags(_linker);
                }
            }

            if (buildSettings.ContainsKey("GCC_ENABLE_CPP_EXCEPTIONS"))
            {
                Debug.Log("    GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"]);
                this.GccEnableCppExceptions((string)buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"]);
            }

            if (buildSettings.ContainsKey("GCC_ENABLE_OBJC_EXCEPTIONS"))
            {
                Debug.Log("    GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"]);
                this.GccEnableObjCExceptions((string)buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"]);
            }

            this.Consolidate();
        }
Пример #14
0
        public void ApplyMod(XCMod mod)
        {
            PBXGroup modGroup = this.GetGroup(mod.group);

            foreach (XCModFile libRef in mod.libs)
            {
                string completeLibPath;
                if (libRef.sourceTree.Equals("SDKROOT"))
                {
                    completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
                    PBXGroup libraryGroup = GetGroup("Libraries");
                    this.AddFile(completeLibPath, libraryGroup, libRef.sourceTree, true, libRef.isWeak);
                }
                else
                {
                    completeLibPath = System.IO.Path.Combine(mod.path, libRef.filePath);
                    this.AddFile(completeLibPath, modGroup, libRef.sourceTree, true, libRef.isWeak);
                }
            }

            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);
            }

            foreach (string filePath in mod.files)
            {
                string absoluteFilePath = System.IO.Path.Combine(mod.path, filePath);
                this.AddFile(absoluteFilePath, modGroup);
            }

            foreach (string folderPath in mod.folders)
            {
                string absoluteFolderPath = System.IO.Path.Combine(mod.path, folderPath);
                absoluteFolderPath = System.IO.Path.GetFullPath(absoluteFolderPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                this.AddFolder(absoluteFolderPath, mod.path, modGroup, mod.excludes.ToArray(), false /*recursive*/);
            }


            foreach (string headerpath in mod.headerpaths)
            {
                string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, headerpath));
                this.AddHeaderSearchPaths(absoluteHeaderPath);
            }

            foreach (string librarypath in mod.librarysearchpaths)
            {
                string absolutePath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, librarypath));
                this.AddLibrarySearchPaths(absolutePath);
            }

            if (mod.frameworksearchpath != null)
            {
                foreach (string frameworksearchpath in mod.frameworksearchpath)
                {
                    string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, frameworksearchpath));
                    this.AddFrameworkSearchPaths(absoluteHeaderPath);
                }
            }

            this.Consolidate();
        }
Пример #15
0
        public PBXGroup GetGroup( string name, string path = null, PBXGroup parent = null )
        {
            //			Debug.Log( "GetGroup: " + name + ", " + path + ", " + parent );
            if( string.IsNullOrEmpty( name ) )
                return null;

            if( parent == null )
                parent = rootGroup;

            foreach( KeyValuePair<string, PBXGroup> current in groups ) {

            //				Debug.Log( "current: " + current.Value.guid + ", " + current.Value.name + ", " + current.Value.path + " - " + parent.HasChild( current.Key ) );
                if( string.IsNullOrEmpty( current.Value.name ) ) {
                    if( current.Value.path.CompareTo( name ) == 0 && parent.HasChild( current.Key ) ) {
                        return current.Value;
                    }
                }
                else if( current.Value.name.CompareTo( name ) == 0 && parent.HasChild( current.Key ) ) {
                    return current.Value;
                }
            }

            PBXGroup result = new PBXGroup( name, path );
            groups.Add( result );
            parent.AddChild( result );

            modified = true;
            return result;

            //		def get_or_create_group(self, name, path=None, parent=None):
            //        if not name:
            //            return None
            //
            //        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)
            //
            //        groups = self.get_groups_by_name(name)
            //
            //        for grp in groups:
            //            if parent.has_child(grp.id):
            //                return grp
            //
            //        grp = PBXGroup.Create(name, path)
            //        parent.add_child(grp)
            //
            //        self.objects[grp.id] = grp
            //
            //        self.modified = True
            //
            //        return grp
        }
Пример #16
0
        public bool AddFolder(string folderPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true)
        {
            Debug.Log("Folder PATH: " + folderPath);
            if (!Directory.Exists(folderPath))
            {
                Debug.Log("Directory doesn't exist?");
                return(false);
            }

            if (folderPath.EndsWith(".lproj"))
            {
                Debug.Log("Ended with .lproj");
                return(AddLocFolder(folderPath, parent, exclude, createBuildFile));
            }

            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(folderPath);

            if (exclude == null)
            {
                Debug.Log("Exclude was null");
                exclude = new string[] {};
            }

            if (parent == null)
            {
                Debug.Log("Parent was null");
                parent = rootGroup;
            }

            // Create group
            PBXGroup newGroup = GetGroup(sourceDirectoryInfo.Name, null /*relative path*/, parent);

            Debug.Log("New Group created");

            foreach (string directory in Directory.GetDirectories(folderPath))
            {
                Debug.Log("DIR: " + directory);
                if (directory.EndsWith(".bundle"))
                {
                    // Treat it like a file and copy even if not recursive
                    // TODO also for .xcdatamodeld?
                    Debug.LogWarning("This is a special folder: " + directory);
                    AddFile(directory, newGroup, "SOURCE_ROOT", createBuildFile);
                    continue;
                }

                if (recursive)
                {
                    Debug.Log("recursive");
                    AddFolder(directory, newGroup, exclude, recursive, createBuildFile);
                }
            }

            // Adding files.
            string regexExclude = string.Format(@"{0}", string.Join("|", exclude));

            foreach (string file in Directory.GetFiles(folderPath))
            {
                if (Regex.IsMatch(file, regexExclude))
                {
                    continue;
                }
                Debug.Log("Adding Files for Folder");
                AddFile(file, newGroup, "SOURCE_ROOT", createBuildFile);
            }

            modified = true;
            return(modified);
        }
Пример #17
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;

		}
Пример #18
0
        public void ApplyMod(XCMod mod)
        {
            PBXGroup modGroup = this.GetGroup(mod.group);

            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);
            }

            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);
            }

            Debug.Log("Adding files...");
            foreach (string filePath in mod.files)
            {
                string absoluteFilePath = System.IO.Path.Combine(mod.path, filePath);
                this.AddFile(absoluteFilePath, modGroup);
            }

            Debug.Log("Adding embed binaries...");
            if (mod.embed_binaries != null)
            {
                //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);
                }
            }

            Debug.Log("Adding folders...");
            foreach (string folderPath in mod.folders)
            {
                string absoluteFolderPath = System.IO.Path.Combine(Application.dataPath, folderPath);
                Debug.Log("Adding folder " + absoluteFolderPath);
                this.AddFolder(absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray(typeof(string)));
            }

            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);
                }
            }

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

            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);

            this.Consolidate();
        }
Пример #19
0
        // We support neither recursing into nor bundles contained inside loc folders
        public bool AddLocFolder( string folderPath, PBXGroup parent = null, string[] exclude = null, bool createBuildFile = true)
        {
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );

            if( exclude == null )
                exclude = new string[] {};

            if( parent == null )
                parent = rootGroup;

            // Create group as needed
            System.Uri projectFolderURI = new System.Uri( projectFileInfo.DirectoryName );
            System.Uri locFolderURI = new System.Uri( folderPath );
            var relativePath = projectFolderURI.MakeRelativeUri( locFolderURI ).ToString();
            PBXGroup newGroup = GetGroup( sourceDirectoryInfo.Name, relativePath, parent );

            // Add loc region to project
            string nom = sourceDirectoryInfo.Name;
            string region = nom.Substring(0, nom.Length - ".lproj".Length);
            project.AddRegion(region);

            // Adding files.
            string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
            foreach( string file in Directory.GetFiles( folderPath ) ) {
                if( Regex.IsMatch( file, regexExclude ) ) {
                    continue;
                }

                // Add a variant group for the language as well
                var variant = new PBXVariantGroup(System.IO.Path.GetFileName( file ), null, "GROUP");
                variantGroups.Add(variant);

                // The group gets a reference to the variant, not to the file itself
                newGroup.AddChild(variant);

                AddFile( file, variant, "GROUP", createBuildFile );
            }

            modified = true;
            return modified;
        }
Пример #20
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;
        }
Пример #21
0
        public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclude = null, bool recursive = true, bool createBuildFile = true )
        {
            if( !Directory.Exists( folderPath ) )
                return false;
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );

            if( exclude == null )
                exclude = new string[] {};

            if( parent == null )
                parent = rootGroup;

            // Create group
            PBXGroup newGroup = GetGroup( sourceDirectoryInfo.Name, null /*relative path*/, parent );

            foreach( string directory in Directory.GetDirectories( folderPath ) ) {
                Debug.Log( "DIR: " + directory );
                if( directory.EndsWith( ".bundle" ) ) {
                    // Treath it like a file and copy even if not recursive
                    Debug.LogWarning( "This is a special folder: " + directory );
                    AddFile( directory, newGroup, "SOURCE_ROOT", createBuildFile );
                    continue;
                }

                if( recursive ) {
                    Debug.Log( "recursive" );
                    AddFolder( directory, newGroup, exclude, recursive, createBuildFile );
                }
            }

            // Adding files.
            string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
            foreach( string file in Directory.GetFiles( folderPath ) ) {
                if( Regex.IsMatch( file, regexExclude ) ) {
                    continue;
                }
                AddFile( file, newGroup, "SOURCE_ROOT", createBuildFile );
            }

            modified = true;
            return modified;
        }
Пример #22
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) && 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)
                    {
                        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);
        }
Пример #23
0
        public PBXGroup GetGroup( string name, string path = null, PBXGroup parent = null )
        {
            if( string.IsNullOrEmpty( name ) )
                return null;

            if( parent == null ) parent = rootGroup;

            foreach( KeyValuePair<string, PBXGroup> current in groups ) {
                if( string.IsNullOrEmpty( current.Value.name ) ) {
                    if( current.Value.path.CompareTo( name ) == 0 && parent.HasChild( current.Key ) ) {
                        return current.Value;
                    }
                } else if( current.Value.name.CompareTo( name ) == 0 && parent.HasChild( current.Key ) ) {
                    return current.Value;
                }
            }

            PBXGroup result = new PBXGroup( name, path );
            groups.Add( result );
            parent.AddChild( result );

            modified = true;
            return result;
        }
Пример #24
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 (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
            String           filename      = System.IO.Path.GetFileName(filePath);
            PBXFileReference fileReference = GetFile(filename);

            if (fileReference != null)
            {
                //Srong reference always taks precedence over weak reference
                if (!weak)
                {
                    PBXBuildFile buildFile = GetBuildFile(fileReference.guid);
                    if (buildFile != null)
                    {
                        buildFile.SetWeakLink(weak);
                    }
                }
                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);
        }