ios端google;修改ios打包时pod数据源为清华

This commit is contained in:
Caiyanpeng committed 2022-01-20 16:30:58 +08:00
1 parent 58a8233697
commit 7bb5bafbd2
14 files changed
+143 -9

No files matched your search

+32 -2
View File
@@ -5,6 +5,7 @@ using System.IO;
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System;
#endif
@@ -15,7 +16,7 @@ public static class XCodePostProcessBuild
"Security.framework","WebKit.framework", "CoreGraphics.framework"
};
[PostProcessBuild(1)]
[PostProcessBuild(11)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
if (BuildTarget.iOS != buildTarget)
@@ -24,10 +25,27 @@ public static class XCodePostProcessBuild
}
string projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
SetFrameworksAndBuildSettings(projectPath);
AddGooglePlist(pathToBuiltProject,projectPath);
SetInfoList(pathToBuiltProject, "com.ZhiXingPai.PowerFun", "wxe3573a84e7e29902");
SetAssociatedDomains(projectPath, "wx.powerfun.com.cn");
Assets.NativeLocale.AddLocalizedStringsIOS(pathToBuiltProject, Path.Combine(Application.dataPath, "Editor/Locale"));
}
private static void AddGooglePlist(string pathToBuiltProject,string path)
{
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(path));
// This is the Xcode target in the generated project
string target = proj.GetUnityMainTargetGuid();
// Copy plist from the project folder to the build folder
FileUtil.CopyFileOrDirectory("Assets/Plugins/iOS/GoogleService-Info.plist", pathToBuiltProject + "/GoogleService-Info.plist");
proj.AddFileToBuild(target, proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
// Write PBXProject object back to the file
proj.WriteToFile(path);
}
private static void SetFrameworksAndBuildSettings(string path)
{
PBXProject proj = new PBXProject();
@@ -38,6 +56,7 @@ public static class XCodePostProcessBuild
proj.AddBuildProperty(target, "Other Linker Flags", "-Objc -all_load");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
//根据微信SDK文档的要求,加入相关的Frameworks
for (int i = 0; i < csAddFrameworks.Length; ++i)
{
@@ -48,7 +67,11 @@ public static class XCodePostProcessBuild
//苹果登录配置项
//proj.AddCapability(target, PBXCapabilityType.SignInWithApple);
proj.AddFrameworkToProject(proj.GetUnityFrameworkTargetGuid(), "AuthenticationServices.framework", false);
//移除无用配置项
proj.RemoveFrameworkFromProject(proj.GetUnityFrameworkTargetGuid(), "Chromium Embedded Framework.framework");
proj.SetBuildProperty(proj.ProjectGuid(), "ENABLE_BITCODE", "NO");
proj.SetBuildProperty(proj.ProjectGuid(), "CLANG_ENABLE_MODULES", "YES");
File.WriteAllText(path, proj.WriteToString());
}
@@ -65,12 +88,19 @@ public static class XCodePostProcessBuild
dict.SetString("CFBundleURLName", wxUrlName);
PlistElementArray urlSchemes = dict.CreateArray("CFBundleURLSchemes");
urlSchemes.AddString(wxScheme);
PlistElementDict dictMine = urlArray.AddDict();
dictMine.SetString("CFBundleTypeRole", "Editor");
dictMine.SetString("CFBundleURLName", "powerfunx");
PlistElementArray urlSchemesMine = dictMine.CreateArray("CFBundleURLSchemes");
urlSchemesMine.AddString("powerfunx");
PlistElementDict dictGG = urlArray.AddDict();
dictGG.SetString("CFBundleTypeRole", "Editor");
dictGG.SetString("CFBundleURLName", "google");
PlistElementArray urlSchemesGG = dictGG.CreateArray("CFBundleURLSchemes");
urlSchemesGG.AddString("com.googleusercontent.apps.492440200766-spo9287smn7epmlarib2pek9kficsq86");
// 在 “info”标签栏的“LSApplicationQueriesSchemes“添加weixin wechat和weixinULAPI
PlistElementArray wxArray = plist.root.CreateArray("LSApplicationQueriesSchemes");
wxArray.AddString("weixin");