From 175bf71acfb05a8451241a1a7fd8ff227852e2d3 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Thu, 7 Sep 2017 13:01:16 +0300 Subject: [PATCH] Code samples added in Swift --- Documentation/Guides/Installation & Setup.md | 45 +++++++++----------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/Documentation/Guides/Installation & Setup.md b/Documentation/Guides/Installation & Setup.md index 43cef6c29c..fbcfbfdd17 100644 --- a/Documentation/Guides/Installation & Setup.md +++ b/Documentation/Guides/Installation & Setup.md @@ -125,30 +125,7 @@ Our examples will use the **default** SDK (`HockeySDK.embeddedframework`). [[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation]; // This line is obsolete in the crash only builds ``` -**Swift 2.3** - -1. Open your `AppDelegate.swift` file. -2. Add the following line at the top of the file below your own import statements: - - ```swift - import HockeySDK - ``` - -3. Search for the method - - ```swift - application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:[NSObject: AnyObject]?) -> Bool - ``` - -4. Add the following lines to setup and start the HockeyApp SDK: - - ```swift - BITHockeyManager.sharedHockeyManager().configureWithIdentifier("APP_IDENTIFIER") - BITHockeyManager.sharedHockeyManager().startManager() - BITHockeyManager.sharedHockeyManager().authenticator.authenticateInstallation() // This line is obsolete in the crash only builds - ``` - -**Swift 3** +**Swift** 1. Open your `AppDelegate.swift` file. 2. Add the following line at the top of the file below your own import statements: @@ -313,6 +290,8 @@ The following points need to be considered to use the HockeySDK SDK with iOS Ext 1. Each extension is required to use the same values for version (`CFBundleShortVersionString`) and build number (`CFBundleVersion`) as the main app uses. (This is required only if you are using the same `APP_IDENTIFIER` for your app and extensions). 2. You need to make sure the SDK setup code is only invoked **once**. Since there is no `applicationDidFinishLaunching:` equivalent and `viewDidLoad` can run multiple times, you need to use a setup like the following example: +**Objective-C** + ```objc static BOOL didSetupHockeySDK = NO; @@ -332,6 +311,24 @@ The following points need to be considered to use the HockeySDK SDK with iOS Ext } ``` + **Swift** + + ```swift + class TodayViewController: UIViewController, NCWidgetProviding { + + static var didSetupHockeySDK = false; + + override func viewDidLoad() { + super.viewDidLoad() + if !TodayViewController.didSetupHockeySDK { + BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER") + BITHockeyManager.shared().start() + TodayViewController.didSetupHockeySDK = true + } + } + } + ``` + 3. The binary distribution provides a special framework build in the `HockeySDKCrashOnly` or `HockeySDKCrashOnlyExtension` folder of the distribution zip file, which only contains crash reporting functionality (also automatic sending crash reports only).