示例#1
0
    public PBXBuildFile(string guid, PBXDictionary dictionary) : base(guid, dictionary)
    {
        if (!this.data.ContainsKey(SETTINGS_KEY))
        {
            return;
        }
        object settingsObj = this.data[SETTINGS_KEY];

        if (!(settingsObj is PBXDictionary))
        {
            return;
        }
        PBXDictionary settingsDict = (PBXDictionary) settingsObj;
        settingsDict.internalNewlines = false;

        if (!settingsDict.ContainsKey(ATTRIBUTES_KEY))
        {
            return;
        }
        object attributesObj = settingsDict[ATTRIBUTES_KEY];

        if (!(attributesObj is PBXList))
        {
            return;
        }

        PBXList attributesCast = (PBXList) attributesObj;
        attributesCast.internalNewlines = false;
    }
示例#2
0
    public XCProject(string filePath) : this()
    {
        if (!System.IO.Directory.Exists(filePath))
        {
            Debug.LogWarning("Path does not exists.");
            return;
        }

        if (filePath.EndsWith(".xcodeproj"))
        {
            this.projectRootPath = Path.GetDirectoryName(filePath);
            this.filePath = filePath;
        }
        else
        {
            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"));
        StreamReader sr = projectFileInfo.OpenText();
        string contents = sr.ReadToEnd();
        sr.Close();

        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;
        }
    }
		public void SetWeakLink( bool weak)
		{
			PBXDictionary settings = null;
			PBXList attributes = null;

			if (_data.ContainsKey (SETTINGS_KEY)) {
				settings = _data[SETTINGS_KEY] as PBXDictionary;
				if (settings.ContainsKey(ATTRIBUTES_KEY)) {
					attributes = settings[ATTRIBUTES_KEY] as PBXList;
				}
			}

			if (weak) {
				if (settings == null) {
					settings = new PBXDictionary();
					settings.internalNewlines = false;
					_data.Add(SETTINGS_KEY, settings);
				}

				if (attributes == null) {
					attributes = new PBXList();
					attributes.internalNewlines = false;
					attributes.Add(WEAK_VALUE);
					settings.Add(ATTRIBUTES_KEY, attributes);
				}
			}
			else {
				if(attributes != null  && attributes.Contains(WEAK_VALUE)) {
					attributes.Remove(WEAK_VALUE);
				}
			}
		}
示例#4
0
 public PBXObject()
 {
     _data = new PBXDictionary();
     _data[ISA_KEY] = this.GetType().Name;
     _guid = GenerateGuid();
     internalNewlines = false;
 }
示例#5
0
		public string Encode( PBXDictionary pbxData, bool readable = false )
		{
			StringBuilder builder = new StringBuilder( PBX_HEADER_TOKEN, BUILDER_CAPACITY );
			bool success = SerializeValue( pbxData, builder, readable );

			return ( success ? builder.ToString() : null );
		}
示例#6
0
    public bool SetWeakLink(bool weak = false)
    {
        PBXDictionary settings = null;
        PBXList attributes = null;

        if (!_data.ContainsKey(SETTINGS_KEY))
        {
            if (weak)
            {
                attributes = new PBXList();
                attributes.internalNewlines = false;
                attributes.Add(WEAK_VALUE);

                settings = new PBXDictionary();
                settings.Add(ATTRIBUTES_KEY, attributes);
                settings.internalNewlines = false;

                this.Add(SETTINGS_KEY, settings);
            }
            return true;
        }

        settings = _data[SETTINGS_KEY] as PBXDictionary;
        settings.internalNewlines = false;
        if (!settings.ContainsKey(ATTRIBUTES_KEY))
        {
            if (weak)
            {
                attributes = new PBXList();
                attributes.internalNewlines = false;
                attributes.Add(WEAK_VALUE);
                settings.Add(ATTRIBUTES_KEY, attributes);
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            attributes = settings[ATTRIBUTES_KEY] as PBXList;
        }

        attributes.internalNewlines = false;
        if (weak)
        {
            attributes.Add(WEAK_VALUE);
        }
        else
        {
            attributes.Remove(WEAK_VALUE);
        }

        settings.Add(ATTRIBUTES_KEY, attributes);
        this.Add(SETTINGS_KEY, settings);

        return true;
    }
示例#7
0
    public string Encode(PBXDictionary pbxData)
    {
        indent = 0;

        StringBuilder builder = new StringBuilder(PBX_HEADER_TOKEN, BUILDER_CAPACITY);
        bool success = SerializeValue(pbxData, builder);

        return (success ? builder.ToString() : null);
    }
示例#8
0
		public PBXObject( string guid, PBXDictionary dictionary ) : this( guid )
		{
			if( !dictionary.ContainsKey( ISA_KEY ) || ((string)dictionary[ ISA_KEY ]).CompareTo( this.GetType().Name ) != 0 )
				Debug.LogError( "PBXDictionary is not a valid ISA object" );
			
			foreach( KeyValuePair<string, object> item in dictionary ) {
				_data[ item.Key ] = item.Value;
			}
		}
示例#9
0
文件: XCProject.cs 项目: gmosdk/unity
        public XCProject( string filePath )
            : this()
        {
            if( !System.IO.Directory.Exists( filePath ) ) {
                Debug.LogWarning( "XCode project path does not exist: " + filePath );
                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;
                //if the path is relative to the project, we need to make it absolute
                if (!System.IO.Path.IsPathRooted(projectRootPath))
                    projectRootPath = Application.dataPath.Replace("Assets", "") + projectRootPath;
                //Debug.Log ("projectRootPath adjusted to " + projectRootPath);
                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;
            }
        }
示例#10
0
		public bool AddCompilerFlag( string flag )
		{
			if( !_data.ContainsKey( SETTINGS_KEY ) )
				_data[ SETTINGS_KEY ] = new PBXDictionary();
			
			if( !((PBXDictionary)_data[ SETTINGS_KEY ]).ContainsKey( COMPILER_FLAGS_KEY ) ) {
				((PBXDictionary)_data[ SETTINGS_KEY ]).Add( COMPILER_FLAGS_KEY, flag );
				return true;
			}
			
			string[] flags = ((string)((PBXDictionary)_data[ SETTINGS_KEY ])[ COMPILER_FLAGS_KEY ]).Split( ' ' );
			foreach( string item in flags ) {
				if( item.CompareTo( flag ) == 0 )
					return false;
			}
			
			((PBXDictionary)_data[ SETTINGS_KEY ])[ COMPILER_FLAGS_KEY ] = ( string.Join( " ", flags ) + " " + flag );
			return true;
		}
        //CodeSignOnCopy
        public bool AddCodeSignOnCopy()
        {
            if( !_data.ContainsKey( SETTINGS_KEY ) )
                _data[ SETTINGS_KEY ] = new PBXDictionary();

            var settings = _data[ SETTINGS_KEY ] as PBXDictionary;
            if( !settings.ContainsKey( ATTRIBUTES_KEY ) ) {
                var attributes = new PBXList();
                attributes.Add( "CodeSignOnCopy" );
                attributes.Add( "RemoveHeadersOnCopy" );
                settings.Add( ATTRIBUTES_KEY, attributes );
            }
            else {
                var attributes = settings[ ATTRIBUTES_KEY ] as PBXList;
                attributes.Add( "CodeSignOnCopy" );
                attributes.Add( "RemoveHeadersOnCopy" );
            }
            return true;
        }
示例#12
0
        public bool AddCompilerFlag( string flag )
        {
            if( !_data.ContainsKey( SETTINGS_KEY ) )
                _data[ SETTINGS_KEY ] = new PBXDictionary();

            if( !((PBXDictionary)_data[ SETTINGS_KEY ]).ContainsKey( COMPILER_FLAGS_KEY ) ) {
                ((PBXDictionary)_data[ SETTINGS_KEY ]).Add( COMPILER_FLAGS_KEY, flag );
                return true;
            }

            string[] flags = ((string)((PBXDictionary)_data[ SETTINGS_KEY ])[ COMPILER_FLAGS_KEY ]).Split( ' ' );
            foreach( string item in flags ) {
                if( item.CompareTo( flag ) == 0 )
                    return false;
            }

            ((PBXDictionary)_data[ SETTINGS_KEY ])[ COMPILER_FLAGS_KEY ] = ( string.Join( " ", flags ) + " " + flag );
            return true;

            //		def add_compiler_flag(self, flag):
            //        k_settings = 'settings'
            //        k_attributes = 'COMPILER_FLAGS'
            //
            //        if not self.has_key(k_settings):
            //            self[k_settings] = PBXDict()
            //
            //        if not self[k_settings].has_key(k_attributes):
            //            self[k_settings][k_attributes] = flag
            //            return True
            //
            //        flags = self[k_settings][k_attributes].split(' ')
            //
            //        if flag in flags:
            //            return False
            //
            //        flags.append(flag)
            //
            //        self[k_settings][k_attributes] = ' '.join(flags)
        }
示例#13
0
 public PBXContainerItemProxy(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
     internalNewlines = true;
 }
示例#14
0
 public PBXShellScriptBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
示例#15
0
 public PBXNativeTarget(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
     internalNewlines = true;
 }
示例#16
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;
        }
示例#17
0
        /// <summary>
        /// Saves a project after editing.
        /// </summary>
        public void Save()
        {
            PBXDictionary result = new PBXDictionary();
            result.Add( "archiveVersion", 1 );
            result.Add( "classes", new PBXDictionary() );
            result.Add( "objectVersion", 46 );

            Consolidate();
            result.Add( "objects", _objects );

            result.Add( "rootObject", _rootObjectKey );

            string projectPath = Path.Combine( this.filePath, "project.pbxproj" );

            // Delete old project file, in case of an IOException 'Sharing violation on path Error'
            DeleteExisting(projectPath);

            // Parse result object directly into file
            CreateNewProject(result,projectPath);
        }
示例#18
0
 public PBXProject(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
示例#19
0
        public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string[] compilerFlags = null )
        {
            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);
            if (filename.Contains("+")) {
                filename = string.Format ("\"{0}\"", filename);
            }

            PBXFileReference fileReference = GetFile(filename);

            if (fileReference != null) {
                //Weak references always taks precedence over strong reference
                if (weak) {
                    PBXBuildFile buildFile = GetBuildFile(fileReference.guid);
                    if(buildFile != null) {
                        buildFile.SetWeakLink(weak);
                    }
                }
                // Dear future me: If they ever invent a time machine, please don't come back in time to hunt me down.
                // From Unity 5, AdSupport is loaded dinamically, meaning that there will be a reference to the
                // file in the project and it won't add it to the linking libraries. And we need that.
                // TODO: The correct solution would be to check inside each phase if that file is already present.
                if (filename.Contains("AdSupport.framework")) {
                    if (string.IsNullOrEmpty(fileReference.buildPhase)) {
                        fileReference.buildPhase = "PBXFrameworksBuildPhase";
                    }
                } else {
                    return null;
                }

            }

            if (fileReference == 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 ) {
                            PBXBuildFile newBuildFile = GetBuildFile(fileReference.guid);
                            if (newBuildFile == null){
                                newBuildFile = new PBXBuildFile( fileReference, weak );
                                buildFiles.Add( newBuildFile );
                            }

                            if (currentObject.Value.HasBuildFile(newBuildFile.guid)) {
                                continue;
                            }
                            currentObject.Value.AddBuildFile( newBuildFile );

                        }
                        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 );
                            foreach (string flag in compilerFlags) {
                                buildFile.AddCompilerFlag(flag);
                            }
                            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;
        }
示例#20
0
文件: PBXGroup.cs 项目: gmosdk/unity
 public PBXGroup( string guid, PBXDictionary dictionary )
     : base(guid, dictionary)
 {
 }
示例#21
0
        public static void SetDevTeamID(IIgorModule ModuleInst, string ProjectPath, string DevTeamID)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                string ProjectGUID = CurrentProject.project.guid;

                object ProjectSectionObj = CurrentProject.GetObject(ProjectGUID);

                if (IgorAssert.EnsureTrue(ModuleInst, ProjectSectionObj != null, "Can't find Project Section in XCodeProj."))
                {
                    PBXDictionary ProjectSection = (PBXDictionary)ProjectSectionObj;

                    object AttributesSectionObj = ProjectSection["attributes"];

                    if (IgorAssert.EnsureTrue(ModuleInst, AttributesSectionObj != null, "Can't find Attributes Section in Project Section."))
                    {
                        object TargetAttributesObj = ((PBXDictionary)AttributesSectionObj)["TargetAttributes"];

                        if (IgorAssert.EnsureTrue(ModuleInst, TargetAttributesObj != null, "Can't find TargetAttributes Section in Attributes Section."))
                        {
                            PBXDictionary TargetAttributes = (PBXDictionary)TargetAttributesObj;

                            object TargetsObj = ProjectSection["targets"];

                            if (IgorAssert.EnsureTrue(ModuleInst, TargetsObj != null, "Can't find Targets Section in Project Section."))
                            {
                                PBXList TargetsList = ((PBXList)TargetsObj);

                                if (IgorAssert.EnsureTrue(ModuleInst, TargetsList.Count > 0, "No build targets defined in XCodeProj."))
                                {
                                    string PrimaryBuildTargetGUID = (string)(TargetsList[0]);

                                    PBXDictionary PrimaryBuildTargetToDevTeam = new PBXDictionary();
                                    PBXDictionary DevTeamIDDictionary         = new PBXDictionary();

                                    DevTeamIDDictionary.Add("DevelopmentTeam", DevTeamID);

                                    PrimaryBuildTargetToDevTeam.Add(PrimaryBuildTargetGUID, DevTeamIDDictionary);

                                    if (TargetAttributes.ContainsKey(PrimaryBuildTargetGUID))
                                    {
                                        object ExistingPrimaryBuildTargetObj = TargetAttributes[PrimaryBuildTargetGUID];

                                        if (ExistingPrimaryBuildTargetObj != null)
                                        {
                                            PBXDictionary ExistingPrimaryBuildTarget = (PBXDictionary)ExistingPrimaryBuildTargetObj;

                                            if (!ExistingPrimaryBuildTarget.ContainsKey("DevelopmentTeam"))
                                            {
                                                ExistingPrimaryBuildTarget.Append(DevTeamIDDictionary);

                                                IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                            }
                                            else
                                            {
                                                IgorDebug.Log(ModuleInst, "Development Team already set up in XCodeProj.");
                                            }
                                        }
                                        else
                                        {
                                            IgorDebug.LogError(ModuleInst, "Primary build target already has a key in TargetAttributes, but the value stored is invalid.");
                                        }
                                    }
                                    else
                                    {
                                        TargetAttributes.Append(PrimaryBuildTargetToDevTeam);

                                        IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                    }

                                    CurrentProject.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
示例#22
0
//      XCBuildConfigurationList buildConfigurations;
//      bool defaultConfigurationIsVisible = false;
//      string defaultConfigurationName;

        public XCConfigurationList(string guid, PBXDictionary dictionary) : base(guid, dictionary)
        {
        }
示例#23
0
    public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
    {
#if UNITY_5
        if (target != BuildTarget.iOS)
        {
#else
        if (target != BuildTarget.iOS)
        {
#endif
            Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
            return;
        }

        // Create a new project object from build target
        XCProject project = new XCProject(pathToBuiltProject);

        // Find and run through all projmods files to patch the project.
        // Please pay attention that ALL projmods files in your project folder will be excuted!
        string[] files = Directory.GetFiles(Application.dataPath, "*.projmods", SearchOption.AllDirectories);
        foreach (string file in files)
        {
            //Debug.Log("ProjMod File: " + file);
            //project.ApplyMod(file);

            ApplyMod(project, file);
        }

        ////TODO disable the bitcode for iOS 9
        //project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Release");
        //project.overwriteBuildSetting("ENABLE_BITCODE", "NO", "Debug");

        //关闭bitcode
        project.overwriteBuildSetting("ENABLE_BITCODE", "NO");

        //TODO implement generic settings as a module option
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: wang ke (LYDZ2B92D4)", "Release");
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: wang ke (LYDZ2B92D4)", "Debug");
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: client Tgame (8NK3ABPV64)", "Release");
        //project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: client Tgame (8NK3ABPV64)", "Debug");

//#if AUDIT
//        #region krly
//        project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Distribution: BeiJing TianShenHuDong Science and Technology Co., Ltd. (9ZK4D6KRR3)", "Release");
//        project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: wang ke (LYDZ2B92D4)", "Debug");

//        project.overwriteBuildSetting("PROVISIONING_PROFILE", "tfkrly-dev");
//        project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", "tfkrly-dis");
//        #endregion
//#else

//        #region tgame
//        project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Distribution: BeiJing TianShenHuDong Science and Technology Co., Ltd.", "Release");
//        project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: Hengli Liu (98M285BSQB)", "Debug");

//        project.overwriteBuildSetting("PROVISIONING_PROFILE", "tgame-dev");
//        project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", "Tgame-dis");
//        #endregion

//#endif

        #region 设置包名


        if (PlayerSettings.applicationIdentifier == GameBundleName.TEST_FLIGTH_IDENTIFIER)
        {
            //Test Flight
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Distribution: BeiJing TianShenHuDong Science and Technology Co., Ltd. (9ZK4D6KRR3)", "Release");
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: wang ke (LYDZ2B92D4)", "Debug");

            project.overwriteBuildSetting("PROVISIONING_PROFILE", "tfkrly-dev");
            project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", "tfkrly-dis");
        }
        else
        {
            //公司内部测试
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Distribution: BeiJing TianShenHuDong Science and Technology Co., Ltd.", "Release");
            project.overwriteBuildSetting("CODE_SIGN_IDENTITY", "iPhone Developer: Hengli Liu (98M285BSQB)", "Debug");

            project.overwriteBuildSetting("PROVISIONING_PROFILE", "tgame-dev");
            project.overwriteBuildSetting("PROVISIONING_PROFILE_SPECIFIER", "Tgame-dis");
        }


        #endregion



        project.overwriteBuildSetting("GCC_ENABLE_OBJC_EXCEPTIONS", "YES", "Release");
        project.overwriteBuildSetting("GCC_ENABLE_OBJC_EXCEPTIONS", "YES", "Debug");

        project.overwriteBuildSetting("GCC_ENABLE_CPP_EXCEPTIONS", "YES", "Release");
        project.overwriteBuildSetting("GCC_ENABLE_CPP_EXCEPTIONS", "YES", "Debug");

        project.overwriteBuildSetting("GCC_ENABLE_CPP_RTTI", "YES", "Release");
        project.overwriteBuildSetting("GCC_ENABLE_CPP_RTTI", "YES", "Debug");


        //#if AUDIT
        //        project.overwriteBuildSetting("PRODUCT_BUNDLE_IDENTIFIER", "com.zeus.awesome.krly");
        //        project.overwriteBuildSetting("PRODUCT_NAME","krly");
        //#elif NORMAL
        //        project.overwriteBuildSetting("PRODUCT_BUNDLE_IDENTIFIER","com.tianshen.shuguang.tgame");
        //        project.overwriteBuildSetting("PRODUCT_NAME", "krly");
        //#endif

        //TODO implement generic settings as a module option
        //		project.overwriteBuildSetting("CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Distribution", "Release");

        //设置XCode app name
        //project.overwriteBuildSetting("PRODUCT_NAME", "krly");

        var pbxproj = project.project;

        var attrs                   = pbxproj.attributes;
        var targetAttrs             = (PBXDictionary)attrs["TargetAttributes"];
        PBXDictionary targetSetting = new PBXDictionary();
        targetSetting["ProvisioningStyle"] = "Manual";


        var targets = pbxproj.targets;
        foreach (var t in targets)
        {
            var targetID = (string)t;
            if (targetAttrs.ContainsKey(targetID))
            {
                var TargetAttr = (PBXDictionary)targetAttrs[targetID];
                TargetAttr.Append(targetSetting);
            }
            else
            {
                targetAttrs[targetID] = targetSetting;
            }
        }


        // Finally save the xcode project
        project.Save();
    }
示例#24
0
 public PBXGroup(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
示例#25
0
 public PBXCopyFilesBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
示例#26
0
 public PBXFrameworksBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
示例#27
0
 public PBXReferenceProxy(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
     internalNewlines = true;
 }
示例#28
0
		public PBXFrameworksBuildPhase( string guid, PBXDictionary dictionary ) : base ( guid, dictionary )
		{
//			Debug.Log( "constructor child" + GetType().Name );
		}
示例#29
0
 public PBXVariantGroup(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
     internalNewlines = true;
 }
		/// <summary>
		/// Saves a project after editing.
		/// </summary>
		public void Save()
		{
			PBXDictionary result = new PBXDictionary();
			result.Add( "archiveVersion", 1 );
			result.Add( "classes", new PBXDictionary() );
			result.Add( "objectVersion", 45 );
			
			Consolidate();
			result.Add( "objects", _objects );
			
			result.Add( "rootObject", _rootObjectKey );
			
			Backup();
			
			// Parse result object directly into file
			PBXParser parser = new PBXParser();
			StreamWriter saveFile = File.CreateText( System.IO.Path.Combine( this.filePath, "project.pbxproj" ) );
			saveFile.Write( parser.Encode( result, false ) );
			saveFile.Close();

//			Xcode4Controller.Connect();
//			Xcode4Controller.OpenProject(filePath);
		}
示例#31
0
 public PBXFileReference( string guid, PBXDictionary dictionary )
     : base(guid, dictionary)
 {
 }
//		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
		}
示例#33
0
        /// <summary>
        /// Saves a project after editing.
        /// </summary>
        public void Save()
        {
            PBXDictionary result = new PBXDictionary();
            result.internalNewlines = true;
            result.Add( "archiveVersion", 1 );
            result.Add( "classes", new PBXDictionary() );
            result.Add( "objectVersion", 46 );

            Consolidate();
            result.Add( "objects", _objects );

            result.Add( "rootObject", _rootObjectKey );

            Backup();

            PBXParser parser = new PBXParser();
            StreamWriter saveFile = File.CreateText( System.IO.Path.Combine( this.filePath, "project.pbxproj" ) );
            saveFile.Write( parser.Encode( result ) );
            saveFile.Close();
        }
 public XCConfigurationList( string guid, PBXDictionary dictionary )
     : base(guid, dictionary)
 {
     internalNewlines = true;
 }
示例#35
0
 public void Consolidate()
 {
     PBXDictionary consolidated = new PBXDictionary();
     consolidated.Append<PBXBuildFile>( this.buildFiles );
     consolidated.Append<PBXCopyFilesBuildPhase>( this.copyBuildPhases );
     consolidated.Append<PBXFileReference>( this.fileReferences );
     consolidated.Append<PBXFrameworksBuildPhase>( this.frameworkBuildPhases );
     consolidated.Append<PBXGroup>( this.groups );
     consolidated.Append<PBXNativeTarget>( this.nativeTargets );
     consolidated.Add( project.guid, project.data );
     consolidated.Append<PBXResourcesBuildPhase>( this.resourcesBuildPhases );
     consolidated.Append<PBXShellScriptBuildPhase>( this.shellScriptBuildPhases );
     consolidated.Append<PBXSourcesBuildPhase>( this.sourcesBuildPhases );
     consolidated.Append<XCBuildConfiguration>( this.buildConfigurations );
     consolidated.Append<XCConfigurationList>( this.configurationLists );
     _objects = consolidated;
     consolidated = null;
 }
示例#36
0
 public PBXTargetDependency(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
     internalNewlines = true;
 }
示例#37
0
 private void CreateNewProject(PBXDictionary result, string path)
 {
     PBXParser parser = new PBXParser();
     StreamWriter saveFile = File.CreateText( path );
     saveFile.Write( parser.Encode( result, true ) );
     saveFile.Close();
 }
示例#38
0
 public PBXSourcesBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
 public PBXProject( string guid, PBXDictionary dictionary )
     : base(guid, dictionary)
 {
 }
示例#40
0
 public PBXBuildFile(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }