Exemplo n.º 1
0
        public override PBXFile Clone()
        {
            PbxSdkFile file = PbxSdkFile.CreateInstance();

            file.currentSdkFile = this.currentSdkFile;
            file.name           = this.name;
            file.absolutePath   = this.absolutePath;

            return(file);
        }
Exemplo n.º 2
0
        public static PbxSdkFile CreateInstance()
        {
            PbxSdkFile framework = ScriptableObject.CreateInstance <PbxSdkFile> () as PbxSdkFile;

            framework.group  = "Frameworks";
            framework.edited = true;
            if (sdkFiles == null)
            {
                Debug.LogError("iOS SDK not found");
                framework.removed = true;
                return(framework);
            }
            framework.currentSdkFiles = sdkFiles;
            framework.currentSdkFile  = sdkFiles [0];
            framework.name            = framework.currentSdkFile;
            return(framework);
        }
Exemplo n.º 3
0
        public static new PbxSdkFile CreateInstance(XmlElement element)
        {
            PbxSdkFile framework = ScriptableObject.CreateInstance <PbxSdkFile> () as PbxSdkFile;

            if (sdkFiles == null)
            {
                try {
                    LoadDeviceFrameworks();
                } catch (DirectoryNotFoundException) {
                    Debug.LogWarning("Coulnd't find iOS SDK");
                }
            }
            framework.fileRefID      = PBXEditor.GenerateID();
            framework.name           = element.Attributes ["name"].Value;
            framework.frameworkIndex = System.Array.IndexOf(sdkFiles, framework.name);
            if (framework.frameworkIndex == -1)
            {
                Debug.LogWarning("Could not find " + framework.name + " in iOS SDK.");
                framework.removed = true;
            }
            framework.currentSdkFile  = sdkFiles [framework.frameworkIndex];
            framework.currentSdkFiles = sdkFiles;
            framework.group           = element.Attributes ["group"].Value;
            if (framework.name.Contains(".framework"))
            {
                framework.relativePath = FRAMEWORK_PATH + framework.name;
            }
            else
            {
                framework.relativePath = LIBRARY_PATH + framework.name;
            }
            framework.sourceTree   = "SDKROOT";
            framework.absolutePath = "($" + framework.sourceTree + ")" + framework.relativePath;
            if (element.HasAttribute("required"))
            {
                framework.required = System.Convert.ToBoolean(element.Attributes["required"].Value);
                if (!framework.required)
                {
                    framework.optionalSettings.Add("ATTRIBUTES = (Weak, ); ");
                }
            }
            framework.AssignBuildPhase(System.IO.Path.GetExtension(framework.relativePath));
            return(framework);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        private void Initialize()
        {
            pbxFilePathSet.Clear();
            pbxSdkFileList.Clear();
            pbxFileList.Clear();
            headerSearchPaths.Clear();
            librarySearchPaths.Clear();
            pListEntryList.Clear();

            LoadPBXFiles();
            try {
                PbxSdkFile.LoadDeviceFrameworks();
            } catch {
                Debug.LogError("Couldn't Fid iOS SDK");
            }
            for (int i = 0; i < pbxFileList.Count; i++)
            {
                if (pbxFilePathSet.Contains(pbxFileList[i].absolutePath))
                {
                    pbxFileList.RemoveAt(i--);
                }
                else
                {
                    pbxFilePathSet.Add(pbxFileList[i].absolutePath);
                }
            }
            pListEntryList     = LoadPListEntries();
            linkerFlags        = LoadLinkerFlags();
            headerSearchPaths  = LoadHeaderSearchPaths();
            librarySearchPaths = LoadLibrarySearchPaths();

            pbxSdkFileList.Sort();
            pbxFileList.Sort();
            headerSearchPaths.Sort();
            librarySearchPaths.Sort();

            dirty = false;
        }
Exemplo n.º 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;
        }