AddBuildProperty() public method

public AddBuildProperty ( IEnumerable targetGuids, string name, string value ) : void
targetGuids IEnumerable
name string
value string
return void
示例#1
1
    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 buildTarget, string path)
    {
        #if UNITY_5
        var expectedTarget = BuildTarget.iOS;
        #else
        var expectedTarget = BuildTarget.iPhone;
        #endif
        if (buildTarget == expectedTarget) {
            var projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            var project = new PBXProject();
            project.ReadFromString(File.ReadAllText(projectPath));

            var target = project.TargetGuidByName("Unity-iPhone");

            foreach (var frameworkName in StrongFrameworks) {
                project.AddFrameworkToProject(target, frameworkName + ".framework", false);
            }
            foreach (var frameworkName in WeakFrameworks) {
                project.AddFrameworkToProject(target, frameworkName + ".framework", true);
            }
            foreach (var flag in LDFlags) {
                project.AddBuildProperty(target, "OTHER_LDFLAGS", flag);
            }
            foreach (var libraryName in Libraries) {
                project.AddBuildProperty(target, "OTHER_LDFLAGS", "-l" + libraryName);
            }

            File.WriteAllText(projectPath, project.WriteToString());
        }
    }
示例#3
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        UnityEngine.Debug.Log("OnPostprocessBuild "+buildTarget+" "+path);

        if (buildTarget == BuildTarget.iOS) {

            string projectPath = PBXProject.GetPBXProjectPath(path);

            PBXProject project = new PBXProject();
            project.ReadFromFile(projectPath);

            UnityEngine.Debug.Log(PBXProject.GetUnityTargetName());
            string target = project.TargetGuidByName(PBXProject.GetUnityTargetName());

            UnityEngine.Debug.Log(target);

            // Add build settings for CocoaPods
            project.AddBuildProperty(target, "HEADER_SEARCH_PATHS", "$(inherited)");
            project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "$(inherited)");
            project.AddBuildProperty(target, "OTHER_CFLAGS", "$(inherited)");
            project.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)");

            // Disable Bitcode
            project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            // Copy Podfile into project
            string unityProjectRootPath = Path.GetFullPath("./").Normalize();
            UnityEngine.Debug.Log(unityProjectRootPath);

            // Default src location is the project root
            FileUtil.ReplaceFile("Assets/DeltaDNAAds/Editor/iOS/Podfile", path + "/Podfile");

            // Set Podfile platform version to match Unity
            #if UNITY_5_5_OR_NEWER
            var targetOSVersion = PlayerSettings.iOS.targetOSVersionString;
            string iosPlatform = targetOSVersion.ToString();
            UnityEngine.Debug.Log(iosPlatform);
            #else
            var targetOSVersion = PlayerSettings.iOS.targetOSVersion;
            string iosPlatform = targetOSVersion.ToString().Substring(4).Replace('_', '.');
            #endif

            var podfile = new List<string>(File.ReadAllLines(path + "/Podfile"));
            podfile = new List<string>(podfile.Select(e => e.StartsWith("platform") ? string.Format("platform :ios, '{0}'", iosPlatform) : e).AsEnumerable());
            File.WriteAllLines(path + "/Podfile", podfile.ToArray());

            // Update the XCode project on disk
            project.WriteToFile(projectPath);

            // Run pod update
            Process proc = new Process();
            proc.StartInfo.FileName = "/usr/local/bin/pod";
            proc.StartInfo.Arguments = "install --project-directory=\""+path+"\"";
            proc.StartInfo.UseShellExecute = false;
            proc.Start();
            proc.WaitForExit();
        }
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        #if UNITY_5
        if (buildTarget == BuildTarget.iOS)
        #else
        if (buildTarget == BuildTarget.iPhone)
        #endif
        {
            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));

            string target = proj.TargetGuidByName("Unity-iPhone");

            // Add custom system frameworks. Duplicate frameworks are ignored.
            // needed by our native plugin in Assets/Plugins/iOS
            proj.AddFrameworkToProject(target, "Security.framework", false /*not weak*/);
            proj.AddFrameworkToProject(target, "Social.framework", false /*not weak*/);
            proj.AddFrameworkToProject(target, "Accounts.framework", false /*not weak*/);
            proj.AddFrameworkToProject(target, "MediaPlayer.framework", false /*not weak*/);
            proj.AddFrameworkToProject(target, "MessageUI.framework", false /*not weak*/);
            proj.AddFrameworkToProject(target, "MobileCoreServices.framework", false /*not weak*/);

            proj.AddFrameworkToProject(target, "libc++.dylib", false /*not weak*/);

            // 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");

            // Set a custom link flag
            proj.AddBuildProperty(target, "GCC_PREPROCESSOR_DEFINITIONS", "$(CONFIGURATION) $(inherited)");
            proj.AddBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

            File.WriteAllText(projPath, proj.WriteToString());
        }

        // edit Info.plist
        /*var plistPath = Path.Combine(path, "Info.plist");

        var plist = new PlistDocument();

        plist.ReadFromFile(plistPath);

        plist.root.SetString("UIBackgroundModes", "voip");

        plist.WriteToFile(plistPath);*/
    }
        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());
        }
示例#6
0
    private static void EditorIOSAutoBuild(string buildPath)
    {
        #if UNITY_IOS
        var dummy = ScriptableObject.CreateInstance <XCodePostProcess>();
        var file  = dummy.m_entitlementsFile;
        ScriptableObject.DestroyImmediate(dummy);
        if (file == null)
        {
            return;
        }

        var proj_path = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(buildPath);
        var proj      = new UnityEditor.iOS.Xcode.PBXProject();
        proj.ReadFromFile(proj_path);

        // target_name = "Unity-iPhone"
        var target_name = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
        var target_guid = proj.TargetGuidByName(target_name);
        var src         = AssetDatabase.GetAssetPath(file);
        var file_name   = Path.GetFileName(src);
        var dst         = buildPath + "/" + target_name + "/" + file_name;
        FileUtil.CopyFileOrDirectory(src, dst);
        proj.AddFile(target_name + "/" + file_name, file_name);
        proj.AddBuildProperty(target_guid, "CODE_SIGN_ENTITLEMENTS", target_name + "/" + file_name);

        proj.WriteToFile(proj_path);
        #endif
    }
 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);
 }
        static void runPodUpdate(string path)
        {
            // Copy the podfile into the project.
            string podfile = "Assets/GoogleMobileAds/Editor/Podfile";
            string destpodfile = path + "/Podfile";
            if(!System.IO.File.Exists(destpodfile))
            {
                FileUtil.CopyFileOrDirectory(podfile, destpodfile);
            }

            try
            {
                CocoaPodHelper.Update(path);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log("Could not create a new Xcode project with CocoaPods: " +
                    e.Message);
            }

            #if UNITY_5
                string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
                PBXProject project = new PBXProject();
                project.ReadFromString(File.ReadAllText(pbxprojPath));
                string target = project.TargetGuidByName("Unity-iPhone");

                project.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
                project.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)");

                File.WriteAllText(pbxprojPath, project.WriteToString());
            #else
                UnityEngine.Debug.Log("Unable to modify build settings in XCode project. Build " +
                        "settings must be set manually");
            #endif
        }
    public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        #if UNITY_IOS
        string temp = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
        PBXProject proj = new PBXProject();
        proj.ReadFromString(File.ReadAllText(temp));

        string target = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
        proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
        proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-lc++");
        proj.AddBuildProperty(target, "CODE_SIGN_RESOURCE_RULES_PATH", "$(SDKROOT)/ResourceRules.plist");
        proj.AddBuildProperty(target, "CLANG_ENABLE_MODULES","YES");

        File.WriteAllText(temp, proj.WriteToString());
        #endif
    }
示例#10
0
    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 onPostProcessBuildPlayer(BuildTarget target, string pathToBuiltProject) {
#if UNITY_4_X
		if (target == BuildTarget.iPhone) {
#else
		if (target == BuildTarget.iOS) {
#endif

#if UNITY_EDITOR_OSX
			UnityEngine.Debug.Log ("Path to built project: " + pathToBuiltProject);

			string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
			UnityEngine.Debug.Log ("Project Path: " + projPath);

			PBXProject proj = new PBXProject();
			proj.ReadFromString(File.ReadAllText(projPath));
			string projTarget = proj.TargetGuidByName("Unity-iPhone");
			UnityEngine.Debug.Log ("Project Target: " + projTarget);

			proj.AddFrameworkToProject(projTarget, "Security.framework", false);
			proj.AddBuildProperty(projTarget, "OTHER_LDFLAGS", "-ObjC -lz -lstdc++");

			File.WriteAllText(projPath, proj.WriteToString());
#endif
		}
		
		if (target == BuildTarget.WP8Player) {
			postProcessWP8Build(pathToBuiltProject);
		}
	}
    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());
    }
示例#13
0
    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");

            // Add user packages to project. Most other source or resource files and packages
            // can be added the same way.
            /*
            CopyAndReplaceDirectory("NativeAssets/TestLib.bundle", Path.Combine(path, "Frameworks/TestLib.bundle"));
            proj.AddFileToBuild(target, proj.AddFile("Frameworks/TestLib.bundle",
                                                     "Frameworks/TestLib.bundle", PBXSourceTree.Source));

            CopyAndReplaceDirectory("NativeAssets/TestLib.framework", Path.Combine(path, "Frameworks/TestLib.framework"));
            proj.AddFileToBuild(target, proj.AddFile("Frameworks/TestLib.framework",
                                                     "Frameworks/TestLib.framework", PBXSourceTree.Source));
            */
            // Add custom system frameworks. Duplicate frameworks are ignored.
            // needed by our native plugin in Assets/Plugins/iOS

            proj.AddFrameworkToProject(target, "MessageUI.framework", false /*not weak*/);

            // 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");

            // Set a custom link flag
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            File.WriteAllText(projPath, proj.WriteToString());
        }
    }
示例#14
0
    //设置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();//写入文件保存
    }
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        #if UNITY_IPHONE
            if (target != BuildTarget.iOS) return;

            string buildName = Path.GetFileNameWithoutExtension(path);
            string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();

            proj.ReadFromString(File.ReadAllText(pbxprojPath));

            string buildTarget = proj.TargetGuidByName("Unity-iPhone");

            DirectoryInfo projectParent = Directory.GetParent(Application.dataPath);

            char divider = Path.DirectorySeparatorChar;

            DirectoryInfo destinationFolder =
                new DirectoryInfo(path + divider + "Frameworks");

            foreach(DirectoryInfo file in destinationFolder.GetDirectories()) {
                string filePath = "Frameworks/"+ file.Name;
                proj.AddFile(filePath, filePath, PBXSourceTree.Source);
                proj.AddFrameworkToProject (buildTarget, file.Name, false);
            }

            proj.SetBuildProperty(
                buildTarget, "FRAMEWORK_SEARCH_PATHS", "$(SRCROOT)/Frameworks"
            );
            proj.AddBuildProperty(
                buildTarget, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"
            );
            proj.SetBuildProperty(buildTarget, "CLANG_ENABLE_MODULES", "YES");

            File.WriteAllText(pbxprojPath, proj.WriteToString());
        #endif
    }
        /// <summary>
        /// Updates the generated pbxproj to reduce manual work required by developers. Currently
        /// this adds the '-fobjc-arc' flag for the Play Games ObjC source file.
        /// </summary>
        /// <param name="pbxprojPath">Pbxproj path.</param>
        private static void UpdateGeneratedPbxproj(string pbxprojPath)
        {
            PBXProject proj = new PBXProject();
            proj.ReadFromString(File.ReadAllText(pbxprojPath));

            string target =
                proj.TargetGuidByName(PBXProject.GetUnityTargetName());
            string testTarget =
                proj.TargetGuidByName(PBXProject.GetUnityTestTargetName());

            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)");
            proj.AddBuildProperty(testTarget, "OTHER_LDFLAGS", "$(inherited)");
            proj.AddBuildProperty(target, "HEADER_SEARCH_PATHS", "$(inherited)");
            proj.AddBuildProperty(testTarget, "HEADER_SEARCH_PATHS", "$(inherited)");
            proj.AddBuildProperty(target, "OTHER_CFLAGS", "$(inherited)");
            proj.AddBuildProperty(testTarget, "OTHER_CFLAGS", "$(inherited)");

            string fileGuid =
                 proj.FindFileGuidByProjectPath("Libraries/Plugins/iOS/GPGSAppController.mm");

            List<string> list = new List<string>();
            list.Add("-fobjc-arc");

            proj.SetCompileFlagsForFile(target, fileGuid, list);

            File.WriteAllText(pbxprojPath, proj.WriteToString());
        }
    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());
    }
示例#18
0
 public static void OnPostProcessBuild(BuildTarget platform, string projectPath)
 {
     if (platform != BuildTarget.iOS) {
       return;
     }
     string pbxFile = PBXProject.GetPBXProjectPath(projectPath);
     PBXProject pbxProject = new PBXProject();
     pbxProject.ReadFromFile(pbxFile);
     string target = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName());
     pbxProject.AddFrameworkToProject(target, "Security.framework", false);
     pbxProject.AddFrameworkToProject(target, "GLKit.framework", false);
     pbxProject.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
     pbxProject.WriteToFile(pbxFile);
 }
 static void AddBuildProperties(UnityEditor.iOS.Xcode.PBXProject project, string targetGUID)
 {
     project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC");
 }
示例#20
0
		static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
		{
			#if UNITY_5
			if (target == BuildTarget.WSAPlayer || target == BuildTarget.WP8Player)
			#else
			if (target == BuildTarget.MetroPlayer || target == BuildTarget.WP8Player)
			#endif
			{
				#if UNITY_WP8 || UNITY_5
				var productName = PlayerSettings.productName.Replace(" ", "").Replace("_", "");
				#else
				var productName = PlayerSettings.productName;
				#endif
				
				#if UNITY_5
				if (EditorUserBuildSettings.wsaSDK == WSASDK.UniversalSDK81 && EditorUserBuildSettings.activeBuildTarget != BuildTarget.WP8Player)
				#else
				if (EditorUserBuildSettings.metroSDK == MetroSDK.UniversalSDK81 && EditorUserBuildSettings.activeBuildTarget != BuildTarget.WP8Player)
				#endif
				{
					var projPath = string.Format("{0}/{1}/{1}.Shared/{1}.Shared.projItems", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					var doc = XDocument.Load(projPath);
					addPostProjectReferences(doc, pathToBuiltProject, string.Format("/{0}.Shared", productName), productName, "$(MSBuildThisFileDirectory)");
					doc.Save(projPath);

					projPath = string.Format("{0}/{1}/{1}.Windows/{1}.Windows.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					doc.Save(projPath);

					projPath = string.Format("{0}/{1}/{1}.WindowsPhone/{1}.WindowsPhone.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);
					doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					doc.Save(projPath);
				}
				else
				{
					var projPath = string.Format("{0}/{1}/{1}.csproj", pathToBuiltProject, productName);
					Debug.Log("Modifying Proj: " + projPath);

					var doc = XDocument.Load(projPath);
					addPostProjectCompilerDirectives(doc);
					addPostProjectReferences(doc, pathToBuiltProject, "", productName, "");
					doc.Save(projPath);
				}
			}
			#if UNITY_IOS && UNITY_5
			else if (target == BuildTarget.iOS)
			{
				string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";

				var proj = new PBXProject();
				proj.ReadFromString(File.ReadAllText (projPath));

				string targetID = proj.TargetGuidByName ("Unity-iPhone");

				// set custom link flags
				proj.AddBuildProperty (targetID, "OTHER_LDFLAGS", "-all_load");
				proj.AddBuildProperty (targetID, "OTHER_LDFLAGS", "-ObjC");

				// add frameworks
				proj.AddFrameworkToProject(targetID, "AdSupport.framework", true);
				proj.AddFrameworkToProject(targetID, "CoreTelephony.framework", true);
				proj.AddFrameworkToProject(targetID, "EventKit.framework", true);
				proj.AddFrameworkToProject(targetID, "EventKitUI.framework", true);
				proj.AddFrameworkToProject(targetID, "iAd.framework", true);
				proj.AddFrameworkToProject(targetID, "MessageUI.framework", true);
				proj.AddFrameworkToProject(targetID, "StoreKit.framework", true);
				proj.AddFrameworkToProject(targetID, "Security.framework", true);
				proj.AddFrameworkToProject(targetID, "GameKit.framework", true);
				proj.AddFrameworkToProject(targetID, "GoogleMobileAds.framework", false);

				// change GoogleMobileAds to use reletive path
				string projData = proj.WriteToString();
				projData = projData.Replace
				(
					@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = System/Library/Frameworks/GoogleMobileAds.framework; sourceTree = SDKROOT; };",
					@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = Frameworks/GoogleMobileAds.framework; sourceTree = ""<group>""; };"
					//@"/* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleMobileAds.framework; path = """ + pathToBuiltProject+"/Frameworks/GoogleMobileAds.framework" + @"""; sourceTree = ""<absolute>""; };"
				);

				// change framework search path to include local framework directory
				projData = projData.Replace
				(
					@"FRAMEWORK_SEARCH_PATHS = ""$(inherited)"";",
					@"FRAMEWORK_SEARCH_PATHS = (""$(inherited)"", ""$(PROJECT_DIR)/Frameworks"",);"
				);

				// save proj data
				File.WriteAllText(projPath, projData);

				// create Frameworks folder if one doesn't exists
				if (!Directory.Exists(pathToBuiltProject+"/Frameworks/")) Directory.CreateDirectory(pathToBuiltProject+"/Frameworks/");

				// extract GoogleMobileAds.framework.zip to xcode framework path
				if (!Directory.Exists(pathToBuiltProject+"/Frameworks/GoogleMobileAds.framework/"))
				{
					var startInfo = new System.Diagnostics.ProcessStartInfo();
					startInfo.Arguments = @"""" + Application.dataPath+"/Plugins/IOS/GoogleMobileAds.framework.zip" + @""" -d """ + pathToBuiltProject+@"/Frameworks/""";
					startInfo.FileName = "unzip";
					startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
					startInfo.CreateNoWindow = true;
					using (var process = System.Diagnostics.Process.Start(startInfo))
					{
						process.WaitForExit();
						int exitCode = process.ExitCode;
						if (exitCode != 0) Debug.LogError("Failed to unzip GoogleMobileAds.framework.zip with ErrorCode: " + exitCode);
					}
				}
			}
			#endif
    	}
示例#21
0
        private static void ModifyProject(string projectPath)
        {
            // Create PBXProject
              PBXProject project = new PBXProject();
              project.ReadFromString(File.ReadAllText(projectPath));

              if (!AppboyConfig.IOSAutomatesIntegration) {
            // Remove AppboyAppDelegate.mm from PBXProject
            Debug.Log("Removing AppboyAppDelegate.mm from " + AppboyAppDelegatePath);
            string appboyAppDelegateGuid = project.FindFileGuidByProjectPath(AppboyAppDelegatePath);
            project.RemoveFile(appboyAppDelegateGuid);
              } else {
            // Get project targets using Unity's default app target names
            string[] targets = {
              project.TargetGuidByName(PBXProject.GetUnityTargetName()),
              project.TargetGuidByName(PBXProject.GetUnityTestTargetName())
            };

            string[] requiredFrameworks = {
              "SystemConfiguration.framework",
              "QuartzCore.framework",
              "libz.tbd",
              "CoreImage.framework",
              "CoreText.framework"
            };

            string[] optionalFrameworks = {
              "CoreTelephony.framework",
              "Social.framework",
              "Accounts.framework",
              "AdSupport.framework",
              "StoreKit.framework",
              "CoreLocation.framework", // optional for location tracking
              "ImageIO.framework" // required by SDWebImage
            };

            foreach (string target in targets) {
              // Modify build properties
              project.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Frameworks/Plugins/iOS");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Libraries/Plugins/iOS");
              project.AddBuildProperty(target, "FRAMEWORK_SEARCH_PATHS", "./Libraries");

              // Add required frameworks
              // Note: Unity's documentation for PBXProject.AddFrameworkToProject says that the boolean parameter
              // should be true if required and false if optional, but actual behavior appears to be the exact opposite.
              foreach (string framework in requiredFrameworks) {
            project.AddFrameworkToProject(target, framework, false);
              }

              foreach (string framework in optionalFrameworks) {
            project.AddFrameworkToProject(target, framework, true);
              }
            }
              }

              // Write changes to XCode project
              File.WriteAllText(projectPath, project.WriteToString());
        }
示例#22
0
        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());
        }
    /// <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
                );
            }
        }
    }
示例#24
0
	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

	}