手动集成

注意:

  • SDK 最低兼容 iOS 7.0;
  • 请确保应用已成功集成 Bugtags SDK v1.3.0 +。

步骤:

  1. 下载 SDK 压缩包 并解压缩
  2. BugtagsInsta.framework 文件夹拖到 Xcode 项目中
  3. 在应用的设置中,Build Phases -> Link Binary With Libraries 里添加以下 framework
     Foundation  Security    CFNetwork    libz.tbd
    
  4. AppDelegate.m 中导入头文件

    #import <BugtagsInsta/BugtagsInsta.h>
    

    如果是 Swift 项目,请在对应的 bridging-header.h 中导入

  5. 在项目 AppDelegate 的 application didFinishLaunchingWithOptions 方法中初始化 BugtagsInsta 并注册到 Bugtags

    Objective-C

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
         [Bugtags startWithAppKey:@"APP_KEY" invocationEvent:BTGInvocationEventBubble];
         [Bugtags registerPlugin:[[BugtagsInsta alloc] init]];
         return YES;
     }
    

    Swift 3

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
         Bugtags.start(withAppKey: "APP_KEY", invocationEvent: BTGInvocationEventBubble)
         Bugtags.registerPlugin(BugtagsInsta())
         return true
     }
    

    Swift 2

     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
         Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble)
         Bugtags.registerPlugin(BugtagsInsta())
         return true
     }
    
  6. 如果你需要自定义 BugtagsInsta 的监听端口,可以在 BugtagsInsta 的初始化方法中传入端口号,建议端口号为 10000 以上:

    Objective-C

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
         [Bugtags startWithAppKey:@"APP_KEY" invocationEvent:BTGInvocationEventBubble];
         [Bugtags registerPlugin:[[BugtagsInsta alloc] initWithPort:10222]];
         return YES;
     }
    

    Swift 3

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
         Bugtags.start(withAppKey: "APP_KEY", invocationEvent: BTGInvocationEventBubble)
         Bugtags.registerPlugin(BugtagsInsta(port: 10222))
         return true
     }
    

    Swift 2

     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
         Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble)
         Bugtags.registerPlugin(BugtagsInsta(port: 10222))
         return true
     }
    
评论