public AddFileToBuild ( string targetGuid, string fileGuid ) : void | ||
targetGuid | string | |
fileGuid | string | |
Результат | void |
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) { string projPath = PBXProject.GetPBXProjectPath(path); PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); // システムのフレームワークを追加 proj.AddFrameworkToProject(target, "AssetsLibrary.framework", false); // 自前のフレームワークを追加 CopyAndReplaceDirectory("Assets/Lib/mylib.framework", Path.Combine(path, "Frameworks/mylib.framework")); proj.AddFileToBuild(target, proj.AddFile("Frameworks/mylib.framework", "Frameworks/mylib.framework", PBXSourceTree.Source)); // ファイルを追加 var fileName = "my_file.xml"; var filePath = Path.Combine("Assets/Lib", fileName); File.Copy(filePath, Path.Combine(path, fileName)); proj.AddFileToBuild(target, proj.AddFile(fileName, fileName, PBXSourceTree.Source)); // Yosemiteでipaが書き出せないエラーに対応するための設定 proj.SetBuildProperty(target, "CODE_SIGN_RESOURCE_RULES_PATH", "$(SDKROOT)/ResourceRules.plist"); // フレームワークの検索パスを設定・追加 proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks"); // 書き出し File.WriteAllText(projPath, proj.WriteToString()); } }
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target == BuildTarget.iOS) { //Disable metal for the remote display sample. Metal is not supported due to shaders used in the source Unity sample. PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.iOS, false); GraphicsDeviceType[] apis = { GraphicsDeviceType.OpenGLES2 }; PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, apis); // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string projTarget = proj.TargetGuidByName("Unity-iPhone"); var file = "ULSGPUAssets.bin"; var dstLocalPath = "Frameworks/" + file; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy("Assets/ULSFaceTracker/Plugins/iOS/" + file, dstPath, true); proj.AddFileToBuild(projTarget, proj.AddFile(dstLocalPath, dstLocalPath)); File.WriteAllText(projPath, proj.WriteToString()); #endif } else if (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64) { string path = pathToBuiltProject.Substring(0, pathToBuiltProject.IndexOf(".exe")) + "_Data/Plugins/model"; FileUtil.CopyFileOrDirectory("Assets/ULSFaceTracker/Plugins/model", path); } }
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { #if UNITY_4_6 if (buildTarget == BuildTarget.iPhone) #else if (buildTarget == BuildTarget.iOS) #endif { string projPath = PBXProject.GetPBXProjectPath(path); // Fix on 4.6.x #if UNITY_4_6 if(!projPath.Contains("Unity-iPhone.xcodeproj")) { projPath = projPath.Replace("Unity-iPhone", "Unity-iPhone.xcodeproj"); } #endif PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string targetName = PBXProject.GetUnityTargetName(); string target = proj.TargetGuidByName(targetName); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("Frameworks/AdSupport.framework", "Frameworks/AdSupport.framework", PBXSourceTree.Sdk)); File.WriteAllText(projPath, proj.WriteToString()); } }
private static void PostProcessIosBuild(string pathToBuiltProject) { UnityEditor.iOS.Xcode.PBXProject project = new UnityEditor.iOS.Xcode.PBXProject(); string pbxPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(pathToBuiltProject); project.ReadFromFile(pbxPath); #if UNITY_2019_3_OR_NEWER string targetId = project.GetUnityFrameworkTargetGuid(); #else string targetId = project.TargetGuidByName(UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName()); #endif project.AddFrameworkToProject(targetId, "AdSupport.framework", false); project.AddFrameworkToProject(targetId, "CoreTelephony.framework", false); project.AddFrameworkToProject(targetId, "StoreKit.framework", false); project.AddFrameworkToProject(targetId, "WebKit.framework", false); project.AddFileToBuild(targetId, project.AddFile("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", UnityEditor.iOS.Xcode.PBXSourceTree.Sdk)); project.AddFileToBuild(targetId, project.AddFile("usr/lib/libz.1.1.3.dylib", "Frameworks/libz.1.1.3.dylib", UnityEditor.iOS.Xcode.PBXSourceTree.Sdk)); project.AddBuildProperty(targetId, "OTHER_LDFLAGS", "-ObjC"); project.WriteToFile(pbxPath); Debug.Log("Vungle iOS post processor completed."); }
private static void AddFolderBuild(PBXProject proj, string xcodePath, string root) { //获得源文件下所有目录文件 string currDir = Path.Combine(xcodePath, root); if (root.EndsWith(".framework") || root.EndsWith(".xcframework") || root.EndsWith(".bundle")) { string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); string fileGuid = proj.AddFile(root, root, PBXSourceTree.Source); proj.AddFileToBuild(target, fileGuid); SetEmbedFrameworks(proj, root, fileGuid); Console.WriteLine(string.Format("add framework or bundle to build:{0}->{1}", currDir, root)); return; } List <string> folders = new List <string>(Directory.GetDirectories(currDir)); foreach (string folder in folders) { string name = Path.GetFileName(folder); string t_path = Path.Combine(currDir, name); string t_projPath = Path.Combine(root, name); if (folder.EndsWith(".framework") || folder.EndsWith(".xcframework") || folder.EndsWith(".bundle")) { string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); string fileGuid = proj.AddFile(t_projPath, t_projPath, PBXSourceTree.Source); proj.AddFileToBuild(target, fileGuid); AutoAddSearchPath(proj, xcodePath, t_path); SetEmbedFrameworks(proj, t_projPath, fileGuid); Console.WriteLine(string.Format("add framework or bundle to build:{0}->{1}", t_path, t_projPath)); } else { AddFolderBuild(proj, xcodePath, t_projPath); } } List <string> files = new List <string>(Directory.GetFiles(currDir)); foreach (string file in files) { if (NeedCopy(file)) { string name = Path.GetFileName(file); string t_path = Path.Combine(currDir, name); string t_projPath = Path.Combine(root, name); string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); string fileGuid = proj.AddFile(t_projPath, t_projPath, PBXSourceTree.Source); proj.AddFileToBuild(target, fileGuid); AutoAddSearchPath(proj, xcodePath, t_path); SetEmbedFrameworks(proj, t_projPath, fileGuid); Console.WriteLine("add file to build:" + Path.Combine(root, file)); } } }
private static void ProcessPostBuild (BuildTarget buildTarget, string path) { string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); // //Required Frameworks proj.AddFrameworkToProject(target, "AudioToolbox.framework", false); proj.AddFrameworkToProject(target, "AVFoundation.framework", false); proj.AddFrameworkToProject(target, "CoreGraphics.framework", false); proj.AddFrameworkToProject(target, "CoreTelephony.framework", false); proj.AddFrameworkToProject(target, "CoreMedia.framework", false); proj.AddFrameworkToProject(target, "EventKit.framework", false); proj.AddFrameworkToProject(target, "EventKitUI.framework", false); proj.AddFrameworkToProject(target, "MediaPlayer.framework", false); proj.AddFrameworkToProject(target, "MessageUI.framework", false); proj.AddFrameworkToProject(target, "QuartzCore.framework", false); proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.1.2.5.dylib", "Frameworks/libz.1.2.5.dylib", PBXSourceTree.Sdk)); //Optional Frameworks proj.AddFrameworkToProject(target, "AdSupport.framework", true); proj.AddFrameworkToProject(target, "Social.framework", true); proj.AddFrameworkToProject(target, "StoreKit.framework", true); proj.AddFrameworkToProject(target, "Webkit.framework", true); File.WriteAllText(projPath, proj.WriteToString()); }
private static void EditXcodeProject(string buildFolder) { PBXProject project = new PBXProject(); string path = Path.Combine(buildFolder, FileUtil.NiceWinPath("Unity-iPhone.xcodeproj/project.pbxproj")); project.ReadFromFile(path); string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName()); if (AdvertisementSettings.enabled && AdvertisementSettings.IsPlatformEnabled(RuntimePlatform.IPhonePlayer)) { string target = Path.Combine(buildFolder, Path.Combine("UnityAds", "UnityAds.framework")); FileUtil.CopyDirectoryRecursive(Path.Combine(extensionPath, FileUtil.NiceWinPath("Editor/Resources/iOS/builds/UnityAds.framework")), target, true); project.AddFileToBuild(targetGuid, project.AddFile(Path.Combine("UnityAds", "UnityAds.framework"), "Frameworks/UnityAds.framework", PBXSourceTree.Source)); project.AddBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/UnityAds"); project.AddFrameworkToProject(targetGuid, "AdSupport.framework", true); project.AddFrameworkToProject(targetGuid, "StoreKit.framework", false); project.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", false); } else { project.RemoveFile(project.FindFileGuidByRealPath(Path.Combine("UnityAds", "UnityAds.framework"))); string[] removeValues = new string[] { "$(SRCROOT)/UnityAds" }; project.UpdateBuildProperty(targetGuid, "FRAMEWORK_SEARCH_PATHS", null, removeValues); string str5 = Path.Combine(buildFolder, "UnityAds"); if (Directory.Exists(str5)) { Directory.Delete(str5, true); } } project.AddFileToBuild(targetGuid, project.AddFile("UnityAdsConfig.h", "Classes/UnityAds/UnityAdsConfig.h")); project.WriteToFile(path); }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity")); string[] filesToCopy = new string[] { "PlatformBase.h", "RenderAPI_Metal.mm", "RenderAPI_OpenGLCoreES.cpp", "RenderAPI.cpp", "RenderAPI.h", "RenderingPlugin.cpp", }; for (int i = 0; i < filesToCopy.Length; ++i) { var srcPath = Path.Combine("../PluginSource/source", filesToCopy[i]); var dstLocalPath = "Libraries/" + filesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); #endif // #if UNITY_IOS }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false); string target = proj.TargetGuidByName("Unity-iPhone"); proj.SetBuildProperty(target, "DEVELOPMENT_TEAM", "Z6SFPV59E3"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity")); string[] filesToCopy = new string[] { }; for (int i = 0; i < filesToCopy.Length; ++i) { var srcPath = Path.Combine("../PluginSource/source", filesToCopy[i]); var dstLocalPath = "Libraries/" + filesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); #endif // #if UNITY_IOS }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "AssetsLibrary.framework", false); string target = proj.TargetGuidByName("Unity-iPhone"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Sturfee/Plugins/iOS/Shared")); string[] sturGLoaderfilesToCopy = new string[] { "PlatformBase.hpp", "UnityInterface.hpp", }; string[] sharedFilesToCopy = new string[] { "SturgProcesser.hpp", "SFDataStream.hpp", "SFLogger.hpp", }; for (int i = 0; i < sturGLoaderfilesToCopy.Length; ++i) { var srcPath = Path.Combine(Path.Combine(Application.dataPath, "Sturfee/Plugins/iOS/SturGLoader/Include"), sturGLoaderfilesToCopy[i]); var dstLocalPath = "Libraries/Sturfee/Plugins/iOS/SturGLoader/Include/" + sturGLoaderfilesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } for (int i = 0; i < sharedFilesToCopy.Length; ++i) { var srcPath = Path.Combine(Path.Combine(Application.dataPath, "Sturfee/Plugins/iOS/Shared"), sharedFilesToCopy[i]); var dstLocalPath = "Libraries/Sturfee/Plugins/iOS/Shared/" + sharedFilesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); #endif // #if UNITY_IOS }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false); string target = proj.TargetGuidByName("Unity-iPhone"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity")); //check UnityARKitPluginSettings UnityARKitPluginSettings ps = LoadSettings(); if (ps.AppRequiresARKit) { //add plist entry string plistPath = Path.Combine(pathToBuiltProject, "Info.plist"); PlistDocument plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); PlistElementDict rootDict = plist.root; const string capsKey = "UIRequiredDeviceCapabilities"; PlistElementArray capsArray; PlistElement pel; if (rootDict.values.TryGetValue(capsKey, out pel)) { capsArray = pel.AsArray(); } else { capsArray = rootDict.CreateArray(capsKey); } capsArray.AddString("arkit"); File.WriteAllText(plistPath, plist.WriteToString()); } //add or replace define for facetracking UpdateDefinesInFile(pathToBuiltProject + "/Classes/Preprocessor.h", new Dictionary <string, bool>() { { "ARKIT_USES_FACETRACKING", ps.m_ARKitUsesFacetracking } }); string[] filesToCopy = new string[] { }; for (int i = 0; i < filesToCopy.Length; ++i) { var srcPath = Path.Combine("../PluginSource/source", filesToCopy[i]); var dstLocalPath = "Libraries/" + filesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); #endif // #if UNITY_IOS }
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject) { if (buildTarget != BuildTarget.iOS) { return; } PBXProject project = new PBXProject(); string pbxProjectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; project.ReadFromString(File.ReadAllText(pbxProjectPath)); string target = project.TargetGuidByName(PBXProject.GetUnityTargetName()); string testTarget = project.TargetGuidByName(PBXProject.GetUnityTestTargetName()); // Linker flags. project.SetBuildProperty(target, "ARCHS", "$(ARCHS_STANDARD)"); project.SetBuildProperty(testTarget, "ARCHS", "$(ARCHS_STANDARD)"); project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC"); project.AddBuildProperty(testTarget, "OTHER_LDFLAGS", "-ObjC"); project.AddBuildProperty(target, "OTHER_LDFLAGS", "-lz"); project.AddBuildProperty(testTarget, "OTHER_LDFLAGS", "-lz"); // Search paths. project.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks"); // Framework dependencies. project.AddFrameworkToProject(target, "AVFoundation.framework", true); project.AddFrameworkToProject(target, "Accelerate.framework", true); project.AddFrameworkToProject(target, "CFNetwork.framework", true); project.AddFrameworkToProject(target, "CoreBluetooth.framework", true); project.AddFrameworkToProject(target, "CoreText.framework", true); project.AddFrameworkToProject(target, "MediaPlayer.framework", true); project.AddFrameworkToProject(target, "MediaToolbox.framework", true); project.AddFrameworkToProject(target, "Metal.framework", true); project.AddFrameworkToProject(target, "Security.framework", true); project.AddFrameworkToProject(target, "SystemConfiguration.framework", true); // Dynamic library dependencies. string sqlite3dylibGuid = project.AddFile("usr/lib/libsqlite3.dylib", "usr/lib/libsqlite3.dylib", PBXSourceTree.Sdk); project.AddFileToBuild(target, sqlite3dylibGuid); string libCppdylibGuid = project.AddFile("usr/lib/libc++.dylib", "usr/lib/libc++.dylib", PBXSourceTree.Sdk); project.AddFileToBuild(target, libCppdylibGuid); File.WriteAllText(pbxProjectPath, project.WriteToString()); }
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) { string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("Frameworks/AdSupport.framework", "Frameworks/AdSupport.framework", PBXSourceTree.Sdk)); File.WriteAllText(projPath, proj.WriteToString()); } }
public static void OnPostProcessBuild(BuildTarget buildTarget, string path) { string projPath = Path.Combine(path, "Unity-iPhone.xcodeproj/project.pbxproj"); PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.1.2.5.tbd", "Frameworks/libz.1.2.5.tbd", PBXSourceTree.Sdk)); File.WriteAllText(projPath, proj.WriteToString()); }
private static void UpdatePbxProject(string projectPath, string buildPath) { PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projectPath)); string[] frameworks = { "CFNetwork.framework", "CoreGraphics.framework", "Foundation.framework", "MobileCoreServices.framework", "Security.framework", "SystemConfiguration.framework", "UIKit.framework", "CoreTelephony.framework", "CoreLocation.framework", "CoreData.framework", "UserNotifications.framework" }; string[] targets = { proj.TargetGuidByName(PBXProject.GetUnityTargetName()), proj.TargetGuidByName(PBXProject.GetUnityTestTargetName()) }; string airshipConfig = Path.Combine(buildPath, "AirshipConfig.plist"); if (File.Exists(airshipConfig)) { File.Delete(airshipConfig); } File.Copy(Path.Combine(Application.dataPath, "Plugins/iOS/AirshipConfig.plist"), airshipConfig); string airshipGUID = proj.AddFile("AirshipConfig.plist", "AirshipConfig.plist", PBXSourceTree.Source); foreach (string target in targets) { proj.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)"); proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC -lz -lsqlite3"); proj.AddFileToBuild(target, airshipGUID); foreach (string framework in frameworks) { proj.AddFrameworkToProject(target, framework, false); UnityEngine.Debug.Log ("Adding framework: " + framework); } } File.WriteAllText(projectPath, proj.WriteToString()); }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS //Handle plist string plistPath = pathToBuiltProject + "/Info.plist"; PlistDocument plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); PlistElementDict rootDict = plist.root; rootDict.SetString("CFBundleVersion", "1.0.67"); rootDict.SetString("NSPhotoLibraryUsageDescription", "Use Photo"); rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Use Photo 11"); rootDict.SetString("NSCameraUsageDescription", "Use Camera"); File.WriteAllText(plistPath, plist.WriteToString()); string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "CoreImage.framework", false); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "Accelerate.framework", false); string target = proj.TargetGuidByName("Unity-iPhone"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity")); string[] filesToCopy = new string[] { }; for (int i = 0; i < filesToCopy.Length; ++i) { var srcPath = Path.Combine("../PluginSource/source", filesToCopy[i]); var dstLocalPath = "Libraries/" + filesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); CopyFile("GestureFile/libpaddle_capi_layers.a", "libpaddle_capi_layers.a", pathToBuiltProject); CopyFile("pose/pose.bin", "pose.bin", pathToBuiltProject); // CopyFile("pose/opencv2.framework.zip", "opencv2.framework.zip", pathToBuiltProject); // CopyFile("IOS_Pose/libpaddle_capi_layers.a" ,pathToBuiltProject); #endif }
private static void CopyFile(PBXProject proj, string xcodePath, string src, string des) { bool needCopy = NeedCopy(src); if (needCopy) { File.Copy(src, des); string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); // The path is relative to the source folder string relativePath = des.Replace(xcodePath + "/", ""); string fileGuid = proj.AddFile(relativePath, relativePath, PBXSourceTree.Source); proj.AddFileToBuild(target, fileGuid); AutoAddSearchPath(proj, xcodePath, des); SetEmbedFrameworks(proj, src, fileGuid); Console.WriteLine("copy file " + src + " -> " + des); } }
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) { string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); proj.AddFileToBuild(target, proj.AddFile("usr/lib/Security.framework", "Frameworks/Security.framework", PBXSourceTree.Sdk)); proj.SetBuildProperty(target, "ENABLE_BITCODE", "false"); File.WriteAllText(projPath, proj.WriteToString()); } }
//设置Capabilities void SetCapabilities(string pathToBuildProject) { string projPath = pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; //项目路径,这个路径在mac上默认是不显示的,需要右键->显示包内容才能看到。unity到处的名字就是这个。 UnityEditor.iOS.Xcode.PBXProject pbxProj = new UnityEditor.iOS.Xcode.PBXProject(); //创建xcode project类 pbxProj.ReadFromString(File.ReadAllText(projPath)); //xcode project读入 string targetGuid = pbxProj.TargetGuidByName(PBXProject.GetUnityTargetName()); //获得Target名 //设置BuildSetting pbxProj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO"); pbxProj.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC"); pbxProj.SetBuildProperty(targetGuid, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); //定位崩溃bug pbxProj.SetBuildProperty(targetGuid, "EXCLUDED_ARCHS", "armv7"); pbxProj.AddFrameworkToProject(targetGuid, "MediaPlayer.framework", false); pbxProj.AddFrameworkToProject(targetGuid, "AdSupport.framework", true); //添加资源 pbxProj.AddFileToBuild(targetGuid, pbxProj.AddFile(System.Environment.CurrentDirectory + "/LTBaseSDK_Oversea/ltgame.cfg", "Resource/ltgame.cfg", PBXSourceTree.Source)); //修改编译方式 string mmfile = pbxProj.FindFileGuidByProjectPath("Classes/UnityAppController.mm"); var flags = pbxProj.GetCompileFlagsForFile(targetGuid, mmfile); flags.Add("-fno-objc-arc"); pbxProj.SetCompileFlagsForFile(targetGuid, mmfile, flags); mmfile = pbxProj.FindFileGuidByProjectPath("Libraries/Plugins/IOS/LTSDK/LTSDKNPC.mm"); flags = pbxProj.GetCompileFlagsForFile(targetGuid, mmfile); flags.Add("-fno-objc-arc"); pbxProj.SetCompileFlagsForFile(targetGuid, mmfile, flags); pbxProj.WriteToFile(projPath); string[] splits = PlayerSettings.applicationIdentifier.Split('.'); var capManager = new ProjectCapabilityManager(projPath, splits[splits.Length - 1] + ".entitlements", PBXProject.GetUnityTargetName());//创建设置Capability类 if (PlayerSettings.applicationIdentifier.Equals("com.longtugame.dzyz.longtu")) { //正式包,增加计费 capManager.AddInAppPurchase(); } capManager.AddAssociatedDomains(new[] { "applinks:dy.longtugame.com" }); capManager.WriteToFile();//写入文件保存 }
private static void AddLibToProject(PBXProject inst, string targetGuid, string lib) { string fileGuid = inst.AddFile("usr/lib/" + lib, "Frameworks/" + lib, PBXSourceTree.Sdk); inst.AddFileToBuild(targetGuid, fileGuid); }
/// <summary> /// 指定ディレクトリをXcodeにコピーして追加する /// </summary> public static void CopyAndAddBuildToXcode( PBXProject pbxProject, string targetGuid, string copyDirectoryPath, string buildPath, string currentDirectoryPath, bool needToAddBuild = true ) { //コピー元(Unity)のディレクトリとコピー先(Xcode)のディレクトリのパスを作成 string unityDirectoryPath = copyDirectoryPath; string xcodeDirectoryPath = buildPath; //ディレクトリ内のディレクトリの中身をコピーしている場合 if(!string.IsNullOrEmpty(currentDirectoryPath)){ unityDirectoryPath = Path.Combine(unityDirectoryPath, currentDirectoryPath); xcodeDirectoryPath = Path.Combine(xcodeDirectoryPath, currentDirectoryPath); //既にディクショナリーがある場合は削除し、新たにディクショナリー作成 Delete (xcodeDirectoryPath); Directory.CreateDirectory(xcodeDirectoryPath); } //ファイルをコピーし、プロジェクトへの追加も行う foreach (string filePath in Directory.GetFiles(unityDirectoryPath)){ //metaファイルはコピーしない string extension = Path.GetExtension (filePath); if(extension == ExtensionName.META){ continue; } //アーカイブファイルの場合は、それが入っているディレクトリにパスを通す else if(extension == ExtensionName.ARCHIVE){ pbxProject.AddBuildProperty( targetGuid, XcodeProjectSetting.LIBRARY_SEARCH_PATHS_KEY, XcodeProjectSetting.PROJECT_ROOT + currentDirectoryPath ); } //ファイルパスからファイル名を取得し、コピー先のパスを作成 string fileName = Path.GetFileName (filePath); string copyPath = Path.Combine (xcodeDirectoryPath, fileName); //隠しファイルはコピーしない .DS_Storeとか if(fileName[0] == '.'){ continue; } //既に同名ファイルがある場合は削除、その後コピー File.Delete(copyPath); File.Copy(filePath, copyPath); if(needToAddBuild){ //プロジェクト内へ追加する時のパスは、ビルドしたディレクトリからの相対パス string relativePath = Path.Combine(currentDirectoryPath, fileName); pbxProject.AddFileToBuild(targetGuid, pbxProject.AddFile(relativePath, relativePath, PBXSourceTree.Source)); } } //ディレクトリの中にあるディレクトリの中もコピー foreach (string directoryPath in Directory.GetDirectories(unityDirectoryPath)){ string directoryName = Path.GetFileName (directoryPath); bool nextNeedToAddBuild = needToAddBuild; //フレームワークやImages.xcassetsがが入っているディレクトリはコピーするだけ if(directoryName.Contains(ExtensionName.FRAMEWORK) || directoryName.Contains(ExtensionName.BUNDLE) || directoryName == XcodeProjectSetting.IMAGE_XCASSETS_DIRECTORY_NAME){ nextNeedToAddBuild = false; } CopyAndAddBuildToXcode ( pbxProject, targetGuid, copyDirectoryPath, buildPath, Path.Combine(currentDirectoryPath, directoryName), nextNeedToAddBuild ); //フレームワークはディレクトリ内を全てコピーしてから、フレームワークごとプロジェクトに追加し、フレームワーク検索パスを通す if(directoryName.Contains(ExtensionName.FRAMEWORK) || directoryName.Contains(ExtensionName.BUNDLE)){ string relativePath = Path.Combine(currentDirectoryPath, directoryName); pbxProject.AddFileToBuild(targetGuid, pbxProject.AddFile(relativePath, relativePath, PBXSourceTree.Source)); pbxProject.AddBuildProperty( targetGuid, XcodeProjectSetting.FRAMEWORK_SEARCH_PATHS_KEY, XcodeProjectSetting.PROJECT_ROOT + currentDirectoryPath ); } } }
static void OnPostprocessBuild(BuildTarget buildTarget, string path) { if (buildTarget != BuildTarget.iOS) return; /*------------------------------------------------------*/ // for frameworks string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; Debug.Log("Build iOS. path: " + projPath); PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); // string debugConfig = proj.BuildConfigByName(target, "Debug"); // string releaseConfig = proj.BuildConfigByName(target, "Release"); // Add custom system frameworks. Duplicate frameworks are ignored. // needed by our native plugin in Assets/Plugins/iOS // proj.AddFrameworkToProject(target, ".framework", false /*not weak*/); // Add usr/lib string framenwork1 = "libz.dylib"; string framenwork2 = "libsqlite3.0.dylib"; string fileGuid1 = proj.AddFile ("usr/lib/"+framenwork1, "Frameworks/"+framenwork1, PBXSourceTree.Sdk); string fileGuid2 = proj.AddFile ("usr/lib/"+framenwork2, "Frameworks/"+framenwork2, PBXSourceTree.Sdk); proj.AddFileToBuild (target, fileGuid1); proj.AddFileToBuild (target, fileGuid2); // Add our framework directory to the framework include path proj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); proj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks"); // proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC"); proj.AddBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); File.WriteAllText(projPath, proj.WriteToString()); /*------------------------------------------------------*/ // for Info.plist // PlistDocument // http://docs.unity3d.com/ScriptReference/iOS.Xcode.PlistDocument.html // Get plist var plistPath = Path.Combine(path, "Info.plist"); var plist = new PlistDocument(); plist.ReadFromFile(plistPath); // Get root PlistElementDict rootDict = plist.root; // Create URL types string identifier = PlayerPrefs.GetString ("identifier"); string scheme = PlayerPrefs.GetString ("scheme"); PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes"); PlistElementDict dict = urlTypesArray.AddDict (); dict.SetString ("CFBundleURLName", identifier); PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes"); schemesArray.AddString (scheme); // PlistElementArray urlTypesArray = rootDict.CreateArray ("CFBundleURLTypes"); // PlistElementDict dict = urlTypesArray.AddDict (); // dict.SetString ("CFBundleURLName", "com.unitybuild.test"); // PlistElementArray schemesArray = dict.CreateArray ("CFBundleURLSchemes"); // schemesArray.AddString ("myscheme"); // Write to file File.WriteAllText(plistPath, plist.WriteToString()); }
private static void OnPostprocessBuildIOS(string pathToBuiltProject) { // We use UnityEditor.iOS.Xcode API which only exists in iOS editor module #if UNITY_IOS string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); proj.AddFrameworkToProject(proj.TargetGuidByName("Unity-iPhone"), "ARKit.framework", false); string target = proj.TargetGuidByName("Unity-iPhone"); Directory.CreateDirectory(Path.Combine(pathToBuiltProject, "Libraries/Unity")); // Check UnityARKitPluginSettings UnityARKitPluginSettings ps = LoadSettings(); string plistPath = Path.Combine(pathToBuiltProject, "Info.plist"); PlistDocument plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); PlistElementDict rootDict = plist.root; // Get or create array to manage device capabilities const string capsKey = "UIRequiredDeviceCapabilities"; PlistElementArray capsArray; PlistElement pel; if (rootDict.values.TryGetValue(capsKey, out pel)) { capsArray = pel.AsArray(); } else { capsArray = rootDict.CreateArray(capsKey); } // Remove any existing "arkit" plist entries const string arkitStr = "arkit"; capsArray.values.RemoveAll(x => arkitStr.Equals(x.AsString())); if (ps.AppRequiresARKit) { // Add "arkit" plist entry capsArray.AddString(arkitStr); } File.WriteAllText(plistPath, plist.WriteToString()); foreach (ARReferenceImagesSet ar in imageSets) { AddReferenceImagesSetToAssetCatalog(ar, pathToBuiltProject, proj); } //TODO: remove this when XCode actool is able to handles ARResources despite deployment target if (imageSets.Count > 0) { proj.SetBuildProperty(target, "IPHONEOS_DEPLOYMENT_TARGET", "11.3"); } // Add or replace define for facetracking UpdateDefinesInFile(pathToBuiltProject + "/Classes/Preprocessor.h", new Dictionary <string, bool>() { { "ARKIT_USES_FACETRACKING", ps.m_ARKitUsesFacetracking } }); string[] filesToCopy = new string[] { }; for (int i = 0; i < filesToCopy.Length; ++i) { var srcPath = Path.Combine("../PluginSource/source", filesToCopy[i]); var dstLocalPath = "Libraries/" + filesToCopy[i]; var dstPath = Path.Combine(pathToBuiltProject, dstLocalPath); File.Copy(srcPath, dstPath, true); proj.AddFileToBuild(target, proj.AddFile(dstLocalPath, dstLocalPath)); } File.WriteAllText(projPath, proj.WriteToString()); #endif // #if UNITY_IOS }
public static void OnPostProcessBuild(BuildTarget target, string path) { var pbxProjectPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(path); var pbxProject = new UnityEditor.iOS.Xcode.PBXProject(); pbxProject.ReadFromString(System.IO.File.ReadAllText(pbxProjectPath)); Debug.Log("TTPPostProcessSettings::Add swift support for mopub and ecpm"); pbxProject.AddBuildProperty(GetTargetGUID(pbxProject), "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"); pbxProject.AddBuildProperty(GetTargetGUID(pbxProject), "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift"); pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "LD_RUNPATH_SEARCH_PATHS", "/usr/lib/swift $(inherited) @executable_path/Frameworks"); pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES"); pbxProject.SetBuildProperty(GetTargetGUID(pbxProject), "SWIFT_VERSION", "5"); #if UNITY_2019_3_OR_NEWER var unityFrameworkTarget = pbxProject.GetUnityFrameworkTargetGuid(); pbxProject.AddBuildProperty(unityFrameworkTarget, "LIBRARY_SEARCH_PATHS", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"); pbxProject.AddBuildProperty(unityFrameworkTarget, "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift"); pbxProject.SetBuildProperty(unityFrameworkTarget, "LD_RUNPATH_SEARCH_PATHS", "/usr/lib/swift $(inherited) @executable_path/Frameworks"); pbxProject.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO"); pbxProject.SetBuildProperty(unityFrameworkTarget, "SWIFT_VERSION", "5"); var mainTargetLinkFrameworksId = pbxProject.GetFrameworksBuildPhaseByTarget(pbxProject.GetUnityMainTargetGuid()); var unityFrameworkBuildProductId = pbxProject.GetTargetProductFileRef(pbxProject.GetUnityFrameworkTargetGuid()); Debug.Log("Linking unity framework to main target to support unity 2020 - " + mainTargetLinkFrameworksId + ", " + unityFrameworkBuildProductId); pbxProject.AddFileToBuildSection(pbxProject.GetUnityMainTargetGuid(), mainTargetLinkFrameworksId, unityFrameworkBuildProductId); #endif #if UNITY_2019_3_OR_NEWER //Add BUAdASDK.bundle string pathToBUAdSDK = "Data/Raw/Bundle/BUAdSDK.bundle"; string absPathToBUADSDK = Path.Combine(path, pathToBUAdSDK); if (Directory.Exists(absPathToBUADSDK)) { Debug.Log("TTPPostProcessSettings :: Adding BUAdSDK.bundle"); pbxProject.AddFileToBuild(GetTargetGUID(pbxProject), pbxProject.AddFile(pathToBUAdSDK, "BUAdSDK.bundle")); } else { Debug.Log("TTPPostProcessSettings :: BUAdSDK.bundle not exists"); } //END BUAdSDK string pathToTapJoyBundle = "Data/Raw/Bundle/TapjoyResources.bundle"; string absPathTapJoyBundle = Path.Combine(path, pathToBUAdSDK); if (Directory.Exists(absPathTapJoyBundle)) { Debug.Log("TTPPostProcessSettings :: Adding TapjoyResources.bundle"); pbxProject.AddFileToBuild(GetTargetGUID(pbxProject), pbxProject.AddFile(pathToTapJoyBundle, "TapjoyResources.bundle")); } else { Debug.Log("TTPAddTiktokBundle.cs :: TapjoyResources.bundle not exists"); } #endif File.WriteAllText(pbxProjectPath, pbxProject.WriteToString()); var plistPath = Path.Combine(path, "Info.plist"); var plist = new PlistDocument(); plist.ReadFromFile(plistPath); rootDict = plist.root; rootDict.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS", false); rootDict.SetBoolean("FIREBASE_ANALYTICS_COLLECTION_ENABLED", false); // Add AppLovinSdkKey if (Application.identifier == "com.tabtaleint.ttplugins" || Application.identifier == "com.tabtaleint.ttplugins" || Application.identifier == "com.tabtaleint.ttplugins") { rootDict.SetString("AppLovinSdkKey", "yRHC8kgWwG5S4lOh7Dx_pZB2iEBLVWMSzde5MKbGahifQ6MTKIT7tk9ZzLvTsFwptZvDuVTTBB8cHU9bohkeQu"); } else { rootDict.SetString("AppLovinSdkKey", "TREvWeSbneklepMTdxWL5KCqUD57xezP4CIarlBcOwM1kiVMe0hkLvTq7dy3HwSL6mxyV7Tu1wwlcP5FQo-nhW"); } var array = rootDict.CreateArray("SKAdNetworkItems"); //admob array.AddDict().SetString("SKAdNetworkIdentifier", "cstr6suwn9.skadnetwork"); //applovin array.AddDict().SetString("SKAdNetworkIdentifier", "ludvb6z3bs.skadnetwork"); //ironsource array.AddDict().SetString("SKAdNetworkIdentifier", "su67r6k2v3.skadnetwork"); //adcolony array.AddDict().SetString("SKAdNetworkIdentifier", "4pfyvq9l8r.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "4fzdc2evr5.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "4468km3ulz.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "3rd42ekr43.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "m8dbw4sv7c.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "ejvt5qm6ak.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "mtkv5xtk9e.skadnetwork"); //chartboost array.AddDict().SetString("SKAdNetworkIdentifier", "f38h382jlk.skadnetwork"); //facebook array.AddDict().SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork"); //hypermx array.AddDict().SetString("SKAdNetworkIdentifier", "nu4557a4je.skadnetwork"); //inmobi array.AddDict().SetString("SKAdNetworkIdentifier", "wzmmz9fp6w.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "uw77j35x4d.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "7ug5zh24hu.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "hs6bdukanm.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "ggvn48r87g.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "5lm9lj6jb7.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "9rd848q2bz.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "c6k4g5qg8m.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "3sh42y64q3.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "yclnxrl5pm.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "f73kdq92p3.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "ydx93a7ass.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "w9q455wk68.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "prcb7njmu6.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "wg4vff78zm.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "mlmmfzh3r3.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "tl55sbb4fm.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "t38b2kh725.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "5l3tpt7t6e.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "7rz58n8ntl.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "klf5c3l5u5.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "cg4yq2srnc.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "av6w8kgt66.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "9t245vhmpl.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "v72qych5uu.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "2u9pt9hc89.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "44jx6755aq.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "8s468mfl3y.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "p78axxw29g.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "ppxm28t8ap.skadnetwork"); //mintegral array.AddDict().SetString("SKAdNetworkIdentifier", "kbd757ywx3.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "glqzh8vgby.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "6xzpu9s2p8.skadnetwork"); //pangle array.AddDict().SetString("SKAdNetworkIdentifier", "22mmun2rn5.skadnetwork"); //non cn array.AddDict().SetString("SKAdNetworkIdentifier", "238da6jt44.skadnetwork"); //cn //tapjoy array.AddDict().SetString("SKAdNetworkIdentifier", "ecpz2srf59.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "578prtvx9j.skadnetwork"); //unity ads array.AddDict().SetString("SKAdNetworkIdentifier", "4dzt52r2t5.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "488r3q3dtq.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "zmvfpc5aq8.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "v79kvwwj4g.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "lr83yxwka7.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "44n7hlldy6.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "424m5254lk.skadnetwork"); //vungle array.AddDict().SetString("SKAdNetworkIdentifier", "gta9lk7p23.skadnetwork"); //mopub array.AddDict().SetString("SKAdNetworkIdentifier", "cdkw7geqsh.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "qyjfv329m4.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "3qy4746246.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "523jb4fst2.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "5a6flpkh64.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "737z793b9f.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "7953jerfzd.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "97r2b46745.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "9yg77x724h.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "bvpn9ufa9b.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "cj5566h2ga.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "gvmwg8q7h5.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "mls7yz5dvl.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "n66cz3y3bx.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "n9x2a789qt.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "nzq8sh4pbs.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "pu4na253f3.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "u679fj5vs4.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "xy9t38ct57.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "z4gj7hsk7h.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "s39g8k73mm.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "24t9a8vw3c.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "yrqqpx2mcb.skadnetwork"); array.AddDict().SetString("SKAdNetworkIdentifier", "52fl2v3hgk.skadnetwork"); // fix problem with statusbar on iOS 14 if (!rootDict.values.ContainsKey("UIViewControllerBasedStatusBarAppearance")) { rootDict.SetBoolean("UIViewControllerBasedStatusBarAppearance", false); } File.WriteAllText(plistPath, plist.WriteToString()); }
public static void OnPostProcessBuild (BuildTarget buildTarget, string path) { #if UNITY_ANDROID #elif UNITY_IPHONE string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject pbxProj = new PBXProject (); pbxProj.ReadFromFile (projPath); string target = pbxProj.TargetGuidByName (PBXProject.GetUnityTargetName ()); pbxProj.AddFrameworkToProject (target, "AssetsLibrary.framework", false); pbxProj.AddFrameworkToProject (target, "AudioToolbox.framework", false); pbxProj.AddFrameworkToProject (target, "AVFoundation.framework", false); pbxProj.AddFrameworkToProject (target, "CFNetwork.framework", false); pbxProj.AddFrameworkToProject (target, "CoreAudio.framework", false); pbxProj.AddFrameworkToProject (target, "CoreLocation.framework", false); pbxProj.AddFrameworkToProject (target, "CoreMedia.framework", false); pbxProj.AddFrameworkToProject (target, "CoreTelephony.framework", false); pbxProj.AddFrameworkToProject (target, "CoreVideo.framework", false); pbxProj.AddFrameworkToProject (target, "CoreGraphics.framework", false); pbxProj.AddFrameworkToProject (target, "ImageIO.framework", false); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++.dylib", "Frameworks/libc++.dylib", PBXSourceTree.Sdk)); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libc++abi.dylib", "Frameworks/libc++abi.dylib", PBXSourceTree.Sdk)); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk)); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libstdc++.dylib", "Frameworks/libstdc++.dylib", PBXSourceTree.Sdk)); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libxml2.dylib", "Frameworks/libxml2.dylib", PBXSourceTree.Sdk)); pbxProj.AddFileToBuild (target, pbxProj.AddFile ("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk)); pbxProj.AddFrameworkToProject (target, "MapKit.framework", false); pbxProj.AddFrameworkToProject (target, "OpenGLES.framework", false); pbxProj.AddFrameworkToProject (target, "QuartzCore.framework", false); pbxProj.AddFrameworkToProject (target, "SystemConfiguration.framework", false); pbxProj.AddFrameworkToProject (target, "UIKit.framework", false); DirectoryInfo di = new DirectoryInfo (Application.dataPath); string rongCloudLibFloder = Path.Combine (di.Parent.FullName, "RongCloudLib"); CopyAndReplaceDirectory(Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), Path.Combine(path, "Frameworks/RongIMLib.framework")); pbxProj.AddFileToBuild(target, pbxProj.AddFile("Frameworks/RongIMLib.framework", "Frameworks/RongIMLib.framework", PBXSourceTree.Source)); // pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (rongCloudLibFloder, "RongIMLib.framework"), "Frameworks/RongIMLib.framework", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudBinding.m"), "Libraries/RongCloudBinding.m", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.m"), "Libraries/RongCloudManager.m", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/RongCloudManager.h"), "Libraries/RongCloudManager.h", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.h"), "Libraries/GroupOperationMessage.h", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupOperationMessage.m"), "Libraries/GroupOperationMessage.m", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.h"), "Libraries/GroupRequestMessage.h", PBXSourceTree.Absolute)); pbxProj.AddFileToBuild (target, pbxProj.AddFile (Path.Combine (Application.dataPath, "Editor/RongCloud/iOS/GroupRequestMessage.m"), "Libraries/GroupRequestMessage.m", PBXSourceTree.Absolute)); pbxProj.SetBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); pbxProj.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(PROJECT_DIR)/Frameworks"); pbxProj.WriteToFile (projPath); PlistDocument plist = new PlistDocument (); string plistPath = Path.Combine (path, "Info.plist"); plist.ReadFromFile (plistPath); var deviceCapabilities = plist.root ["UIRequiredDeviceCapabilities"].AsArray (); deviceCapabilities.AddString ("front-facing-camera"); deviceCapabilities.AddString ("video-camera"); // plist.root.SetBoolean ("LSHasLocalizedDisplayName", true); plist.WriteToFile (plistPath); #endif }