public void ApplyMod(XCMod mod) { PBXGroup modGroup = this.GetGroup(mod.group); // UnityEngine.Debug.Log( "Adding libraries..." ); // PBXGroup librariesGroup = this.GetGroup( "Libraries" ); foreach (XCModFile libRef in mod.libs) { string completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath); this.AddFile(completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak); } // UnityEngine.Debug.Log( "Adding frameworks..." ); PBXGroup frameworkGroup = this.GetGroup("Frameworks"); foreach (string framework in mod.frameworks) { string[] filename = framework.Split(':'); bool isWeak = (filename.Length > 1) ? true : false; string completePath = System.IO.Path.Combine("System/Library/Frameworks", filename[0]); this.AddFile(completePath, frameworkGroup, "SDKROOT", true, isWeak); } // UnityEngine.Debug.Log( "Adding files..." ); // foreach( string filePath in mod.files ) { // string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath ); // // // if( filePath.EndsWith(".framework") ) // this.AddFile( absoluteFilePath, frameworkGroup, "GROUP", true, false); // else // this.AddFile( absoluteFilePath, modGroup ); // } // UnityEngine.Debug.Log( "Adding folders..." ); foreach (string folderPath in mod.folders) { string absoluteFolderPath = System.IO.Path.Combine(mod.path, folderPath); this.AddFolder(absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray(typeof(string))); } // UnityEngine.Debug.Log( "Adding headerpaths..." ); foreach (string headerpath in mod.headerpaths) { string absoluteHeaderPath = System.IO.Path.Combine(mod.path, headerpath); this.AddHeaderSearchPaths(absoluteHeaderPath); } // UnityEngine.Debug.Log( "Adding librarypaths..." ); foreach (string headerpath in mod.librarypaths) { string absoluteLibraryPath = System.IO.Path.Combine(mod.path, headerpath); this.AddLibrarySearchPaths(absoluteLibraryPath); } // UnityEngine.Debug.Log ("Adding Zip..."); foreach (string zipPath in mod.zipPaths) { string zipFileName = zipPath; string sdkName = zipFileName.Remove(zipFileName.LastIndexOf(".")); string unzipLoc = mod.path + "/" + zipFileName; string dirpath = this.projectRootPath; ZipHelper zipTool = new ZipHelper(); zipTool.UnzipWithPath(unzipLoc, dirpath); //删除多余解压文件 DirectoryInfo di = new DirectoryInfo(dirpath + "/__MACOSX"); di.Delete(true); string absoluteFolderPath = System.IO.Path.Combine(this.projectRootPath, sdkName + "/"); // this.AddFolder( absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray( typeof(string) ) ); //第二个参数传null,能够在xcode项目再减少一层文件夹 this.AddFolder(absoluteFolderPath, null, (string[])mod.excludes.ToArray(typeof(string))); } // UnityEngine.Debug.Log( "Adding files..." ); foreach (string filePath in mod.files) { //原版为根据.projmods中的files来添加 // string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath ); //对于ShareSDK,由于解压的文件夹已经移动至Xcode根目录,所以要根据根目录路径进行库路径添加 string absoluteFilePath = System.IO.Path.Combine(this.projectRootPath, filePath); if (filePath.EndsWith(".framework")) { this.AddFile(absoluteFilePath, frameworkGroup, "GROUP", true, false); } else { this.AddFile(absoluteFilePath, modGroup); } } // UnityEngine.Debug.Log( "Configure build settings..." ); Hashtable buildSettings = mod.buildSettings; if (buildSettings.ContainsKey("OTHER_LDFLAGS")) { // UnityEngine.Debug.Log( " Adding other linker flags..." ); ArrayList otherLinkerFlags = (ArrayList)buildSettings["OTHER_LDFLAGS"]; foreach (string linker in otherLinkerFlags) { string _linker = linker; if (!_linker.StartsWith("-")) { _linker = "-" + _linker; } this.AddOtherLDFlags(_linker); } } if (buildSettings.ContainsKey("GCC_ENABLE_CPP_EXCEPTIONS")) { // UnityEngine.Debug.Log( " GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] ); this.GccEnableCppExceptions((string)buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"]); } if (buildSettings.ContainsKey("GCC_ENABLE_OBJC_EXCEPTIONS")) { // UnityEngine.Debug.Log( " GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] ); this.GccEnableObjCExceptions((string)buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"]); } this.Consolidate(); }
public void ApplyMod(string pbxmod) { XCMod mod = new XCMod(pbxmod); ApplyMod(mod); }