public void EditProject() { foreach (PBXFile fileReference in fileReferences) { fileReference.MakePathRelative(projectPath); if (fileReference.isCustomFramework) { frameworkSearchPaths.Add (System.IO.Path.GetDirectoryName(fileReference.absolutePath)); } } PBXEditor editor = new PBXEditor (projectPath); PListEditor plistEditor = new PListEditor (projectPath); plistEditor.AddPListEntries (plistEntries); try { editor.AddFileReferences(fileReferences); editor.AddLinkerFlags (linkerFlags); editor.AddHeaderSearchPaths (headerPaths); editor.AddLibrarySearchPaths (libraryPaths); if (frameworkSearchPaths.Count > 0) { frameworkSearchPaths.Add (DEFAULT_FRAMEWORK_SEARCH_PATH); editor.AddFrameworkSearchPaths (frameworkSearchPaths); } } catch (System.ArgumentOutOfRangeException) { Debug.LogError ("Another script has modified the Xcode project and BuildBuddy cannot run"); return; } editor.Save (); }
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); }
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); }
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); }
protected void AssignBuildPhase(string fileExtension) { switch (fileExtension) { case ".a": buildPhase = BuildPhase.FRAMEWORKS; lastKnownFileType = "archive.ar"; break; case ".app": buildPhase = BuildPhase.NONE; lastKnownFileType = "wrapper.application"; break; case ".s": buildPhase = BuildPhase.SOURCES; lastKnownFileType = "sourcecode.asm"; break; case ".c": buildPhase = BuildPhase.SOURCES; lastKnownFileType = "sourcecode.c.c"; break; case ".cpp": buildPhase = BuildPhase.SOURCES; lastKnownFileType = "sourcecode.cpp.cpp"; break; case ".framework": buildPhase = BuildPhase.FRAMEWORKS; lastKnownFileType = "wrapper.framework"; isCustomFramework = true; break; case ".h": buildPhase = BuildPhase.NONE; lastKnownFileType = "sourcecode.c.h"; break; case ".pch": buildPhase = BuildPhase.NONE; lastKnownFileType = "sourcecode.c.h"; break; case ".icns": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "image.icns"; break; case ".m": buildPhase = BuildPhase.SOURCES; lastKnownFileType = "sourcecode.c.objc"; break; case ".mm": buildPhase = BuildPhase.SOURCES; lastKnownFileType = "sourcecode.c.objcpp"; break; case ".nib": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "wrapper.nib"; break; case ".plist": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text.plist.xml"; break; case ".png": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "image.png"; break; case ".rtf": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text.rtf"; break; case ".tiff": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "image.tiff"; break; case ".txt": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text"; break; case ".cs": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text"; break; case ".xcodeproj": buildPhase = BuildPhase.NONE; lastKnownFileType = "wrapper.pb-project"; break; case ".xib": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "file.xib"; break; case ".xml": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text.xml"; break; case ".strings": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "text.plist.strings"; break; case ".bundle": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "wrapper.plug-in"; break; case ".dylib": buildPhase = BuildPhase.FRAMEWORKS; lastKnownFileType = "compiled.macho-o.dylib"; break; case ".xcassets": buildPhase = BuildPhase.RESOURCES; lastKnownFileType = "folder.assetcatalog"; break; default: if (fileExtension.Equals("")) { Debug.LogWarning("Nested folders must be imported individually"); } else if (!fileExtension.Equals(".DS_Store")) { Debug.LogWarning("Build Buddy does not support " + fileExtension + " files"); } removed = true; buildPhase = BuildPhase.NONE; lastKnownFileType = ""; break; } if (buildPhase != BuildPhase.NONE) { buildRefID = PBXEditor.GenerateID(); } }