Esempio n. 1
0
 public PBXGroup(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 2
0
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string compilerFlags = null)
        {
            // Converting path to use Forward slashes
            filePath = filePath.Replace('\\', '/');

//			Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );

            PBXDictionary results = new PBXDictionary();

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

            string absPath = string.Empty;

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

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

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

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

            if (fileReference != null)
            {
                //Updating internal data with this call.
                fileReference.GuessFileType();
            }
            else
            {
                fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            }

            // Adding compiler flag
            if (!string.IsNullOrEmpty(compilerFlags))
            {
                fileReference.compilerFlags = compilerFlags;
            }

            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference

            /*if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {
             *  Debug.Log("Build Phase Type : " + fileReference.buildPhase + " file path : " + filePath);
             *                  switch( fileReference.buildPhase ) {
             *                          case "PBXFrameworksBuildPhase":
             *                                  foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
             *                                          BuildAddFile(fileReference,currentObject,weak);
             *                                  }
             *                                  if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 )) {
             *                                          string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
             *                                          if (File.Exists(absPath)) {
             *                                                  this.AddLibrarySearchPaths( new PBXList( libraryPath ) );
             *                                          } else {
             *                                                  this.AddFrameworkSearchPaths( new PBXList( libraryPath ) );
             *                                          }
             *
             *                                  }
             *                                  break;
             *                          case "PBXResourcesBuildPhase":
             *                                  foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
             * //							Debug.Log( "Adding Resources Build File" );
             *                                          BuildAddFile(fileReference,currentObject,weak);
             *                                  }
             *                                  break;
             *                          case "PBXShellScriptBuildPhase":
             *                                  foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
             * //							Debug.Log( "Adding Script Build File" );
             *                                          BuildAddFile(fileReference,currentObject,weak);
             *                                  }
             *                                  break;
             *                          case "PBXSourcesBuildPhase":
             *          Debug.Log("PBXSourcesBuildPhase : " + fileReference.compilerFlags);
             *                                  foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
             * //							Debug.Log( "Adding Source Build File" );
             *                                          BuildAddFile(fileReference,currentObject,weak);
             *                                  }
             *                                  break;
             *                          case "PBXCopyFilesBuildPhase":
             *                                  foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
             * //							Debug.Log( "Adding Copy Files Build Phase" );
             *                                          BuildAddFile(fileReference,currentObject,weak);
             *                                  }
             *                                  break;
             *                          case null:
             *                                  Debug.LogWarning( "File Not Supported: " + filePath );
             *                                  break;
             *                          default:
             *                                  Debug.LogWarning( "File Not Supported." );
             *                                  return null;
             *                  }
             *          }*/

            if (createBuildFiles)
            {
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    AddBuildFramework(fileReference, 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":
                    AddBuildFile(fileReference, weak);

                    break;

                case "PBXShellScriptBuildPhase":
                    AddBuildFile(fileReference, weak);

                    break;

                case "PBXSourcesBuildPhase":
                    AddBuildFile(fileReference, weak);

                    break;

                case "PBXCopyFilesBuildPhase":
                    AddBuildFile(fileReference, weak);

                    break;

                case null:
                    AddBuildFile(fileReference, weak);


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

                default:
                    Debug.LogWarning("File Not Supported.");
                    return(null);
                }
            }


            return(results);
        }
Esempio n. 3
0
        public XCProject(string filePath) : this()
        {
            if (!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 = 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 (!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"));

            StreamReader streamReader = projectFileInfo.OpenText();
            string       contents     = streamReader.ReadToEnd();

            streamReader.Close();


            // Get xcode project
            xcodeProject = GetXcodeProject(filePath);
            targetGUID   = GetUnityTargetGUID();


            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("Error " + _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]);

                PBXNativeTarget _unityNativeTarget = GetUnityNativeTarget();
                _targetBuildPhases = (PBXList)_unityNativeTarget.data["buildPhases"];
            }
            else
            {
                Debug.LogWarning("error: project has no root object");
                _project   = null;
                _rootGroup = null;
            }
        }
Esempio n. 4
0
 public PBXObject()
 {
     _data          = new PBXDictionary();
     _data[ISA_KEY] = this.GetType().Name;
     _guid          = GenerateGuid();
 }
Esempio n. 5
0
 public PBXFileReference(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 6
0
 public PBXContainerItemProxy(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 7
0
 public PBXReferenceProxy(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
 public XCBuildConfiguration(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 9
0
 public PBXNativeTarget(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 10
0
 public PBXCopyFilesBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 11
0
 public PBXSourcesBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 12
0
 public PBXShellScriptBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 13
0
 public PBXFrameworksBuildPhase(string guid, PBXDictionary dictionary) : base(guid, dictionary)
 {
 }
Esempio n. 14
0
//		XCBuildConfigurationList buildConfigurations;
//		bool defaultConfigurationIsVisible = false;
//		string defaultConfigurationName;

        public XCConfigurationList(string guid, PBXDictionary dictionary) : base(guid, dictionary)
        {
        }