Inheritance: UnityEditor.XCodeEditor.PBXObject
Beispiel #1
0
        public void AddEmbedFramework(string fileName)
        {
            Debug.Log("Add Embed Framework: " + fileName);

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

            if (fileReference == null)
            {
                Debug.Log("Embed Framework must added already: " + fileName);
                return;
            }

            var embedPhase = this.AddEmbedFrameworkBuildPhase();

            if (embedPhase == null)
            {
                Debug.Log("AddEmbedFrameworkBuildPhase Failed.");
                return;
            }

            //create a build file
            PBXBuildFile buildFile = new PBXBuildFile(fileReference);

            buildFile.AddCodeSignOnCopy();
            buildFiles.Add(buildFile);

            embedPhase.AddBuildFile(buildFile);
        }
Beispiel #2
0
        private void BuildAddFile(PBXFileReference fileReference, KeyValuePair <string, PBXResourcesBuildPhase> currentObject, bool weak)
        {
            PBXBuildFile buildFile = new PBXBuildFile(fileReference, weak);

            buildFiles.Add(buildFile);
            currentObject.Value.AddBuildFile(buildFile);
        }
Beispiel #3
0
        public void BuildAddFile(PBXFileReference fileReference, KeyValuePair <string, PBXFrameworksBuildPhase> currentObject, bool weak)
        {
            PBXBuildFile buildFile = new PBXBuildFile(fileReference, weak);

            buildFiles.Add(buildFile);
            currentObject.Value.AddBuildFile(buildFile);
        }
Beispiel #4
0
 public bool AddBuildFile( PBXBuildFile file )
 {
     if( !ContainsKey( FILES_KEY ) ){
         this.Add( FILES_KEY, new PBXList() );
     }
     ((PBXList)_data[ FILES_KEY ]).Add( file.guid );
     return true;
 }
 public bool AddBuildFile(PBXBuildFile file)
 {
     if (!ContainsKey(FILES_KEY))
     {
         this.Add(FILES_KEY, new PBXList());
     }
     ((PBXList)_data[FILES_KEY]).Add(file.guid);
     return(true);
 }
        public bool AddBuildFile( PBXBuildFile file )
        {
            //			if( ((string)file[ ISA_KEY ]).CompareTo( "PBXBuildFile" ) != 0 )
            //				return false;
            //			Debug.Log( "--> buildphase " + (string)_data[ ISA_KEY ] );

            if( !ContainsKey( FILES_KEY ) ){
            //				Debug.Log( "key not present" );
                this.Add( FILES_KEY, new PBXList() );
            }
            //			Debug.Log( "key: " + _data[ FILES_KEY ] );
            //			Debug.Log( "Adding: " + file.guid );
            ((PBXList)_data[ FILES_KEY ]).Add( file.guid );
            //			if( ((PBXList)_data[ FILES_KEY ]).Contains( file.guid ) ) {
            //				Debug.Log( "AGGIUNTO" );
            //			}
            //			else {
            //				Debug.Log( "MANCA" );
            //			}

            return true;
        }
Beispiel #7
0
        public void AddRegionPath()
        {
            string srcDir = Application.dataPath + "/Editor/XUPorter/Mods/ios/localname/Supporting Files/";
            string tgtDir = projectRootPath + "/Unity-iPhone Tests/";

            //this.projectRootPath
            CopyRegionDirectory(srcDir, tgtDir, true);

            string plistfile_guid = "";

            foreach (var item in variantGroups)
            {
                if (item.Value.name.CompareTo("InfoPlist.strings") == 0)
                {
                    plistfile_guid = item.Value.guid;
                }
            }

            PBXBuildFile buildFile = null;

            foreach (KeyValuePair <string, PBXBuildFile> current in buildFiles)
            {
//				Debug.Log(current.Value.fileRef+"==="+plistfile_guid);
                if (!string.IsNullOrEmpty(current.Value.fileRef) && current.Value.fileRef.CompareTo(plistfile_guid) == 0)
                {
//					Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>==="+plistfile_guid);
                    buildFile = current.Value;
                }
            }


            foreach (var item in resourcesBuildPhases)
            {
                item.Value.AddBuildFile(buildFile);
                break;
            }
        }
Beispiel #8
0
        public bool AddBuildFile(PBXBuildFile file)
        {
//			if( ((string)file[ ISA_KEY ]).CompareTo( "PBXBuildFile" ) != 0 )
//				return false;
//			Debug.Log( "--> buildphase " + (string)_data[ ISA_KEY ] );


            if (!ContainsKey(FILES_KEY))
            {
//				Debug.Log( "key not present" );
                this.Add(FILES_KEY, new PBXList());
            }
//			Debug.Log( "key: " + _data[ FILES_KEY ] );
//			Debug.Log( "Adding: " + file.guid );
            ((PBXList)_data[FILES_KEY]).Add(file.guid);
//			if( ((PBXList)_data[ FILES_KEY ]).Contains( file.guid ) ) {
//				Debug.Log( "AGGIUNTO" );
//			}
//			else {
//				Debug.Log( "MANCA" );
//			}

            return(true);
        }
Beispiel #9
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.Replace("Assets", ""), filePath);
            }

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


            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) && File.Exists(absPath) && tree.CompareTo("SOURCE_ROOT") == 0)
                    {
                        //CustomDebug.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);
                        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 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
			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 void AddEmbedFramework( string fileName)
        {
            Debug.Log( "Add Embed Framework: " + fileName );

            //Check if there is already a file
            PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( fileName ) );
            if( fileReference == null ) {
                Debug.Log("Embed Framework must added already: " + fileName);
                return;
            }

            var embedPhase = this.AddEmbedFrameworkBuildPhase();
            if (embedPhase == null)
            {
                Debug.Log("AddEmbedFrameworkBuildPhase Failed.");
                return;
            }

            //create a build file
            PBXBuildFile buildFile = new PBXBuildFile( fileReference );
            buildFile.AddCodeSignOnCopy();
            buildFiles.Add( buildFile );

            embedPhase.AddBuildFile(buildFile);
        }
Beispiel #12
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.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);
                        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
        }
Beispiel #13
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
        }
Beispiel #14
0
        public static string AddNewBuildFile(IIgorModule ModuleInst, string ProjectPath, string FileRefGUID)
        {
            if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach(KeyValuePair<string, PBXBuildFile> CurrentBuildFile in CurrentProject.buildFiles)
                {
                    if(IgorAssert.EnsureTrue(ModuleInst, CurrentBuildFile.Value.ContainsKey("fileRef"), "PBXBuildFile doesn't contain a key for fileRef."))
                    {
                        if(CurrentBuildFile.Value.data["fileRef"] == FileRefGUID)
                        {
                            IgorDebug.Log(ModuleInst, "The file GUID " + FileRefGUID + " already has an associated BuildFile in the XCodeProj.");

                            return CurrentBuildFile.Value.guid;
                        }
                    }
                }

                foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if(CurrentFileRef.Value.guid == FileRefGUID)
                    {
                        PBXBuildFile NewBuildFile = new PBXBuildFile(CurrentFileRef.Value);

                        CurrentProject.buildFiles.Add(NewBuildFile);

                        IgorDebug.Log(ModuleInst, "BuildFile for FileRefGUID " + FileRefGUID + " has been added to the XCodeProj.");

                        CurrentProject.Save();

                        return NewBuildFile.guid;
                    }
                }
            }

            return "";
        }
Beispiel #15
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();
        }
Beispiel #16
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 );
 }
Beispiel #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(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);
        }