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

            // Convert to absolute
            this.projectRootPath = Path.GetFullPath(this.projectRootPath);

            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 ) ) {
            //				_rootObject = (PBXDictionary)_objects[ _rootObjectKey ];
                _project = new PBXProject( _rootObjectKey, (PBXDictionary)_objects[ _rootObjectKey ] );
            //				_rootGroup = (PBXDictionary)_objects[ (string)_rootObject[ "mainGroup" ] ];
                _rootGroup = new PBXGroup( _rootObjectKey, (PBXDictionary)_objects[ _project.mainGroupID ] );
            }
            else {
                Debug.LogWarning( "error: project has no root object" );
                _project = null;
                _rootGroup = null;
            }
        }
Exemple #2
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();
        }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
        public XCProject(string filePath)
        {
            DiscoverXcodeProject(filePath);

            Debug.LogFormat("Opening project \"{0}\".", this.filePath);

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

            string contents;

            using (StreamReader streamReader = projectFileInfo.OpenText())
            {
                contents = streamReader.ReadToEnd();
            }

            PBXParser parser = new PBXParser();

            _datastore = parser.Decode(contents);
            if (_datastore == null)
            {
                throw new System.Exception("Project file not found at file path " + this.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))
            {
//              _rootObject = (PBXDictionary)_objects[ _rootObjectKey ];
                _project = new PBXProject(_rootObjectKey, (PBXDictionary)_objects[_rootObjectKey]);
//              _rootGroup = (PBXDictionary)_objects[ (string)_rootObject[ "mainGroup" ] ];
                _rootGroup = new PBXGroup(_rootObjectKey, (PBXDictionary)_objects[_project.mainGroupID]);
            }
            else
            {
                Debug.LogWarning("error: project has no root object");
                _project   = null;
                _rootGroup = null;
            }
        }
Exemple #5
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", 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(Path.Combine(filePath, "project.pbxproj"));

            saveFile.Write(parser.Encode(result, false));
            saveFile.Close();
        }
        /// <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();
        }
Exemple #7
0
        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;
            }
        }
Exemple #8
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();
 }
Exemple #9
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"));
            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;
            }
        }
		/// <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();
		}
Exemple #11
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", 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);
        }