static void Init() { SetInvalid(); DeveloperRoot = Environment.GetEnvironmentVariable("MD_APPLE_SDK_ROOT"); if (DeveloperRoot.IsNullOrEmpty) { DeveloperRoot = GetConfiguredSdkLocation(); if (DeveloperRoot.IsNullOrEmpty) { DeveloperRoot = "/Developer"; } } if (!ValidateSdkLocation(DeveloperRoot)) { return; } try { var plist = XcodePath.Combine("Contents", "Info.plist"); if (!File.Exists(plist)) { return; } lastWritten = File.GetLastWriteTime(plist); // DTXCode was introduced after xcode 3.2.6 so it may not exist using (var pool = new NSAutoreleasePool()) { var dict = NSDictionary.FromFile(plist); NSObject value; if (dict.TryGetValue(new NSString("DTXcode"), out value)) { DTXcode = ((NSString)value).ToString(); } } IsXcode4 = !string.IsNullOrEmpty(DTXcode) && int.Parse(DTXcode) >= 0400; IsXcode42 = !string.IsNullOrEmpty(DTXcode) && int.Parse(DTXcode) >= 0420; IsValid = true; } catch (Exception ex) { LoggingService.LogError("Error loading Xcode information for prefix '" + DeveloperRoot + "'", ex); SetInvalid(); } }
static void Init() { SetInvalid(); DeveloperRoot = Environment.GetEnvironmentVariable("MD_APPLE_SDK_ROOT"); if (DeveloperRoot.IsNullOrEmpty) { DeveloperRoot = GetConfiguredSdkLocation(); } bool foundSdk = false; FilePath xcode, vplist, devroot; if (DeveloperRoot.IsNullOrEmpty) { foreach (var v in DefaultRoots) { if (ValidateSdkLocation(v, out xcode, out vplist, out devroot)) { foundSdk = true; break; } else { LoggingService.LogDebug("Apple iOS SDK not found at '{0}'", v); } } } else { foundSdk = ValidateSdkLocation(DeveloperRoot, out xcode, out vplist, out devroot); } if (foundSdk) { XcodePath = xcode; DeveloperRoot = devroot; DeveloperRootVersionPlist = vplist; } else { SetInvalid(); return; } try { var plist = XcodePath.Combine("Contents", "Info.plist"); if (!File.Exists(plist)) { return; } lastWritten = File.GetLastWriteTime(plist); // DTXCode was introduced after xcode 3.2.6 so it may not exist using (var pool = new NSAutoreleasePool()) { var dict = NSDictionary.FromFile(plist); NSObject value; if (dict.TryGetValue(new NSString("DTXcode"), out value)) { DTXcode = ((NSString)value).ToString(); } } IsXcode4 = !string.IsNullOrEmpty(DTXcode) && int.Parse(DTXcode) >= 0400; IsXcode42 = !string.IsNullOrEmpty(DTXcode) && int.Parse(DTXcode) >= 0420; IsValid = true; } catch (Exception ex) { LoggingService.LogError("Error loading Xcode information for prefix '" + DeveloperRoot + "'", ex); SetInvalid(); } }
public override void OnGUI() { GUILayout.BeginHorizontal(); Enabled = GUILayout.Toggle(Enabled, Name); GUILayout.FlexibleSpace(); EnableBfgAutomaticReferenceCounting = GUILayout.Toggle(EnableBfgAutomaticReferenceCounting, new GUIContent("BFG ARC", "Enable Automatic Reference Counting for BFGLib")); GUILayout.FlexibleSpace(); if(Expanded){ //List currently included items GUILayout.BeginVertical(); for(int i = 0; i < m_paths.Length; i++){ GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(m_paths[i].path); if(m_paths[i].isFrameworkLink){ GUILayout.Label("[F]"); } if(GUILayout.Button("-", GUILayout.Width(30))){ m_paths = ArrayExtensions.RemoveAt(m_paths, i); Dirty = true; } GUILayout.EndHorizontal(); } //list of automatically included frameworks if(RequiredFrameworks.Count > 0){ string frameworkList = ""; int addedFrameworksCount = 0; foreach(string framework in RequiredFrameworks){ if(!Array.Exists(m_paths, xpath => xpath.isFrameworkLink && xpath.path == framework)){ frameworkList += framework + "\n"; addedFrameworksCount ++; } } frameworkList = frameworkList.Trim(); if(addedFrameworksCount > 0){ GUILayout.BeginHorizontal(); GUI.enabled = false; GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent("Plus " + addedFrameworksCount + " required frameworks & libs", frameworkList), EditorStyles.miniLabel); GUI.enabled = true; GUILayout.EndHorizontal(); } } //Add-new-item buttons GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if(GUILayout.Button("Add Dir")){ string dataPathParent = Directory.GetParent(Application.dataPath).FullName; string newPath = EditorUtility.OpenFolderPanel("Select Directory To Add", dataPathParent, ""); if(newPath != ""){ //Check new path is valid if(newPath.StartsWith(dataPathParent)){ XcodePath xpath = new XcodePath(); //Change to relative path xpath.path = newPath.Substring(dataPathParent.Length + 1); // +1 chomps leading slash xpath.isFrameworkLink = false; //Insert it m_paths = ArrayExtensions.InsertAt(m_paths, xpath, m_paths.Length); Dirty = true; } else{ Debug.LogError("Could not add folder: Directory must be inside the project folder."); } } } if(GUILayout.Button("Add Framework")){ if(m_sdkPath == null){ m_sdkPath = EditorUtility.OpenFolderPanel("Select SDK directory", "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs", ""); } string newPath = EditorUtility.OpenFolderPanel("Select File to Add", m_sdkPath + "/System/Library/Frameworks/", ""); if(newPath != ""){ //Check new path is valid if(newPath.StartsWith(m_sdkPath)){ XcodePath xpath = new XcodePath(); //Change to relative path xpath.path = newPath.Substring(m_sdkPath.Length + 1); // +1 chomps leading slash xpath.isFrameworkLink = true; //Insert it m_paths = ArrayExtensions.InsertAt(m_paths, xpath, m_paths.Length); Dirty = true; } else{ Debug.LogError("Could not add file: File must be inside the SDK folder."); } } } if(GUILayout.Button("Add Library")){ if(m_sdkPath == null){ m_sdkPath = EditorUtility.OpenFolderPanel("Select SDK directory", "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs", ""); } string newPath = EditorUtility.OpenFilePanel("Select File to Add", m_sdkPath, ""); if(newPath != ""){ //Check new path is valid if(newPath.StartsWith(m_sdkPath)){ //If selected file was an alias the file panel will dereference it without telling us. Try to undo the dereference here. FileInfo fileInfo = new FileInfo(newPath); if(fileInfo.Name.IndexOf(".") != fileInfo.Name.LastIndexOf(".")){ FileInfo baseFileInfo = new FileInfo(Path.Combine(fileInfo.DirectoryName, fileInfo.Name.Substring(0, fileInfo.Name.IndexOf(".")) + fileInfo.Name.Substring(fileInfo.Name.LastIndexOf(".")))); if(baseFileInfo.Exists){ newPath = baseFileInfo.FullName; } } XcodePath xpath = new XcodePath(); //Change to relative path xpath.path = newPath.Substring(m_sdkPath.Length + 1); // +1 chomps leading slash xpath.isFrameworkLink = true; //Insert it m_paths = ArrayExtensions.InsertAt(m_paths, xpath, m_paths.Length); Dirty = true; } else{ Debug.LogError("Could not add file: File must be inside the SDK folder."); } } } if(GUILayout.Button(">.<")){ Expanded = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } //End if Expanded else{ GUILayout.Label(m_paths.Length + " files"); if(GUILayout.Button("...")){ Expanded = true; } } if (Enabled) { StatusLight(); } else { DisabledStatusLight(); } GUILayout.EndHorizontal(); }