【数数】修复Android平台下IOS组件找不到的问题

dev_chengFeng hotfix/mht_china/xq/cdn_xq_test/0.1.82
gaoxin 2021-08-30 18:15:54 +08:00 committed by zhangshanxue
parent a3f6147779
commit 9744f908a5
1 changed files with 48 additions and 43 deletions

View File

@ -33,6 +33,9 @@ using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
#endif
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using System.IO;
using ThinkingAnalytics.TaException;
@ -196,7 +199,7 @@ namespace ThinkingAnalytics
public class ThinkingAnalyticsAPI : MonoBehaviour, TaExceptionHandler
{
#region settings
#region settings
[System.Serializable]
public struct Token
{
@ -275,61 +278,63 @@ namespace ThinkingAnalytics
[HideInInspector]
public Token[] tokens = new Token[1];
#endregion
#endregion
public readonly string VERSION = "2.2.1";
private static ThinkingAnalyticsAPI taAPIInstance;
//配置Xcode选项
#if UNITY_EDITOR
#if UNITY_EDITOR
//[PostProcessBuild]
[PostProcessBuildAttribute(88)]
public static void onPostProcessBuild(BuildTarget target, string targetPath)
{
//if (target != BuildTarget.iOS)
//{
// Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
// return;
//}
//string projPath = Path.GetFullPath(targetPath) + "/Unity-iPhone.xcodeproj/project.pbxproj";
{
#if EDITOR_IOS
if (target != BuildTarget.iOS)
{
Debug.LogWarning("Target is not iPhone. XCodePostProcess will not run");
return;
}
//UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
//proj.ReadFromFile(projPath);
//#if UNITY_2019_3_OR_NEWER
//string targetGuid = proj.GetUnityFrameworkTargetGuid();
//#else
//string targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
//#endif
string projPath = Path.GetFullPath(targetPath) + "/Unity-iPhone.xcodeproj/project.pbxproj";
////Build Property
//proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");//BitCode NO
//proj.SetBuildProperty(targetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");//Enable Objective-C Exceptions
UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
proj.ReadFromFile(projPath);
#if UNITY_2019_3_OR_NEWER
string targetGuid = proj.GetUnityFrameworkTargetGuid();
#else
string targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
#endif
//string[] headerSearchPathsToAdd = { "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/main", "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/common" };
//proj.UpdateBuildProperty(targetGuid, "HEADER_SEARCH_PATHS", headerSearchPathsToAdd, null);// Header Search Paths
//Build Property
proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");//BitCode NO
proj.SetBuildProperty(targetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");//Enable Objective-C Exceptions
////Add Frameworks
//proj.AddFrameworkToProject(targetGuid,"WebKit.framework", true);
//proj.AddFrameworkToProject(targetGuid,"CoreTelephony.framework", true);
//proj.AddFrameworkToProject(targetGuid,"SystemConfiguration.framework", true);
//proj.AddFrameworkToProject(targetGuid,"Security.framework", true);
string[] headerSearchPathsToAdd = { "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/main", "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/common" };
proj.UpdateBuildProperty(targetGuid, "HEADER_SEARCH_PATHS", headerSearchPathsToAdd, null);// Header Search Paths
////Add Lib
//proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libsqlite3.tbd", "libsqlite3.tbd", PBXSourceTree.Sdk));
//proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libz.tbd", "libz.tbd", PBXSourceTree.Sdk));
//Add Frameworks
proj.AddFrameworkToProject(targetGuid, "WebKit.framework", true);
proj.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", true);
proj.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", true);
proj.AddFrameworkToProject(targetGuid, "Security.framework", true);
//proj.WriteToFile (projPath);
//Add Lib
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libsqlite3.tbd", "libsqlite3.tbd", PBXSourceTree.Sdk));
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libz.tbd", "libz.tbd", PBXSourceTree.Sdk));
proj.WriteToFile(projPath);
#endif
}
#endif
#endif
/// <summary>
/// 设置自定义访客 ID用于替换系统生成的访客 ID
/// </summary>
/// <param name="FIRSTId">访客 ID</param>
/// <param name="appId">项目 ID(可选)</param>
public static void Identify(string FIRSTId, string appId = "")
/// <summary>
/// 设置自定义访客 ID用于替换系统生成的访客 ID
/// </summary>
/// <param name="FIRSTId">访客 ID</param>
/// <param name="appId">项目 ID(可选)</param>
public static void Identify(string FIRSTId, string appId = "")
{
if (tracking_enabled)
{
@ -877,14 +882,14 @@ namespace ThinkingAnalytics
}
}
#region internal
#region internal
void Awake()
{
taAPIInstance = this;
#if DISABLE_TA
#if DISABLE_TA
tracking_enabled = false;
#endif
#endif
TD_Log.EnableLog(enableLog);
ThinkingAnalyticsWrapper.SetVersionInfo(VERSION);
if (TA_instance == null)
@ -959,6 +964,6 @@ namespace ThinkingAnalytics
instance_lock.ExitReadLock();
}
}
#endregion
#endregion
}
}