private static void removeCompatibilityLibraryFromProject(XCProject project) { string folderPath = Path.Combine(Application.dataPath, "Fyber/iOS/fyber-sdk-compat-lib"); if (Directory.Exists(folderPath)) { Debug.Log(folderPath + " exists. Deleting it"); Directory.Delete(folderPath, true); } string libPath = Path.Combine(project.projectRootPath, "Libraries/Fyber/iOS/fyber-sdk-compat-lib"); if (Directory.Exists(libPath)) { Debug.Log(libPath + " exists. Deleting it"); Directory.Delete(libPath, true); } #if UNITY_5 var compatGroup = "Libraries/Fyber/iOS/fyber-sdk-compat-lib"; string[] filesToRemove = { "FYBBannerSize.h", "FYBBannerView.h", "libFyberSDKCompat.a" }; UnityEditor.iOS.Xcode.PBXProject pbxProject = new UnityEditor.iOS.Xcode.PBXProject(); string pbxprojPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(project.projectRootPath); pbxProject.ReadFromFile(pbxprojPath); foreach (string file in filesToRemove) { var fileToRemove = compatGroup + "/" + file; if (pbxProject.ContainsFileByProjectPath(fileToRemove)) { string guid = pbxProject.FindFileGuidByProjectPath(fileToRemove); pbxProject.RemoveFile(guid); } } pbxProject.WriteToFile(pbxprojPath); #endif // UNITY_5 }
public static void OnPostProcessBuild(BuildTarget target, string path) { #if UNITY_IPHONE || UNITY_IOS #if UNITY_5 if (target == BuildTarget.iOS) #else if (target == BuildTarget.iPhone) #endif // UNITY_5 { string folderPath = Path.Combine(Application.dataPath, "Fyber/iOS/fyber-sdk-compat-lib"); if (Directory.Exists(folderPath)) { Directory.Delete(folderPath, true); } XCProject project = new XCProject(path); string libPath = Path.Combine(project.projectRootPath, "Libraries/Fyber/iOS/fyber-sdk-compat-lib"); if (Directory.Exists(libPath)) { Directory.Delete(libPath, true); } // Find and run through all projmods files to patch the project string projModPath = System.IO.Path.Combine(Application.dataPath, "Fyber/iOS"); string[] files = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories); foreach (var file in files) { project.ApplyMod(Application.dataPath, file); if (file.Contains("NativeX")) { string unityVersionPlist = "<plist><key>name</key><string>Nativex</string><key>settings</key><dict><key>FYBNativeXUnityBuildFlag</key><true /></dict></plist>"; PlistUpdater.UpdatePlist(project.projectRootPath, unityVersionPlist); } } project.Save(); #if UNITY_5 var compatGroup = "Libraries/Fyber/iOS/fyber-sdk-compat-lib"; string[] filesToRemove = { "FYBBannerSize.h", "FYBBannerView.h", "libFyberSDKCompat.a" }; UnityEditor.iOS.Xcode.PBXProject pbxProject = new UnityEditor.iOS.Xcode.PBXProject(); string pbxprojPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(path); pbxProject.ReadFromFile(pbxprojPath); foreach (string file in filesToRemove) { var fileToRemove = compatGroup + "/" + file; if (pbxProject.ContainsFileByProjectPath(fileToRemove)) { string guid = pbxProject.FindFileGuidByProjectPath(fileToRemove); pbxProject.RemoveFile(guid); } } pbxProject.WriteToFile(pbxprojPath); #endif // UNITY_5 } #endif //UNITY_IPHONE || UNITY_IOS }
private static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath) { //iOS以外にビルドしている場合は更新処理を行わないように if (buildTarget != BuildTarget.iOS){ return; } //Xcodeの設定データを読み込む XcodeProjectSetting setting = Resources.Load<XcodeProjectSetting>(SETTING_DATA_PATH); if(setting == null){ Debug.Log ("Resources/" + SETTING_DATA_PATH + "がありません!"); return; } //Xcodeプロジェクトの読み込み string pbxProjPath = PBXProject.GetPBXProjectPath(buildPath); PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromString(File.ReadAllText(pbxProjPath)); //ターゲットのID取得 string targetGuid = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName()); //指定ディレクトリ内のファイルを全てコピーする if(!string.IsNullOrEmpty(setting.CopyDirectoryPath)){ DirectoryProcessor.CopyAndAddBuildToXcode (pbxProject, targetGuid, setting.CopyDirectoryPath, buildPath, ""); } //コンパイラフラグの設定 foreach (XcodeProjectSetting.CompilerFlagsSet compilerFlagsSet in setting.CompilerFlagsSetList) { foreach (string targetPath in compilerFlagsSet.TargetPathList) { if(!pbxProject.ContainsFileByProjectPath(targetPath)){ Debug.Log (targetPath + "が無いのでコンパイラフラグが設定できませんでした"); continue; } string fileGuid = pbxProject.FindFileGuidByProjectPath(targetPath); List<string> flagsList = pbxProject.GetCompileFlagsForFile(targetGuid, fileGuid); flagsList.Add(compilerFlagsSet.Flags); pbxProject.SetCompileFlagsForFile(targetGuid, fileGuid, flagsList); } } //システムのフレームワークを追加 foreach (string framework in setting.FrameworkList) { pbxProject.AddFrameworkToProject(targetGuid, framework, false); } //Linker Flagの設定 pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.LINKER_FLAG_KEY, setting.LinkerFlagArray, null); //フレームワークがあるディレクトリへのパス設定 pbxProject.UpdateBuildProperty(targetGuid, XcodeProjectSetting.FRAMEWORK_SEARCH_PATHS_KEY, setting.FrameworkSearchPathArray, null); //BitCodeの設定 pbxProject.SetBuildProperty(targetGuid, XcodeProjectSetting.ENABLE_BITCODE_KEY, setting.EnableBitCode ? "YES" : "NO"); //プロジェクトファイル書き出し File.WriteAllText(pbxProjPath, pbxProject.WriteToString()); //URLスキームの設定 List<string> urlSchemeList = new List<string>(setting.URLSchemeList); InfoPlistProcessor.SetURLSchemes (buildPath, setting.URLIdentifier, urlSchemeList); //デフォルトで設定されているスプラッシュ画像の設定を消す if(setting.NeedToDeleteLaunchiImagesKey){ InfoPlistProcessor.DeleteLaunchiImagesKey (buildPath); } //ATSの設定 InfoPlistProcessor.SetATS (buildPath, setting.EnableATS); //ステータスバーの設定 InfoPlistProcessor.SetStatusBar (buildPath, setting.EnableStatusBar); }