通过 CocoaPods 集成
注意:
- 当前最新版本为
1.0.5
,请通过pod update BugtagsInsta
更新,不要用--no-repo-update
选项,如果无法获取到最新版本,请先运行pod repo update
更新本地的pod
仓库; - SDK 最低兼容 iOS 7.0;
- 请确保应用已成功集成 Bugtags SDK v1.3.0 +。
步骤:
- 在你项目的 Podfile 中添加以下代码
pod 'BugtagsInsta'
执行 pod 安装命令
pod install
如果无法获取到最新版本的
BugtagsInsta SDK
,请运行以下命令更新本地的pod
仓库pod repo update
运行完成后,重新执行安装命令
pod install
在
AppDelegate.m
中导入头文件#import <BugtagsInsta/BugtagsInsta.h>
如果是 Swift 项目,请在对应的 bridging-header.h 中导入
在项目 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
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble) Bugtags.registerPlugin(BugtagsInsta()) return true }
如果你需要自定义
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
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble) Bugtags.registerPlugin(BugtagsInsta(port: 10222)) return true }