Assets/Editor/Tool/ClientPackage.cs
@@ -41,7 +41,7 @@ } static string THE_2TH_WORLD_SDK_PATH = Application.dataPath + "/Plugins/Android/bin"; // static string MANIFEST_PATH = Application.dataPath + "/Plugins/Android/AndroidManifest.xml"; static string MANIFEST_PATH = Application.dataPath + "/Plugins/Android/AndroidManifest.xml"; static string iOS_PLUGIN_PATH = Application.dataPath + "/Plugins/iOS/Channel"; @@ -440,6 +440,7 @@ // var manifestpath = StringUtility.Contact(_sdkPath, "/Channel/Android/", versionConfig.appId, "/AndroidManifest.xml"); var channelSdkPath = StringUtility.Contact(_sdkPath, "/Channel/Android/", versionConfig.appId, "/", variant); var manifeastPath = StringUtility.Contact(_sdkPath, "/Channel/Android/", versionConfig.appId, "/AndroidManifest.xml"); // if (File.Exists(manifestpath)) // { @@ -463,6 +464,14 @@ return; } if (File.Exists(manifeastPath)) { if (File.Exists(MANIFEST_PATH)) File.Delete(MANIFEST_PATH); File.Copy(manifeastPath, MANIFEST_PATH); DebugEx.LogFormat("Android 清单文件拷贝成功,{0}", manifeastPath); } var option = AssetDatabase.LoadAssetAtPath<Options>("Assets/Editor/Beebyte/Obfuscator/ObfuscatorOptions.asset"); if (option != null) { Assets/Editor/XCodeProjectMod.cs
@@ -2,12 +2,10 @@ using System.IO; using UnityEditor; using UnityEditor.iOS.Xcode.Custom; using UnityEditor.iOS.Xcode.Custom.Extensions; using UnityEngine; public class XCodeProjectMod { #if UNITY_IOS private const string CODE_SIGN_DEVELOPER = ""; private const string CODE_SIGN_DISTRIBUTION = ""; private const string PROVISIONING_DEVELOPER = ""; @@ -24,53 +22,39 @@ string _projectPath = PBXProject.GetPBXProjectPath(path); PBXProject _project = new PBXProject(); _project.ReadFromString(File.ReadAllText(_projectPath)); PBXProject project = new PBXProject(); project.ReadFromString(File.ReadAllText(_projectPath)); string _targetGUID = _project.TargetGuidByName(PBXProject.GetUnityTargetName()); string _fwTargetGUID = _project.TargetGuidByName("UnityFramework"); string targetGUID = project.TargetGuidByName(PBXProject.GetUnityTargetName()); string fwTargetGUID = project.TargetGuidByName("UnityFramework"); //var _codeSign = Debug.isDebugBuild ? CODE_SIGN_DEVELOPER : CODE_SIGN_DISTRIBUTION; //var _provision = Debug.isDebugBuild ? PROVISIONING_DEVELOPER : PROVISIONING_DISTRIBUTION; // BuildSetting里的相关设置 _project.SetBuildProperty(_targetGUID, "ENABLE_BITCODE", "NO"); _project.SetBuildProperty(_targetGUID, "DEVELOPMENT_TEAM", TEAM); project.SetBuildProperty(targetGUID, "ENABLE_BITCODE", "NO"); project.SetBuildProperty(targetGUID, "DEVELOPMENT_TEAM", TEAM); _project.AddBuildProperty(_targetGUID, "OTHER_LDFLAGS", "-ObjC"); _project.AddBuildProperty(_targetGUID, "GCC_GENERATE_DEBUGGING_SYMBOLS", "NO"); project.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC"); project.AddBuildProperty(targetGUID, "GCC_GENERATE_DEBUGGING_SYMBOLS", "NO"); // 处理 Framework // FreeSDK _project.AddFrameworkToProject(_targetGUID, "CoreGraphics.framework", true); _project.AddFrameworkToProject(_targetGUID, "Security.framework", true); _project.AddFrameworkToProject(_targetGUID, "CoreTelephony.framework", true); _project.AddFrameworkToProject(_targetGUID, "StoreKit.framework", true); _project.AddFrameworkToProject(_targetGUID, "MobileCoreServices.framework", true); _project.AddFrameworkToProject(_targetGUID, "SystemConfiguration.framework", true); _project.AddFrameworkToProject(_targetGUID, "AdSupport.framework", true); // 极光推送 // JPush _project.AddFrameworkToProject(_targetGUID, "CFNetwork.framework", true); _project.AddFrameworkToProject(_targetGUID, "CoreFoundation.framework", true); _project.AddFrameworkToProject(_targetGUID, "Foundation.framework", true); _project.AddFrameworkToProject(_targetGUID, "UIKit.framework", true); _project.AddFrameworkToProject(_targetGUID, "UserNotifications.framework", true); //bugly project.AddFrameworkToProject(fwTargetGUID, "SystemConfiguration.framework", true); project.AddFrameworkToProject(fwTargetGUID, "Security.framework", true); project.AddFrameworkToProject(fwTargetGUID, "JavaScriptCore.framework", true); // 处理 库文件 _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk)); _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk)); _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libc++.tbd", "Frameworks/libc++.tbd", PBXSourceTree.Sdk)); _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libiconv.tbd", "Frameworks/libiconv.tbd", PBXSourceTree.Sdk)); _project.AddFileToBuild(_targetGUID, _project.AddFile("/usr/lib/libresolv.tbd", "Frameworks/libresolv.tbd", PBXSourceTree.Sdk)); project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk)); project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk)); project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libc++.tbd", "Frameworks/libc++.tbd", PBXSourceTree.Sdk)); project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libiconv.tbd", "Frameworks/libiconv.tbd", PBXSourceTree.Sdk)); project.AddFileToBuild(fwTargetGUID, project.AddFile("/usr/lib/libresolv.tbd", "Frameworks/libresolv.tbd", PBXSourceTree.Sdk)); //UnityFramework _project.AddBuildProperty(_fwTargetGUID, "OTHER_LDFLAGS", "-ObjC"); project.AddBuildProperty(fwTargetGUID, "OTHER_LDFLAGS", "-ObjC"); File.WriteAllText(_projectPath, _project.WriteToString()); File.WriteAllText(_projectPath, project.WriteToString()); //加推送 //var _capabilityMgr = new ProjectCapabilityManager(_projectPath, "game003.entitlements", PBXProject.GetUnityTargetName()); @@ -104,9 +88,6 @@ _rootDict.SetString("NSMicrophoneUsageDescription", "使用麦克风权限"); _rootDict.SetString("NSPhotoLibraryAddUsageDescription", "使用相册权限,用以存储截屏的账号信息,以防忘记账号密码"); _rootDict.SetString("YLChannelId", "1000"); _rootDict.SetString("YLPlatformId", "1000"); File.WriteAllText(_plistPath, _plist.WriteToString()); } @@ -115,13 +96,13 @@ //修改UnityAppController.mm 文件 var _xclass = new XClass(projectPath + "/Classes/UnityAppController.mm"); //引入UniversalSDK _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\""+ "\n#import <SMPCQuickSDK/SMPCQuickSDK.h>"); _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\"" + "\n#import <SMPCQuickSDK/SMPCQuickSDK.h>"); //unity交互调用的方法 string newCode = "\n" + "extern \"C\" void IOSMessageHandle(const char* jsonString) {\n" + " [GetAppController().universalSDK HandleUnityMessage:[NSString stringWithUTF8String:jsonString]];\n" + "}"; _xclass.WriteBelow("extern \"C\" ScreenOrientation UnityCurrentOrientation() { return GetAppController().unityView.contentOrientation; }",newCode); _xclass.WriteBelow("extern \"C\" ScreenOrientation UnityCurrentOrientation() { return GetAppController().unityView.contentOrientation; }", newCode); //初始化UniversalSDK newCode = "\n" + " _universalSDK = [[UniversalSDK alloc] init];\n [_universalSDK QuickSDKInit:application didFinishLaunchingWithOptions:launchOptions];"; @@ -141,7 +122,7 @@ //修改UnityAppController.h 文件 _xclass = new XClass(projectPath + "/Classes/UnityAppController.h"); _xclass.WriteBelow("@class DisplayConnection;", "@class UniversalSDK;"); _xclass.WriteBelow("@class DisplayConnection;", "@class UniversalSDK;"); _xclass.WriteBelow("DisplayConnection* _mainDisplay;", "UniversalSDK* _universalSDK;"); _xclass.WriteBelow("@property (readonly, copy, nonatomic) DisplayConnection* mainDisplay;", "@property (readonly, copy, nonatomic) UniversalSDK* universalSDK;"); @@ -203,18 +184,16 @@ [MenuItem("Build/ipa")] public static void BuildIPA() { var _p = new System.Diagnostics.Process(); _p.StartInfo.FileName = "osascript"; _p.StartInfo.Arguments = string.Format("-e 'tell application \"Terminal\" \n activate \n do script \"cd {0} && sh {1} {2}\" \n end tell'", var p = new System.Diagnostics.Process(); p.StartInfo.FileName = "osascript"; p.StartInfo.Arguments = string.Format("-e 'tell application \"Terminal\" \n activate \n do script \"cd {0} && sh {1} {2}\" \n end tell'", Application.dataPath + "/../", "buildipa.sh", GetBuildPath()); _p.StartInfo.UseShellExecute = false; _p.StartInfo.RedirectStandardOutput = false; _p.Start(); _p.WaitForExit(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = false; p.Start(); p.WaitForExit(); } #endif } Assets/Plugins/BuglyPlugins.meta
New file @@ -0,0 +1,5 @@ fileFormatVersion: 2 guid: 5cef439187fbb41ab879da2b95ac4291 folderAsset: yes DefaultImporter: userData: Assets/Plugins/BuglyPlugins/Android.meta
New file @@ -0,0 +1,5 @@ fileFormatVersion: 2 guid: 694411f45e4e64facb88eebfc2e1df1c folderAsset: yes DefaultImporter: userData: Assets/Plugins/BuglyPlugins/Android/libs.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: 644a9f5710e62403c94066ef9b61e775 folderAsset: yes DefaultImporter: userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/arm64-v8a.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: a60efd6713c4cb7408ff9957231e903f folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/arm64-v8a/libBugly.soBinary files differ
Assets/Plugins/BuglyPlugins/Android/libs/arm64-v8a/libBugly.so.meta
New file @@ -0,0 +1,70 @@ fileFormatVersion: 2 guid: 46b95cb0cdeb50c4bb886ceaa8c249dc PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: : Any second: enabled: 0 settings: Exclude Android: 0 Exclude Editor: 1 Exclude Linux64: 1 Exclude OSXUniversal: 1 Exclude Win: 1 Exclude Win64: 1 - first: Android: Android second: enabled: 1 settings: CPU: ARM64 - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: CPU: AnyCPU DefaultValueInitialized: true OS: AnyOS - first: Standalone: Linux64 second: enabled: 0 settings: CPU: None - first: Standalone: OSXUniversal second: enabled: 0 settings: CPU: None - first: Standalone: Win second: enabled: 0 settings: CPU: None - first: Standalone: Win64 second: enabled: 0 settings: CPU: None userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/armeabi-v7a.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: d3a9f15911cb3324d8b981efcd17dfcd folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/armeabi-v7a/libBugly.soBinary files differ
Assets/Plugins/BuglyPlugins/Android/libs/armeabi-v7a/libBugly.so.meta
New file @@ -0,0 +1,70 @@ fileFormatVersion: 2 guid: 9c7d7151937c29f479f049518a9234a2 PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: : Any second: enabled: 0 settings: Exclude Android: 0 Exclude Editor: 1 Exclude Linux64: 1 Exclude OSXUniversal: 1 Exclude Win: 1 Exclude Win64: 1 - first: Android: Android second: enabled: 1 settings: CPU: ARMv7 - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: CPU: AnyCPU DefaultValueInitialized: true OS: AnyOS - first: Standalone: Linux64 second: enabled: 0 settings: CPU: None - first: Standalone: OSXUniversal second: enabled: 0 settings: CPU: None - first: Standalone: Win second: enabled: 0 settings: CPU: None - first: Standalone: Win64 second: enabled: 0 settings: CPU: None userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/bugly_crash_release.jarBinary files differ
Assets/Plugins/BuglyPlugins/Android/libs/bugly_crash_release.jar.meta
New file @@ -0,0 +1,32 @@ fileFormatVersion: 2 guid: c8c3e2f76946a8e409133ca12b46acfc PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: Android: Android second: enabled: 1 settings: {} - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: DefaultValueInitialized: true userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jarBinary files differ
Assets/Plugins/BuglyPlugins/Android/libs/buglyagent.jar.meta
New file @@ -0,0 +1,32 @@ fileFormatVersion: 2 guid: 1db231dca0f72420cb880590f799d7d5 PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: Android: Android second: enabled: 1 settings: {} - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: DefaultValueInitialized: true userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/BuglyAgent.cs
New file @@ -0,0 +1,1080 @@ // ---------------------------------------- // // BuglyAgent.cs // // Author: // Yeelik, <bugly@tencent.com> // // Copyright (c) 2015 Bugly, Tencent. All rights reserved. // // ---------------------------------------- // using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Runtime.InteropServices; // We dont use the LogType enum in Unity as the numerical order doesnt suit our purposes /// <summary> /// Log severity. /// { Log, LogDebug, LogInfo, LogWarning, LogAssert, LogError, LogException } /// </summary> public enum LogSeverity { Log, LogDebug, LogInfo, LogWarning, LogAssert, LogError, LogException } /// <summary> /// Bugly agent. /// </summary> public sealed class BuglyAgent { // Define delegate support multicasting to replace the 'Application.LogCallback' public delegate void LogCallbackDelegate (string condition,string stackTrace,LogType type); /// <summary> /// Configs the type of the crash reporter and customized log level to upload /// </summary> /// <param name="type">Type. Default=0, 1=Bugly v2.x MSDK=2</param> /// <param name="logLevel">Log level. Off=0,Error=1,Warn=2,Info=3,Debug=4</param> public static void ConfigCrashReporter(int type, int logLevel){ _SetCrashReporterType (type); _SetCrashReporterLogLevel (logLevel); } /// <summary> /// Init sdk with the specified appId. /// <para>This will initialize sdk to report native exception such as obj-c, c/c++, java exceptions, and also enable c# exception handler to report c# exception logs</para> /// </summary> /// <param name="appId">App identifier.</param> public static void InitWithAppId (string appId) { if (IsInitialized) { DebugLog (null, "BuglyAgent has already been initialized."); return; } if (string.IsNullOrEmpty (appId)) { return; } // init the sdk with app id InitBuglyAgent (appId); DebugLog (null, "Initialized with app id: {0}", appId); // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) _RegisterExceptionHandler (); } /// <summary> /// Only Enable the C# exception handler. /// /// <para> /// You can call it when you do not call the 'InitWithAppId(string)', but you must make sure initialized the sdk in elsewhere, /// such as the native code in associated Android or iOS project. /// </para> /// /// <para> /// Default Level is <c>LogError</c>, so the LogError, LogException will auto report. /// </para> /// /// <para> /// You can call the method <code>BuglyAgent.ConfigAutoReportLogLevel(LogSeverity)</code> /// to change the level to auto report if you known what are you doing. /// </para> /// /// </summary> public static void EnableExceptionHandler () { if (IsInitialized) { DebugLog (null, "BuglyAgent has already been initialized."); return; } DebugLog (null, "Only enable the exception handler, please make sure you has initialized the sdk in the native code in associated Android or iOS project."); // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) _RegisterExceptionHandler (); } /// <summary> /// Registers the log callback handler. /// /// If you need register logcallback using Application.RegisterLogCallback(LogCallback), /// you can call this method to replace it. /// /// <para></para> /// </summary> /// <param name="handler">Handler.</param> public static void RegisterLogCallback (LogCallbackDelegate handler) { if (handler != null) { DebugLog (null, "Add log callback handler: {0}", handler); _LogCallbackEventHandler += handler; } } /// <summary> /// Sets the log callback extras handler. /// </summary> /// <param name="handler">Handler.</param> public static void SetLogCallbackExtrasHandler(Func<Dictionary<string, string>> handler){ if (handler != null) { _LogCallbackExtrasHandler = handler; DebugLog(null, "Add log callback extra data handler : {0}", handler); } } /// <summary> /// Reports the exception. /// </summary> /// <param name="e">E.</param> /// <param name="message">Message.</param> public static void ReportException (System.Exception e, string message) { if (!IsInitialized) { return; } DebugLog (null, "Report exception: {0}\n------------\n{1}\n------------", message, e); _HandleException (e, message, false); } /// <summary> /// Reports the exception. /// </summary> /// <param name="name">Name.</param> /// <param name="message">Message.</param> /// <param name="stackTrace">Stack trace.</param> public static void ReportException (string name, string message, string stackTrace) { if (!IsInitialized) { return; } DebugLog (null, "Report exception: {0} {1} \n{2}", name, message, stackTrace); _HandleException (LogSeverity.LogException, name, message, stackTrace, false); } /// <summary> /// Unregisters the log callback. /// </summary> /// <param name="handler">Handler.</param> public static void UnregisterLogCallback (LogCallbackDelegate handler) { if (handler != null) { DebugLog (null, "Remove log callback handler"); _LogCallbackEventHandler -= handler; } } /// <summary> /// Sets the user identifier. /// </summary> /// <param name="userId">User identifier.</param> public static void SetUserId (string userId) { if (!IsInitialized) { return; } DebugLog (null, "Set user id: {0}", userId); SetUserInfo (userId); } /// <summary> /// Sets the scene. /// </summary> /// <param name="sceneId">Scene identifier.</param> public static void SetScene (int sceneId) { if (!IsInitialized) { return; } DebugLog (null, "Set scene: {0}", sceneId); SetCurrentScene (sceneId); } /// <summary> /// Adds the scene data. /// </summary> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public static void AddSceneData (string key, string value) { if (!IsInitialized) { return; } DebugLog (null, "Add scene data: [{0}, {1}]", key, value); AddKeyAndValueInScene (key, value); } /// <summary> /// Configs the debug mode. /// </summary> /// <param name="enable">If set to <c>true</c> debug mode.</param> public static void ConfigDebugMode (bool enable) { EnableDebugMode (enable); DebugLog (null, "{0} the log message print to console", enable ? "Enable" : "Disable"); } /// <summary> /// Configs the auto quit application. /// </summary> /// <param name="autoQuit">If set to <c>true</c> auto quit.</param> public static void ConfigAutoQuitApplication (bool autoQuit) { _autoQuitApplicationAfterReport = autoQuit; } /// <summary> /// Configs the auto report log level. Default is LogSeverity.LogError. /// <example> /// LogSeverity { Log, LogDebug, LogInfo, LogWarning, LogAssert, LogError, LogException } /// </example> /// </summary> /// /// <param name="level">Level.</param> public static void ConfigAutoReportLogLevel (LogSeverity level) { _autoReportLogLevel = level; } /// <summary> /// Configs the default. /// </summary> /// <param name="channel">Channel.</param> /// <param name="version">Version.</param> /// <param name="user">User.</param> /// <param name="delay">Delay.</param> public static void ConfigDefault (string channel, string version, string user, long delay) { DebugLog (null, "Config default channel:{0}, version:{1}, user:{2}, delay:{3}", channel, version, user, delay); ConfigDefaultBeforeInit (channel, version, user, delay); } /// <summary> /// Logs the debug. /// </summary> /// <param name="tag">Tag.</param> /// <param name="format">Format.</param> /// <param name="args">Arguments.</param> public static void DebugLog (string tag, string format, params object[] args) { if(!_debugMode) { return; } if (string.IsNullOrEmpty (format)) { return; } Console.WriteLine ("[BuglyAgent] <Debug> - {0} : {1}", tag, string.Format (format, args)); } /// <summary> /// Prints the log. /// </summary> /// <param name="level">Level.</param> /// <param name="format">Format.</param> /// <param name="args">Arguments.</param> public static void PrintLog (LogSeverity level, string format, params object[] args) { if (string.IsNullOrEmpty (format)) { return; } LogRecord (level, string.Format (format, args)); } #if UNITY_EDITOR || UNITY_STANDALONE #region Interface(Empty) in Editor private static void InitBuglyAgent (string appId) { } private static void ConfigDefaultBeforeInit(string channel, string version, string user, long delay){ } private static void EnableDebugMode(bool enable){ } private static void SetUserInfo(string userInfo){ } private static void ReportException (int type,string name, string message, string stackTrace, bool quitProgram) { } private static void SetCurrentScene(int sceneId) { } private static void AddKeyAndValueInScene(string key, string value){ } private static void AddExtraDataWithException(string key, string value) { // only impl for iOS } private static void LogRecord(LogSeverity level, string message){ } private static void SetUnityVersion(){ } #endregion #elif UNITY_ANDROID // #if UNITY_ANDROID #region Interface for Android private static readonly string GAME_AGENT_CLASS = "com.tencent.bugly.agent.GameAgent"; private static readonly int TYPE_U3D_CRASH = 4; private static readonly int GAME_TYPE_UNITY = 2; private static bool hasSetGameType = false; private static AndroidJavaClass _gameAgentClass = null; public static AndroidJavaClass GameAgent { get { if (_gameAgentClass == null) { _gameAgentClass = new AndroidJavaClass(GAME_AGENT_CLASS); // using (AndroidJavaClass clazz = new AndroidJavaClass(CLASS_UNITYAGENT)) { // _gameAgentClass = clazz.CallStatic<AndroidJavaObject> ("getInstance"); // } } if (!hasSetGameType) { // set game type: unity(2). _gameAgentClass.CallStatic ("setGameType", GAME_TYPE_UNITY); hasSetGameType = true; } return _gameAgentClass; } } private static string _configChannel; private static string _configVersion; private static string _configUser; private static long _configDelayTime; private static void ConfigDefaultBeforeInit(string channel, string version, string user, long delay){ _configChannel = channel; _configVersion = version; _configUser = user; _configDelayTime = delay; } private static bool _configCrashReporterPackage = false; private static void ConfigCrashReporterPackage(){ if (!_configCrashReporterPackage) { try { GameAgent.CallStatic("setSdkPackageName", _crashReporterPackage); _configCrashReporterPackage = true; } catch { } } } private static void InitBuglyAgent(string appId) { if (IsInitialized) { return; } ConfigCrashReporterPackage(); try { GameAgent.CallStatic("initCrashReport", appId, _configChannel, _configVersion, _configUser, _configDelayTime); _isInitialized = true; } catch { } } private static void EnableDebugMode(bool enable){ _debugMode = enable; ConfigCrashReporterPackage(); try { GameAgent.CallStatic("setLogEnable", enable); } catch { } } private static void SetUserInfo(string userInfo){ ConfigCrashReporterPackage(); try { GameAgent.CallStatic("setUserId", userInfo); } catch { } } private static void ReportException (int type, string name, string reason, string stackTrace, bool quitProgram) { ConfigCrashReporterPackage(); try { GameAgent.CallStatic("postException", TYPE_U3D_CRASH, name, reason, stackTrace, quitProgram); } catch { } } private static void SetCurrentScene(int sceneId) { ConfigCrashReporterPackage(); try { GameAgent.CallStatic("setUserSceneTag", sceneId); } catch { } } private static void SetUnityVersion(){ ConfigCrashReporterPackage(); try { GameAgent.CallStatic("setSdkConfig", "UnityVersion", Application.unityVersion); } catch { } } private static void AddKeyAndValueInScene(string key, string value){ ConfigCrashReporterPackage(); try { GameAgent.CallStatic("putUserData", key, value); } catch { } } private static void AddExtraDataWithException(string key, string value) { // no impl } private static void LogRecord(LogSeverity level, string message){ if (level < LogSeverity.LogWarning) { DebugLog (level.ToString (), message); } ConfigCrashReporterPackage(); try { GameAgent.CallStatic("printLog", string.Format ("<{0}> - {1}", level.ToString (), message)); } catch { } } #endregion #elif UNITY_IPHONE || UNITY_IOS #region Interface for iOS private static bool _crashReporterTypeConfiged = false; private static void ConfigCrashReporterType(){ if (!_crashReporterTypeConfiged) { try { _BuglyConfigCrashReporterType(_crashReporterType); _crashReporterTypeConfiged = true; } catch { } } } private static void ConfigDefaultBeforeInit(string channel, string version, string user, long delay){ ConfigCrashReporterType(); try { _BuglyDefaultConfig(channel, version, user, null); } catch { } } private static void EnableDebugMode(bool enable){ _debugMode = enable; } private static void InitBuglyAgent (string appId) { ConfigCrashReporterType(); if(!string.IsNullOrEmpty(appId)) { _BuglyInit(appId, _debugMode, _crashReproterCustomizedLogLevel); // Log level } } private static void SetUnityVersion(){ ConfigCrashReporterType(); _BuglySetExtraConfig("UnityVersion", Application.unityVersion); } private static void SetUserInfo(string userInfo){ if(!string.IsNullOrEmpty(userInfo)) { ConfigCrashReporterType(); _BuglySetUserId(userInfo); } } private static void ReportException (int type, string name, string reason, string stackTrace, bool quitProgram) { ConfigCrashReporterType(); string extraInfo = ""; Dictionary<string, string> extras = null; if (_LogCallbackExtrasHandler != null) { extras = _LogCallbackExtrasHandler(); } if (extras == null || extras.Count == 0) { extras = new Dictionary<string, string> (); extras.Add ("UnityVersion", Application.unityVersion); } if (extras != null && extras.Count > 0) { if (!extras.ContainsKey("UnityVersion")) { extras.Add ("UnityVersion", Application.unityVersion); } StringBuilder builder = new StringBuilder(); foreach(KeyValuePair<string,string> kvp in extras){ builder.Append(string.Format("\"{0}\" : \"{1}\"", kvp.Key, kvp.Value)).Append(" , "); } extraInfo = string.Format("{{ {0} }}", builder.ToString().TrimEnd(" , ".ToCharArray())); } // 4 is C# exception _BuglyReportException(4, name, reason, stackTrace, extraInfo, quitProgram); } private static void SetCurrentScene(int sceneId) { ConfigCrashReporterType(); _BuglySetTag(sceneId); } private static void AddKeyAndValueInScene(string key, string value){ ConfigCrashReporterType(); _BuglySetKeyValue(key, value); } private static void AddExtraDataWithException(string key, string value) { } private static void LogRecord(LogSeverity level, string message){ if (level < LogSeverity.LogWarning) { DebugLog (level.ToString (), message); } ConfigCrashReporterType(); _BuglyLogMessage(LogSeverityToInt(level), null, message); } private static int LogSeverityToInt(LogSeverity logLevel){ int level = 5; switch(logLevel) { case LogSeverity.Log: level = 5; break; case LogSeverity.LogDebug: level = 4; break; case LogSeverity.LogInfo: level = 3; break; case LogSeverity.LogWarning: case LogSeverity.LogAssert: level = 2; break; case LogSeverity.LogError: case LogSeverity.LogException: level = 1; break; default: level = 0; break; } return level; } // --- dllimport start --- [DllImport("__Internal")] private static extern void _BuglyInit(string appId, bool debug, int level); [DllImport("__Internal")] private static extern void _BuglySetUserId(string userId); [DllImport("__Internal")] private static extern void _BuglySetTag(int tag); [DllImport("__Internal")] private static extern void _BuglySetKeyValue(string key, string value); [DllImport("__Internal")] private static extern void _BuglyReportException(int type, string name, string reason, string stackTrace, string extras, bool quit); [DllImport("__Internal")] private static extern void _BuglyDefaultConfig(string channel, string version, string user, string deviceId); [DllImport("__Internal")] private static extern void _BuglyLogMessage(int level, string tag, string log); [DllImport("__Internal")] private static extern void _BuglyConfigCrashReporterType(int type); [DllImport("__Internal")] private static extern void _BuglySetExtraConfig(string key, string value); // dllimport end #endregion #endif #region Privated Fields and Methods private static event LogCallbackDelegate _LogCallbackEventHandler; private static bool _isInitialized = false; private static LogSeverity _autoReportLogLevel = LogSeverity.LogError; private static int _crashReporterType = 1; // Default=0,1=Bugly-V2,MSDKBugly=2, IMSDKBugly=3 #if UNITY_ANDROID // The crash reporter package name, default is 'com.tencent.bugly' private static string _crashReporterPackage = "com.tencent.bugly"; #endif #if UNITY_IPHONE || UNITY_IOS private static int _crashReproterCustomizedLogLevel = 2; // Off=0,Error=1,Warn=2,Info=3,Debug=4 #endif #pragma warning disable 414 private static bool _debugMode = false; private static bool _autoQuitApplicationAfterReport = false; private static readonly int EXCEPTION_TYPE_UNCAUGHT = 1; private static readonly int EXCEPTION_TYPE_CAUGHT = 2; private static readonly string _pluginVersion = "1.5.1"; private static Func<Dictionary<string, string>> _LogCallbackExtrasHandler; public static string PluginVersion { get { return _pluginVersion; } } public static bool IsInitialized { get { return _isInitialized; } } public static bool AutoQuitApplicationAfterReport { get { return _autoQuitApplicationAfterReport; } } private static void _SetCrashReporterType(int type){ _crashReporterType = type; if (_crashReporterType == 2) { #if UNITY_ANDROID _crashReporterPackage = "com.tencent.bugly.msdk"; #endif } } private static void _SetCrashReporterLogLevel(int logLevel){ #if UNITY_IPHONE || UNITY_IOS _crashReproterCustomizedLogLevel = logLevel; #endif } private static void _RegisterExceptionHandler () { try { // hold only one instance #if UNITY_5 Application.logMessageReceived += _OnLogCallbackHandler; #else Application.RegisterLogCallback (_OnLogCallbackHandler); #endif AppDomain.CurrentDomain.UnhandledException += _OnUncaughtExceptionHandler; _isInitialized = true; DebugLog (null, "Register the log callback in Unity {0}", Application.unityVersion); } catch { } SetUnityVersion (); } private static void _UnregisterExceptionHandler () { try { #if UNITY_5 Application.logMessageReceived -= _OnLogCallbackHandler; #else Application.RegisterLogCallback (null); #endif System.AppDomain.CurrentDomain.UnhandledException -= _OnUncaughtExceptionHandler; DebugLog (null, "Unregister the log callback in unity {0}", Application.unityVersion); } catch { } } private static void _OnLogCallbackHandler (string condition, string stackTrace, LogType type) { if (_LogCallbackEventHandler != null) { _LogCallbackEventHandler (condition, stackTrace, type); } if (!IsInitialized) { return; } if (!string.IsNullOrEmpty (condition) && condition.Contains ("[BuglyAgent] <Log>")) { return; } if (_uncaughtAutoReportOnce) { return; } // convert the log level LogSeverity logLevel = LogSeverity.Log; switch (type) { case LogType.Exception: logLevel = LogSeverity.LogException; break; case LogType.Error: logLevel = LogSeverity.LogError; break; case LogType.Assert: logLevel = LogSeverity.LogAssert; break; case LogType.Warning: logLevel = LogSeverity.LogWarning; break; case LogType.Log: logLevel = LogSeverity.LogDebug; break; default: break; } if (LogSeverity.Log == logLevel) { return; } _HandleException (logLevel, null, condition, stackTrace, true); } private static void _OnUncaughtExceptionHandler (object sender, System.UnhandledExceptionEventArgs args) { if (args == null || args.ExceptionObject == null) { return; } try { if (args.ExceptionObject.GetType () != typeof(System.Exception)) { return; } } catch { if (UnityEngine.Debug.isDebugBuild == true) { UnityEngine.Debug.Log ("BuglyAgent: Failed to report uncaught exception"); } return; } if (!IsInitialized) { return; } if (_uncaughtAutoReportOnce) { return; } _HandleException ((System.Exception)args.ExceptionObject, null, true); } private static void _HandleException (System.Exception e, string message, bool uncaught) { if (e == null) { return; } if (!IsInitialized) { return; } string name = e.GetType ().Name; string reason = e.Message; if (!string.IsNullOrEmpty (message)) { reason = string.Format ("{0}{1}***{2}", reason, Environment.NewLine, message); } StringBuilder stackTraceBuilder = new StringBuilder (""); StackTrace stackTrace = new StackTrace (e, true); int count = stackTrace.FrameCount; for (int i = 0; i < count; i++) { StackFrame frame = stackTrace.GetFrame (i); stackTraceBuilder.AppendFormat ("{0}.{1}", frame.GetMethod ().DeclaringType.Name, frame.GetMethod ().Name); ParameterInfo[] parameters = frame.GetMethod ().GetParameters (); if (parameters == null || parameters.Length == 0) { stackTraceBuilder.Append (" () "); } else { stackTraceBuilder.Append (" ("); int pcount = parameters.Length; ParameterInfo param = null; for (int p = 0; p < pcount; p++) { param = parameters [p]; stackTraceBuilder.AppendFormat ("{0} {1}", param.ParameterType.Name, param.Name); if (p != pcount - 1) { stackTraceBuilder.Append (", "); } } param = null; stackTraceBuilder.Append (") "); } string fileName = frame.GetFileName (); if (!string.IsNullOrEmpty (fileName) && !fileName.ToLower ().Equals ("unknown")) { fileName = fileName.Replace ("\\", "/"); int loc = fileName.ToLower ().IndexOf ("/assets/"); if (loc < 0) { loc = fileName.ToLower ().IndexOf ("assets/"); } if (loc > 0) { fileName = fileName.Substring (loc); } stackTraceBuilder.AppendFormat ("(at {0}:{1})", fileName, frame.GetFileLineNumber ()); } stackTraceBuilder.AppendLine (); } // report _reportException (uncaught, name, reason, stackTraceBuilder.ToString ()); } private static void _reportException (bool uncaught, string name, string reason, string stackTrace) { if (string.IsNullOrEmpty (name)) { return; } if (string.IsNullOrEmpty (stackTrace)) { stackTrace = StackTraceUtility.ExtractStackTrace (); } if (string.IsNullOrEmpty (stackTrace)) { stackTrace = "Empty"; } else { try { string[] frames = stackTrace.Split ('\n'); if (frames != null && frames.Length > 0) { StringBuilder trimFrameBuilder = new StringBuilder (); string frame = null; int count = frames.Length; for (int i = 0; i < count; i++) { frame = frames [i]; if (string.IsNullOrEmpty (frame) || string.IsNullOrEmpty (frame.Trim ())) { continue; } frame = frame.Trim (); // System.Collections.Generic if (frame.StartsWith ("System.Collections.Generic.") || frame.StartsWith ("ShimEnumerator")) { continue; } if (frame.StartsWith ("Bugly")) { continue; } if (frame.Contains ("..ctor")) { continue; } int start = frame.ToLower ().IndexOf ("(at"); int end = frame.ToLower ().IndexOf ("/assets/"); if (start > 0 && end > 0) { trimFrameBuilder.AppendFormat ("{0}(at {1}", frame.Substring (0, start).Replace (":", "."), frame.Substring (end)); } else { trimFrameBuilder.Append (frame.Replace (":", ".")); } trimFrameBuilder.AppendLine (); } stackTrace = trimFrameBuilder.ToString (); } } catch { PrintLog(LogSeverity.LogWarning,"{0}", "Error to parse the stack trace"); } } PrintLog (LogSeverity.LogError, "ReportException: {0} {1}\n*********\n{2}\n*********", name, reason, stackTrace); _uncaughtAutoReportOnce = uncaught && _autoQuitApplicationAfterReport; ReportException (uncaught ? EXCEPTION_TYPE_UNCAUGHT : EXCEPTION_TYPE_CAUGHT, name, reason, stackTrace, uncaught && _autoQuitApplicationAfterReport); } private static void _HandleException (LogSeverity logLevel, string name, string message, string stackTrace, bool uncaught) { if (!IsInitialized) { DebugLog (null, "It has not been initialized."); return; } if (logLevel == LogSeverity.Log) { return; } if ((uncaught && logLevel < _autoReportLogLevel)) { DebugLog (null, "Not report exception for level {0}", logLevel.ToString ()); return; } string type = null; string reason = null; if (!string.IsNullOrEmpty (message)) { try { if ((LogSeverity.LogException == logLevel) && message.Contains ("Exception")) { Match match = new Regex (@"^(?<errorType>\S+):\s*(?<errorMessage>.*)", RegexOptions.Singleline).Match (message); if (match.Success) { type = match.Groups ["errorType"].Value.Trim(); reason = match.Groups ["errorMessage"].Value.Trim (); } } else if ((LogSeverity.LogError == logLevel) && message.StartsWith ("Unhandled Exception:")) { Match match = new Regex (@"^Unhandled\s+Exception:\s*(?<exceptionName>\S+):\s*(?<exceptionDetail>.*)", RegexOptions.Singleline).Match(message); if (match.Success) { string exceptionName = match.Groups ["exceptionName"].Value.Trim(); string exceptionDetail = match.Groups ["exceptionDetail"].Value.Trim (); // int dotLocation = exceptionName.LastIndexOf("."); if (dotLocation > 0 && dotLocation != exceptionName.Length) { type = exceptionName.Substring(dotLocation + 1); } else { type = exceptionName; } int stackLocation = exceptionDetail.IndexOf(" at "); if (stackLocation > 0) { // reason = exceptionDetail.Substring(0, stackLocation); // substring after " at " string callStacks = exceptionDetail.Substring(stackLocation + 3).Replace(" at ", "\n").Replace("in <filename unknown>:0","").Replace("[0x00000]",""); // stackTrace = string.Format("{0}\n{1}", stackTrace, callStacks.Trim()); } else { reason = exceptionDetail; } // for LuaScriptException if(type.Equals("LuaScriptException") && exceptionDetail.Contains(".lua") && exceptionDetail.Contains("stack traceback:")) { stackLocation = exceptionDetail.IndexOf("stack traceback:"); if(stackLocation > 0) { reason = exceptionDetail.Substring(0, stackLocation); // substring after "stack traceback:" string callStacks = exceptionDetail.Substring(stackLocation + 16).Replace(" [", " \n["); // stackTrace = string.Format("{0}\n{1}", stackTrace, callStacks.Trim()); } } } } } catch { } if (string.IsNullOrEmpty (reason)) { reason = message; } } if (string.IsNullOrEmpty (name)) { if (string.IsNullOrEmpty (type)) { type = string.Format ("Unity{0}", logLevel.ToString ()); } } else { type = name; } _reportException (uncaught, type, reason, stackTrace); } private static bool _uncaughtAutoReportOnce = false; #endregion } Assets/Plugins/BuglyPlugins/BuglyAgent.cs.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: be621fe31508b4f2ab134ee879ec97b4 MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: Assets/Plugins/BuglyPlugins/BuglyCallback.cs
New file @@ -0,0 +1,27 @@ // ---------------------------------------- // // BuglyCallbackDelegate.cs // // Author: // Yeelik, <bugly@tencent.com> // // Copyright (c) 2015 Bugly, Tencent. All rights reserved. // // ---------------------------------------- // using UnityEngine; using System.Collections; public abstract class BuglyCallback { // The delegate of callback handler which Call the Application.RegisterLogCallback(Application.LogCallback) /// <summary> /// Raises the application log callback handler event. /// </summary> /// <param name="condition">Condition.</param> /// <param name="stackTrace">Stack trace.</param> /// <param name="type">Type.</param> public abstract void OnApplicationLogCallbackHandler (string condition, string stackTrace, LogType type); } Assets/Plugins/BuglyPlugins/BuglyCallback.cs.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: 78e76f643d1884dcab602d5fe79b08e1 MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: Assets/Plugins/BuglyPlugins/BuglyInit.cs
New file @@ -0,0 +1,80 @@ // ---------------------------------------- // // BuglyInit.cs // // Author: // Yeelik, <bugly@tencent.com> // // Copyright (c) 2015 Bugly, Tencent. All rights reserved. // // ---------------------------------------- // using UnityEngine; using System.Collections; using System.Collections.Generic; public class BuglyInit : MonoBehaviour { /// <summary> /// Your Bugly App ID. Every app has a special identifier that allows Bugly to associate error monitoring data with your app. /// Your App ID can be found on the "Setting" page of the app you are trying to monitor. /// </summary> /// <example>A real App ID looks like this: 90000xxxx</example> private const string BuglyAppID = "YOUR APP ID GOES HERE"; void Awake () { // Enable the debug log print BuglyAgent.ConfigDebugMode (false); // Config default channel, version, user BuglyAgent.ConfigDefault (null, null, null, 0); // Config auto report log level, default is LogSeverity.LogError, so the LogError, LogException log will auto report BuglyAgent.ConfigAutoReportLogLevel (LogSeverity.LogError); // Config auto quit the application make sure only the first one c# exception log will be report, please don't set TRUE if you do not known what are you doing. BuglyAgent.ConfigAutoQuitApplication (false); // If you need register Application.RegisterLogCallback(LogCallback), you can replace it with this method to make sure your function is ok. BuglyAgent.RegisterLogCallback (null); // Init the bugly sdk and enable the c# exception handler. BuglyAgent.InitWithAppId (BuglyAppID); // TODO Required. If you do not need call 'InitWithAppId(string)' to initialize the sdk(may be you has initialized the sdk it associated Android or iOS project), // please call this method to enable c# exception handler only. BuglyAgent.EnableExceptionHandler (); // TODO NOT Required. If you need to report extra data with exception, you can set the extra handler BuglyAgent.SetLogCallbackExtrasHandler (MyLogCallbackExtrasHandler); Destroy (this); } // Extra data handler to packet data and report them with exception. // Please do not do hard work in this handler static Dictionary<string, string> MyLogCallbackExtrasHandler () { // TODO Test log, please do not copy it BuglyAgent.PrintLog (LogSeverity.Log, "extra handler"); // TODO Sample code, please do not copy it Dictionary<string, string> extras = new Dictionary<string, string> (); extras.Add ("ScreenSolution", string.Format ("{0}x{1}", Screen.width, Screen.height)); extras.Add ("deviceModel", SystemInfo.deviceModel); extras.Add ("deviceName", SystemInfo.deviceName); extras.Add ("deviceType", SystemInfo.deviceType.ToString ()); extras.Add ("deviceUId", SystemInfo.deviceUniqueIdentifier); extras.Add ("gDId", string.Format ("{0}", SystemInfo.graphicsDeviceID)); extras.Add ("gDName", SystemInfo.graphicsDeviceName); extras.Add ("gDVdr", SystemInfo.graphicsDeviceVendor); extras.Add ("gDVer", SystemInfo.graphicsDeviceVersion); extras.Add ("gDVdrID", string.Format ("{0}", SystemInfo.graphicsDeviceVendorID)); extras.Add ("graphicsMemorySize", string.Format ("{0}", SystemInfo.graphicsMemorySize)); extras.Add ("systemMemorySize", string.Format ("{0}", SystemInfo.systemMemorySize)); extras.Add ("UnityVersion", Application.unityVersion); BuglyAgent.PrintLog (LogSeverity.LogInfo, "Package extra data"); return extras; } } Assets/Plugins/BuglyPlugins/BuglyInit.cs.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: a717f6955eddf4463ad541714a1b5483 MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: Assets/Plugins/BuglyPlugins/iOS.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: e56fceb1868ea594389663d8ab246744 folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework.meta
New file @@ -0,0 +1,68 @@ fileFormatVersion: 2 guid: 0e6c7f01000593e44b68b0910c9c407f folderAsset: yes PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: : Any second: enabled: 0 settings: Exclude Editor: 1 Exclude Linux64: 1 Exclude OSXUniversal: 1 Exclude Win: 1 Exclude Win64: 1 Exclude iOS: 0 - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: DefaultValueInitialized: true - first: Standalone: Linux64 second: enabled: 0 settings: CPU: x86 - first: Standalone: OSXUniversal second: enabled: 0 settings: CPU: x86 - first: Standalone: Win second: enabled: 0 settings: CPU: None - first: Standalone: Win64 second: enabled: 0 settings: CPU: None - first: iPhone: iOS second: enabled: 1 settings: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/BuglyBinary files differ
Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Bugly.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: 6fb083d2179d34d42baa73ed0b447681 DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: 9fa107de92f7e8f4b940ef540042bb94 folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/Bugly.h
New file @@ -0,0 +1,163 @@ // // Bugly.h // // Version: 2.5(71) // // Copyright (c) 2017年 Tencent. All rights reserved. // #import <Foundation/Foundation.h> #import "BuglyConfig.h" #import "BuglyLog.h" BLY_START_NONNULL @interface Bugly : NSObject /** * 初始化Bugly,使用默认BuglyConfigs * * @param appId 注册Bugly分配的应用唯一标识 */ + (void)startWithAppId:(NSString * BLY_NULLABLE)appId; /** * 使用指定配置初始化Bugly * * @param appId 注册Bugly分配的应用唯一标识 * @param config 传入配置的 BuglyConfig */ + (void)startWithAppId:(NSString * BLY_NULLABLE)appId config:(BuglyConfig * BLY_NULLABLE)config; /** * 使用指定配置初始化Bugly * * @param appId 注册Bugly分配的应用唯一标识 * @param development 是否开发设备 * @param config 传入配置的 BuglyConfig */ + (void)startWithAppId:(NSString * BLY_NULLABLE)appId developmentDevice:(BOOL)development config:(BuglyConfig * BLY_NULLABLE)config; /** * 设置用户标识 * * @param userId 用户标识 */ + (void)setUserIdentifier:(NSString *)userId; /** * 更新版本信息 * * @param version 应用版本信息 */ + (void)updateAppVersion:(NSString *)version; /** * 设置关键数据,随崩溃信息上报 * * @param value KEY * @param key VALUE */ + (void)setUserValue:(NSString *)value forKey:(NSString *)key; /** * 获取USER ID * * @return USER ID */ + (NSString *)buglyUserIdentifier; /** * 获取关键数据 * * @return 关键数据 */ + (NSDictionary * BLY_NULLABLE)allUserValues; /** * 设置标签 * * @param tag 标签ID,可在网站生成 */ + (void)setTag:(NSUInteger)tag; /** * 获取当前设置标签 * * @return 当前标签ID */ + (NSUInteger)currentTag; /** * 获取设备ID * * @return 设备ID */ + (NSString *)buglyDeviceId; /** * 上报自定义Objective-C异常 * * @param exception 异常信息 */ + (void)reportException:(NSException *)exception; /** * 上报错误 * * @param error 错误信息 */ + (void)reportError:(NSError *)error; /** * @brief 上报自定义错误 * * @param category 类型(Cocoa=3,CSharp=4,JS=5,Lua=6) * @param aName 名称 * @param aReason 错误原因 * @param aStackArray 堆栈 * @param info 附加数据 * @param terminate 上报后是否退出应用进程 */ + (void)reportExceptionWithCategory:(NSUInteger)category name:(NSString *)aName reason:(NSString *)aReason callStack:(NSArray *)aStackArray extraInfo:(NSDictionary *)info terminateApp:(BOOL)terminate; /** * SDK 版本信息 * * @return SDK版本号 */ + (NSString *)sdkVersion; /** * APP 版本信息 * * @return SDK版本号 */ + (NSString *)appVersion; /** * App 是否发生了连续闪退 * 如果 启动SDK 且 5秒内 闪退,且次数达到 3次 则判定为连续闪退 * * @return 是否连续闪退 */ + (BOOL)isAppCrashedOnStartUpExceedTheLimit; /** * 关闭bugly监控 */ + (void)closeCrashReport; BLY_END_NONNULL @end Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/Bugly.h.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: ba9736162b6306e40818f1b83f0372ef DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/BuglyConfig.h
New file @@ -0,0 +1,141 @@ // // BuglyConfig.h // Bugly // // Copyright (c) 2016年 Tencent. All rights reserved. // #pragma once #define BLY_UNAVAILABLE(x) __attribute__((unavailable(x))) #if __has_feature(nullability) #define BLY_NONNULL __nonnull #define BLY_NULLABLE __nullable #define BLY_START_NONNULL _Pragma("clang assume_nonnull begin") #define BLY_END_NONNULL _Pragma("clang assume_nonnull end") #else #define BLY_NONNULL #define BLY_NULLABLE #define BLY_START_NONNULL #define BLY_END_NONNULL #endif #import <Foundation/Foundation.h> #import "BuglyLog.h" BLY_START_NONNULL @protocol BuglyDelegate <NSObject> @optional /** * 发生异常时回调 * * @param exception 异常信息 * * @return 返回需上报记录,随异常上报一起上报 */ - (NSString * BLY_NULLABLE)attachmentForException:(NSException * BLY_NULLABLE)exception; /** * 策略激活时回调 * * @param tacticInfo * * @return app是否弹框展示 */ - (BOOL) h5AlertForTactic:(NSDictionary *)tacticInfo; @end @interface BuglyConfig : NSObject /** * SDK Debug信息开关, 默认关闭 */ @property (nonatomic, assign) BOOL debugMode; /** * 设置自定义渠道标识 */ @property (nonatomic, copy) NSString *channel; /** * 设置自定义版本号 */ @property (nonatomic, copy) NSString *version; /** * 设置自定义设备唯一标识 */ @property (nonatomic, copy) NSString *deviceIdentifier; /** * 卡顿监控开关,默认关闭 */ @property (nonatomic) BOOL blockMonitorEnable; /** * 卡顿监控判断间隔,单位为秒 */ @property (nonatomic) NSTimeInterval blockMonitorTimeout; /** * 设置 App Groups Id (如有使用 Bugly iOS Extension SDK,请设置该值) */ @property (nonatomic, copy) NSString *applicationGroupIdentifier; /** * 进程内还原开关,默认开启 */ @property (nonatomic) BOOL symbolicateInProcessEnable; /** * 非正常退出事件记录开关,默认关闭 */ @property (nonatomic) BOOL unexpectedTerminatingDetectionEnable; /** * 页面信息记录开关,默认开启 */ @property (nonatomic) BOOL viewControllerTrackingEnable; /** * Bugly Delegate */ @property (nonatomic, assign) id<BuglyDelegate> delegate; /** * 控制自定义日志上报,默认值为BuglyLogLevelSilent,即关闭日志记录功能。 * 如果设置为BuglyLogLevelWarn,则在崩溃时会上报Warn、Error接口打印的日志 */ @property (nonatomic, assign) BuglyLogLevel reportLogLevel; /** * 崩溃数据过滤器,如果崩溃堆栈的模块名包含过滤器中设置的关键字,则崩溃数据不会进行上报 * 例如,过滤崩溃堆栈中包含搜狗输入法的数据,可以添加过滤器关键字SogouInputIPhone.dylib等 */ @property (nonatomic, copy) NSArray *excludeModuleFilter; /** * 控制台日志上报开关,默认开启 */ @property (nonatomic, assign) BOOL consolelogEnable; /** * 崩溃退出超时,如果监听到崩溃后,App一直没有退出,则到达超时时间后会自动abort进程退出 * 默认值 5s, 单位 秒 * 当赋值为0时,则不会自动abort进程退出 */ @property (nonatomic, assign) NSUInteger crashAbortTimeout; /** * 设置自定义联网、crash上报域名 */ @property (nonatomic, copy) NSString *crashServerUrl; @end BLY_END_NONNULL Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/BuglyConfig.h.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: afc0e443a10bee0478f0fd37d59615a7 DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/BuglyLog.h
New file @@ -0,0 +1,78 @@ // // BuglyLog.h // Bugly // // Copyright (c) 2017年 Tencent. All rights reserved. // #import <Foundation/Foundation.h> // Log level for Bugly Log typedef NS_ENUM(NSUInteger, BuglyLogLevel) { BuglyLogLevelSilent = 0, BuglyLogLevelError = 1, BuglyLogLevelWarn = 2, BuglyLogLevelInfo = 3, BuglyLogLevelDebug = 4, BuglyLogLevelVerbose = 5, }; #pragma mark - OBJC_EXTERN void BLYLog(BuglyLogLevel level, NSString *format, ...) NS_FORMAT_FUNCTION(2, 3); OBJC_EXTERN void BLYLogv(BuglyLogLevel level, NSString *format, va_list args) NS_FORMAT_FUNCTION(2, 0); #pragma mark - #define BUGLY_LOG_MACRO(_level, fmt, ...) [BuglyLog level:_level tag:nil log:fmt, ##__VA_ARGS__] #define BLYLogError(fmt, ...) BUGLY_LOG_MACRO(BuglyLogLevelError, fmt, ##__VA_ARGS__) #define BLYLogWarn(fmt, ...) BUGLY_LOG_MACRO(BuglyLogLevelWarn, fmt, ##__VA_ARGS__) #define BLYLogInfo(fmt, ...) BUGLY_LOG_MACRO(BuglyLogLevelInfo, fmt, ##__VA_ARGS__) #define BLYLogDebug(fmt, ...) BUGLY_LOG_MACRO(BuglyLogLevelDebug, fmt, ##__VA_ARGS__) #define BLYLogVerbose(fmt, ...) BUGLY_LOG_MACRO(BuglyLogLevelVerbose, fmt, ##__VA_ARGS__) #pragma mark - Interface @interface BuglyLog : NSObject /** * @brief 初始化日志模块 * * @param level 设置默认日志级别,默认BLYLogLevelSilent * * @param printConsole 是否打印到控制台,默认NO */ + (void)initLogger:(BuglyLogLevel) level consolePrint:(BOOL)printConsole; /** * @brief 打印BLYLogLevelInfo日志 * * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 */ + (void)log:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2); /** * @brief 打印日志 * * @param level 日志级别 * @param message 日志内容 总日志大小限制为:字符串长度30k,条数200 */ + (void)level:(BuglyLogLevel) level logs:(NSString *)message; /** * @brief 打印日志 * * @param level 日志级别 * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 */ + (void)level:(BuglyLogLevel) level log:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3); /** * @brief 打印日志 * * @param level 日志级别 * @param tag 日志模块分类 * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 */ + (void)level:(BuglyLogLevel) level tag:(NSString *) tag log:(NSString *)format, ... NS_FORMAT_FUNCTION(3, 4); @end Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Headers/BuglyLog.h.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: d362d0ae9e89f87448b3959c3149ba63 DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Modules.meta
New file @@ -0,0 +1,8 @@ fileFormatVersion: 2 guid: 1ab42a981bf428b42808e862a754d662 folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Modules/module.modulemap
New file @@ -0,0 +1,12 @@ framework module Bugly { umbrella header "Bugly.h" export * module * { export * } link framework "Foundation" link framework "Security" link framework "SystemConfiguration" link "c++" link "z" } Assets/Plugins/BuglyPlugins/iOS/Bugly.framework/Modules/module.modulemap.meta
New file @@ -0,0 +1,7 @@ fileFormatVersion: 2 guid: f97d56d4ba4832c448f86ac3b7a33d9e DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/BuglyBridge.h
New file @@ -0,0 +1,101 @@ // // BuglyBridge.h // BuglyAgent // // Created by Yeelik on 15/11/25. // Copyright © 2015年 Bugly. All rights reserved. // // Version: 1.3.3 // #import <Foundation/Foundation.h> #pragma mark - Interface for Bridge #ifdef __cplusplus extern "C"{ #endif /** * @brief 初始化 * * @param appId 应用标识 * @param debug 是否开启debug模式,开启后会在控制台打印调试信息,默认为NO * @param level 自定义日志上报级别,使用SDK接口打印的日志会跟崩溃信息一起上报,默认为Info(即Info、Warning、Error级别的日志都会上报) * Debug=4,Info=3,Warnning=2,Error=1,Off=0 */ void _BuglyInit(const char * appId, bool debug, int level); /** * @brief 设置用户唯一标识 * * @param userId */ void _BuglySetUserId(const char * userId); /** * @brief 设置自定义标签 * * @param tag */ void _BuglySetTag(int tag); /** * @brief 设置自定义键值对数据 * * @param key * @param value */ void _BuglySetKeyValue(const char * key, const char * value); /** * @brief 自定义异常数据上报 * * @param type * @param name 异常类型 * @param reason 异常原因 * @param stackTrace 异常堆栈 * @param extras 附加数据 * @param quit 上报后是否退出应用 */ void _BuglyReportException(int type, const char * name, const char * reason, const char * stackTrace, const char * extras, bool quit); /** * @brief 设置默认的应用配置,在初始化之前调用 * * @param channel 渠道 * @param version 应用版本 * @param user 用户 * @param deviceId 设备唯一标识 */ void _BuglyDefaultConfig(const char * channel, const char * version, const char *user, const char * deviceId); /** * @brief 自定义日志打印接口 * * @param level 日志级别, 1=Error、2=Warning、3=Info、4=Debug * @param tag 日志标签 * @param log 日志内容 */ void _BuglyLogMessage(int level, const char * tag, const char * log); /** * @brief 设置崩溃上报组件的类别 * * @param type 0=Default、1=Bugly、2=MSDK、3=IMSDK */ void _BuglyConfigCrashReporterType(int type); /** * @brief 设置额外的配置信息 * * @param key * @param value */ void _BuglySetExtraConfig(const char *key, const char * value); #ifdef __cplusplus } // extern "C" #endif #pragma mark - Assets/Plugins/BuglyPlugins/iOS/BuglyBridge.h.meta
New file @@ -0,0 +1,67 @@ fileFormatVersion: 2 guid: 179a13c04606f06438dd4abaa4216d3b PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: : Any second: enabled: 0 settings: Exclude Editor: 1 Exclude Linux64: 1 Exclude OSXUniversal: 1 Exclude Win: 1 Exclude Win64: 1 Exclude iOS: 0 - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: DefaultValueInitialized: true - first: Standalone: Linux64 second: enabled: 0 settings: CPU: x86 - first: Standalone: OSXUniversal second: enabled: 0 settings: CPU: x86 - first: Standalone: Win second: enabled: 0 settings: CPU: None - first: Standalone: Win64 second: enabled: 0 settings: CPU: None - first: iPhone: iOS second: enabled: 1 settings: {} userData: assetBundleName: assetBundleVariant: Assets/Plugins/BuglyPlugins/iOS/libBuglyBridge.aBinary files differ
Assets/Plugins/BuglyPlugins/iOS/libBuglyBridge.a.meta
New file @@ -0,0 +1,67 @@ fileFormatVersion: 2 guid: 230abe21ddfebfa48ab04cb2c8c21199 PluginImporter: externalObjects: {} serializedVersion: 2 iconMap: {} executionOrder: {} defineConstraints: [] isPreloaded: 0 isOverridable: 0 isExplicitlyReferenced: 0 validateReferences: 1 platformData: - first: : Any second: enabled: 0 settings: Exclude Editor: 1 Exclude Linux64: 1 Exclude OSXUniversal: 1 Exclude Win: 1 Exclude Win64: 1 Exclude iOS: 0 - first: Any: second: enabled: 0 settings: {} - first: Editor: Editor second: enabled: 0 settings: DefaultValueInitialized: true - first: Standalone: Linux64 second: enabled: 0 settings: CPU: x86 - first: Standalone: OSXUniversal second: enabled: 0 settings: CPU: x86 - first: Standalone: Win second: enabled: 0 settings: CPU: None - first: Standalone: Win64 second: enabled: 0 settings: CPU: None - first: iPhone: iOS second: enabled: 1 settings: {} userData: assetBundleName: assetBundleVariant: