Beispiel #1
0
        public static PBXFile CreateInstance(XmlElement element)
        {
            PBXFile reference = ScriptableObject.CreateInstance <PBXFile> () as PBXFile;

            reference.fileRefID    = PBXEditor.GenerateID();
            reference.relativePath = element.Attributes ["path"].Value;
            reference.name         = System.IO.Path.GetFileName(reference.relativePath);
            reference.group        = element.Attributes ["group"].Value;
            reference._newGroup    = reference.group;
            if (element.HasAttribute("compilerFlags"))
            {
                reference.compilerFlags = element.Attributes ["compilerFlags"].Value;
                reference.optionalSettings.Add("COMPILER_FLAGS = \"" + reference.compilerFlags + "\"; ");
            }
            else if (element.HasAttribute("required"))
            {
                reference.required = System.Convert.ToBoolean(element.Attributes["required"].Value);
                reference.optionalSettings.Add("ATTRIBUTES = (Weak, ); ");
            }
            reference.AssignBuildPhase(System.IO.Path.GetExtension(reference.relativePath));
            reference.BuildAbsolutePath();
            reference.sourceTree = "SOURCE_ROOT";
            try {
                File.GetAttributes(reference.absolutePath);
            }
            catch (FileNotFoundException) {
                Debug.LogWarning("Could find file " + reference.name + " at " + reference.absolutePath);
                reference.fileNotFound = true;
            }
            catch (DirectoryNotFoundException) {
                Debug.LogWarning("Could find file " + reference.name + " at " + reference.absolutePath);
                reference.fileNotFound = true;
            }
            return(reference);
        }
Beispiel #2
0
        public virtual PBXFile Clone()
        {
            PBXFile newFile = CreateInstance(this.absolutePath, this.group);

            newFile.compilerFlags = compilerFlags;
            return(newFile);
        }
Beispiel #3
0
        public static PBXFile CreateInstance(string absolutePath, string group)
        {
            PBXFile reference = ScriptableObject.CreateInstance <PBXFile> () as PBXFile;

            reference.group        = group;
            reference._newGroup    = group;
            reference.fileRefID    = PBXEditor.GenerateID();
            reference.absolutePath = absolutePath;
            reference.MakePathRelative(Application.dataPath);
            reference.AssignBuildPhase(System.IO.Path.GetExtension(reference.absolutePath));
            reference.name   = System.IO.Path.GetFileName(reference.absolutePath);
            reference.edited = true;
            return(reference);
        }
Beispiel #4
0
        public int CompareTo(object obj)
        {
            if (obj as PBXFile == null)
            {
                return(1);
            }
            PBXFile file = obj as PBXFile;

            if (this.group == null)
            {
                return(1);
            }
            if (this.group.CompareTo(file.group) == 0)
            {
                return(this.name.CompareTo(file.name));
            }
            return(this.group.CompareTo(file.group));
        }
Beispiel #5
0
        public List <PBXFile> LoadPBXFiles()
        {
            pbxFileList.Clear();
            pbxSdkFileList.Clear();
            foreach (XmlElement file in document.GetElementsByTagName("pbxfile"))
            {
                string filePath = file.Attributes["path"].Value;
                if (filePath.Equals(FRAMEWORK_PATH_TOKEN))
                {
                    pbxSdkFileList.Add(PbxSdkFile.CreateInstance(file));
                    continue;
                }
                pbxFileList.Add(PBXFile.CreateInstance(file));
            }
            List <PBXFile> allFiles = new List <PBXFile>(pbxFileList);

            allFiles.AddRange(pbxSdkFileList);
            return(allFiles);
        }
Beispiel #6
0
        public void OnGUI()
        {
            Undo.RecordObject(this, "Xcode Window");
            #region buttons
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Add File"))
                {
                    string import = EditorUtility.OpenFilePanel("Include in Xcode project", Application.dataPath + "/..", "");
                    if (!import.Equals(""))
                    {
                        if (pbxFilePathSet.Contains(import))
                        {
                            Debug.LogWarning("Already importing: " + import);
                        }
                        else
                        {
                            pbxFileList.Add(PBXFile.CreateInstance(import, importGroup));
                            pbxFilePathSet.Add(import);
                            dirty = true;
                        }
                    }
                    for (int i = 0; i < pbxFileList.Count; i++)
                    {
                        if (pbxFileList[i].removed)
                        {
                            pbxFileList.RemoveAt(i--);
                        }
                    }
                }
                if (GUILayout.Button("Add Folder"))
                {
                    string import = EditorUtility.OpenFolderPanel("Include folder in Xcode project", Application.dataPath + "/..", "");
                    if (!import.Equals(""))
                    {
                        dirty = true;
                        if (System.IO.Path.GetExtension(import).Equals(".framework"))
                        {
                            pbxFileList.Add(PBXFile.CreateInstance(import, importGroup));
                        }
                        else
                        {
                            string[] filePaths = System.IO.Directory.GetFiles(import);
                            foreach (string path in filePaths)
                            {
                                if (pbxFilePathSet.Contains(path))
                                {
                                    Debug.LogWarning("Already importing: " + path);
                                }
                                else
                                {
                                    pbxFileList.Add(PBXFile.CreateInstance(path, importGroup));
                                    pbxFilePathSet.Add(path);
                                }
                            }
                            filePaths = System.IO.Directory.GetDirectories(import, "*.*");
                            foreach (string path in filePaths)
                            {
                                if (pbxFilePathSet.Contains(path))
                                {
                                    Debug.LogWarning("Already importing: " + path);
                                }
                                else
                                {
                                    pbxFileList.Add(PBXFile.CreateInstance(path, importGroup));
                                    pbxFilePathSet.Add(path);
                                }
                            }
                        }
                    }
                    for (int i = 0; i < pbxFileList.Count; i++)
                    {
                        if (pbxFileList[i].removed)
                        {
                            pbxFileList.RemoveAt(i--);
                        }
                    }
                }
                if (GUILayout.Button("Add iOS SDK File"))
                {
                    pbxSdkFileList.Add(PbxSdkFile.CreateInstance());
                    displaySdkFiles = true;
                }
            }
            try {
                EditorGUILayout.EndHorizontal();
            }
            catch (System.InvalidOperationException) { Debug.Log("Caught invalidoperatinexception"); }
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Header Search Path"))
                {
                    headerSearchPaths.Add("");
                    displayHeaderPaths = true;
                }
                if (GUILayout.Button("Library Search Path"))
                {
                    librarySearchPaths.Add("");
                    displayLibraryPaths = true;
                }
                if (GUILayout.Button("Plist Entry"))
                {
                    pListEntryList.Add(PlistEntry.CreateInstance());
                    displayPlistEditor = true;
                }
            }
            EditorGUILayout.EndHorizontal();
            #endregion
            EditorGUILayout.Space();

            importGroup = EditorGUILayout.TextField("File Import Group: ", importGroup);
            EditorGUI.BeginChangeCheck();
            linkerFlags = EditorGUILayout.TextField("Linker Flags: ", linkerFlags);
            if (EditorGUI.EndChangeCheck())
            {
                dirty = true;
            }
            EditorGUILayout.Space();
            #region SDKFilesData
            displaySdkFiles = EditorGUILayout.Foldout(displaySdkFiles, "iOS SDK Files: (" + pbxSdkFileList.Count + ")");
            if (displaySdkFiles)
            {
                BBGuiHelper.BeginIndent();
                {
                    for (int i = 0; i < pbxSdkFileList.Count; i++)
                    {
                        if (pbxSdkFileList[i].removed)
                        {
                            pbxFilePathSet.Remove(pbxSdkFileList[i].absolutePath);
                            pbxSdkFileList.RemoveAt(i--);
                            dirty = true;
                            continue;
                        }
                        if (pbxSdkFileList[i] != null)
                        {
                            Undo.RecordObject(pbxSdkFileList[i], "Xcode File Import");
                        }
                        pbxSdkFileList[i].OnGUI();
                        if (pbxSdkFileList[i].edited)
                        {
                            dirty = true;
                        }
                    }
                }
                BBGuiHelper.EndIndent();
            }
            #endregion
            EditorGUILayout.Space();
            #region FilesData
            displayFiles = EditorGUILayout.Foldout(displayFiles, "Other Files: (" + pbxFileList.Count + ")");
            if (displayFiles)
            {
                BBGuiHelper.BeginIndent();
                {
                    string currentGroup = "";
                    BBGuiHelper.BeginIndent();
                    for (int i = 0; i < pbxFileList.Count; i++)
                    {
                        if (pbxFileList[i].removed)
                        {
                            pbxFilePathSet.Remove(pbxFileList[i].absolutePath);
                            pbxFileList.RemoveAt(i--);
                            dirty = true;
                            continue;
                        }
                        if (pbxFileList[i] != null)
                        {
                            Undo.RecordObject(pbxFileList[i], "Xcode File Import");
                        }
                        if (!pbxFileList[i].group.Equals(currentGroup))
                        {
                            BBGuiHelper.EndIndent();
                            EditorGUILayout.LabelField(pbxFileList[i].group);
                            currentGroup = pbxFileList[i].group;
                            BBGuiHelper.BeginIndent();
                        }
                        pbxFileList[i].OnGUI();
                        if (pbxFileList[i].edited)
                        {
                            dirty = true;
                        }
                    }
                    BBGuiHelper.EndIndent();
                }
                BBGuiHelper.EndIndent();
            }
            #endregion
            EditorGUILayout.Space();
            #region HeaderPaths
            displayHeaderPaths = EditorGUILayout.Foldout(displayHeaderPaths, "Header Search Paths: (" + headerSearchPaths.Count + ")");
            if (displayHeaderPaths)
            {
                BBGuiHelper.BeginIndent();
                {
                    EditorGUI.BeginChangeCheck();
                    for (int i = 0; i < headerSearchPaths.Count; i++)
                    {
                        headerSearchPaths[i] = EditorGUILayout.TextField(headerSearchPaths[i]);
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button("Set"))
                        {
                            headerSearchPaths[i] = EditorUtility.OpenFolderPanel("Set Header Search Path", Application.dataPath + "/..", "");
                            headerSearchPaths[i] = MakePathRelative(headerSearchPaths[i]);
                        }
                        if (GUILayout.Button("Remove"))
                        {
                            headerSearchPaths.RemoveAt(i--);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        dirty = true;
                    }
                }
                BBGuiHelper.EndIndent();
            }
            #endregion
            EditorGUILayout.Space();
            #region LibraryPaths
            displayLibraryPaths = EditorGUILayout.Foldout(displayLibraryPaths, "Library Search Paths: (" + librarySearchPaths.Count + ")");
            if (displayLibraryPaths)
            {
                BBGuiHelper.BeginIndent();
                {
                    EditorGUI.BeginChangeCheck();
                    for (int i = 0; i < librarySearchPaths.Count; i++)
                    {
                        librarySearchPaths[i] = EditorGUILayout.TextField(librarySearchPaths[i]);
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button("Set"))
                        {
                            librarySearchPaths[i] = EditorUtility.OpenFolderPanel("Set Library Search Path", Application.dataPath + "/..", "");
                            librarySearchPaths[i] = MakePathRelative(librarySearchPaths[i]);
                        }
                        if (GUILayout.Button("Remove"))
                        {
                            librarySearchPaths.RemoveAt(i--);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        dirty = true;
                    }
                }
                BBGuiHelper.EndIndent();
            }
            #endregion
            EditorGUILayout.Space();
            #region plistEditor
            displayPlistEditor = EditorGUILayout.Foldout(displayPlistEditor, "Info.plist Editor: (" + pListEntryList.Count + ")");
            if (displayPlistEditor)
            {
                for (int i = 0; i < pListEntryList.Count; i++)
                {
                    if (pListEntryList[i] != null)
                    {
                        Undo.RecordObject(pListEntryList[i], "Plist Entry");
                    }
                    pListEntryList[i].OnGUI();
                    if (pListEntryList[i].edited)
                    {
                        dirty = true;
                    }
                    if (pListEntryList[i].removed)
                    {
                        pListEntryList.RemoveAt(i--);
                        dirty = true;
                    }
                }
            }
            #endregion
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                if (dirty)
                {
                    GUI.color = Color.green;
                }
                else
                {
                    GUI.color = Color.gray;
                }
                if (GUILayout.Button("Apply Changes"))
                {
                    ApplyChanges();
                }
                if (dirty)
                {
                    GUI.color = Color.red;
                }
                else
                {
                    GUI.color = Color.gray;
                }
                if (GUILayout.Button("Cancel Changes"))
                {
                    Initialize();
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
        }