GithubHelp home page GithubHelp logo

j-swift / hockeysdk-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitstadium/hockeysdk-ios

0.0 3.0 0.0 24.11 MB

The official iOS SDK for the HockeyApp service (Releases are in the master branch, current development in the default develop branch)

Home Page: http://hockeyapp.net/releases

License: Other

Objective-C 97.76% Objective-C++ 0.83% C 1.05% Ruby 0.36%

hockeysdk-ios's Introduction

Build Status Carthage compatible Version

Version 4.1.0-beta.2

NOTE: With the release of HockeySDK 4.0.0-alpha.1 a bug was introduced which lead to the exclusion of the Application Support folder from iCloud and iTunes backups.

If you have been using one of the affected versions (4.0.0-alpha.2, Version 4.0.0-beta.1, 4.0.0, 4.1.0-alpha.1, 4.1.0-alpha.2, or Version 4.1.0-beta.1), please make sure to update to at least version 4.0.1 or 4.1.0-beta.2 of our SDK as soon as you can.

Introduction

HockeySDK-iOS implements support for using HockeyApp in your iOS applications.

The following features are currently supported:

  1. Collect crash reports: If your app crashes, a crash log with the same format as from the Apple Crash Reporter is written to the device's storage. If the user starts the app again, he is asked to submit the crash report to HockeyApp. This works for both beta and live apps, i.e. those submitted to the App Store.

  2. User Metrics: Understand user behavior to improve your app. Track usage through daily and monthly active users, monitor crash impacted users, as well as customer engagement through session count. If you are part of Preseason, you can now track Custom Events in your app, understand user actions and see the aggregates on the HockeyApp portal.

  3. Update Ad-Hoc / Enterprise apps: The app will check with HockeyApp if a new version for your Ad-Hoc or Enterprise build is available. If yes, it will show an alert view to the user and let him see the release notes, the version history and start the installation process right away.

  4. Update notification for app store: The app will check if a new version for your app store release is available. If yes, it will show an alert view to the user and let him open your app in the App Store app. (Disabled by default!)

  5. Feedback: Collect feedback from your users from within your app and communicate directly with them using the HockeyApp backend.

  6. Authenticate: Identify and authenticate users of Ad-Hoc or Enterprise builds

This document contains the following sections:

  1. Requirements
  2. Setup
  3. Advanced Setup
  4. Linking System Frameworks manually
  5. CocoaPods
  6. Carthage
  7. iOS Extensions
  8. WatchKit 1 Extensions
  9. Crash Reporting
  10. User Metrics
  11. Feedback
  12. Store Updates
  13. In-App-Updates (Beta & Enterprise only)
  14. Debug information
  15. Documentation
  16. Troubleshooting
  17. Contributing
  18. Contributor License
  19. Contact

1. Requirements

  1. We assume that you already have a project in Xcode and that this project is opened in Xcode 7 or later.
  2. The SDK supports iOS 6.0 and later.

2. Setup

We recommend integration of our binary into your Xcode project to setup HockeySDK for your iOS app. You can also use our interactive SDK integration wizard in HockeyApp for Mac which covers all the steps from below. For other ways to setup the SDK, see Advanced Setup.

2.1 Obtain an App Identifier

Please see the "How to create a new app" tutorial. This will provide you with an HockeyApp specific App Identifier to be used to initialize the SDK.

2.2 Download the SDK

  1. Download the latest HockeySDK-iOS framework which is provided as a zip-File.
  2. Unzip the file and you will see a folder called HockeySDK-iOS. (Make sure not to use 3rd party unzip tools!)

2.3 Copy the SDK into your projects directory in Finder

From our experience, 3rd-party libraries usually reside inside a subdirectory (let's call our subdirectory Vendor), so if you don't have your project organized with a subdirectory for libraries, now would be a great start for it. To continue our example, create a folder called Vendor inside your project directory and move the unzipped HockeySDK-iOS-folder into it.

The SDK comes in three flavours:

  • Full featured HockeySDK.embeddedframework
  • Crash reporting only: HockeySDK.framework in the subfolder HockeySDKCrashOnly
  • Crash reporting only for extensions: HockeySDK.framework in the subfolder HockeySDKCrashOnlyExtension (which is required to be used for extensions).

Our examples will use the full featured SDK (HockeySDK.embeddedframework).

2.4 Add the SDK to the project in Xcode

We recommend to use Xcode's group-feature to create a group for 3rd-party-libraries similar to the structure of our files on disk. For example, similar to the file structure in 2.3 above, our projects have a group called Vendor.

  1. Make sure the Project Navigator is visible (โŒ˜+1).
  2. Drag & drop HockeySDK.embeddedframework from your Finder to the Vendor group in Xcode using the Project Navigator on the left side.
  3. An overlay will appear. Select Create groups and set the checkmark for your target. Then click Finish.

2.5 Modify Code

Objective-C

  1. Open your AppDelegate.m file.
  2. Add the following line at the top of the file below your own import statements:
@import HockeySDK;
  1. Search for the method application:didFinishLaunchingWithOptions:
  2. Add the following lines to setup and start the Application Insights SDK:
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
// Do some additional configuration if needed here
[[BITHockeyManager sharedHockeyManager] startManager];
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation]; // This line is obsolete in the crash only builds

Swift

  1. Open your AppDelegate.swift file.
  2. Add the following line at the top of the file below your own import statements:
import HockeySDK
  1. Search for the method
application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:[NSObject: AnyObject]?) -> Bool
  1. Add the following lines to setup and start the Application Insights SDK:
BITHockeyManager.sharedHockeyManager().configureWithIdentifier("APP_IDENTIFIER")
BITHockeyManager.sharedHockeyManager().startManager()
BITHockeyManager.sharedHockeyManager().authenticator.authenticateInstallation() // This line is obsolete in the crash only builds

Note: The SDK is optimized to defer everything possible to a later time while making sure e.g. crashes on startup can also be caught and each module executes other code with a delay some seconds. This ensures that applicationDidFinishLaunching will process as fast as possible and the SDK will not block the startup sequence resulting in a possible kill by the watchdog process.

Congratulation, now you're all set to use HockeySDK!

3. Advanced Setup

3.1 Linking System Frameworks manually

If you are working with an older project which doesn't support clang modules yet or you for some reason turned off the Enable Modules (C and Objective-C and Link Frameworks Automatically options in Xcode, you have to manually link some system frameworks:

  1. Select your project in the Project Navigator (โŒ˜+1).
  2. Select your app target.
  3. Select the tab Build Phases.
  4. Expand Link Binary With Libraries.
  5. Add the following system frameworks, if they are missing:
  6. Full Featured: + AssetsLibrary + CoreText + CoreGraphics + Foundation + MobileCoreServices + QuartzCore + QuickLook + Photos + Security + SystemConfiguration + UIKit + libc++ + libz
  7. Crash reporting only: + Foundation + Security + SystemConfiguration + UIKit + libc++
  8. Crash reporting only for extensions: + Foundation + Security + SystemConfiguration + libc++

Note that this also means that you can't use the @import syntax mentioned in the Modify Code section but have to stick to the old #import <HockeySDK/HockeySDK.h>.

3.2 CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like HockeySDK in your projects. To learn how to setup CocoaPods for your project, visit the official CocoaPods website.

Podfile

platform :ios, '8.0'
pod "HockeySDK"

3.2.1 Binary Distribution Options

The default and recommended distribution is a binary (static library) and a resource bundle with translations and images for all SDK Features: Crash Reporting, User Feedback, Store Updates, Authentication, AdHoc Updates.

You can alternative use a Crash Reporting build only by using the following line in your Podfile:

pod "HockeySDK", :subspecs => ['CrashOnlyLib']

Or you can use the Crash Reporting build only for extensions by using the following line in your Podfile:

pod "HockeySDK", :subspecs => ['CrashOnlyExtensionsLib']

3.2.2 Source Integration Options

Alternatively you can integrate the SDK by source if you want to do any modifications or want a different feature set. The following entry will integrate the SDK:

pod "HockeySDK-Source"

3.3 Carthage

Carthage is an alternative way to add frameworks to your app. For general information about how to use Carthage, please follow their documentation.

To add HockeySDK to your project, simply put this line into your Cartfile:

github "bitstadium/HockeySDK-iOS"

and then follow the steps described in the Carthage documentation.

3.4 iOS Extensions

The following points need to be considered to use the HockeySDK SDK with iOS Extensions:

  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:
static BOOL didSetupHockeySDK = NO;

@interface TodayViewController () <NCWidgetProviding>

@end

@implementation TodayViewController

+ (void)viewDidLoad {
  [super viewDidLoad];
  if (!didSetupHockeySDK) {
    [[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
    [[BITHockeyManager sharedHockeyManager] startManager];
    didSetupHockeySDK = YES;
  }
}
  1. 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).

3.5 WatchKit 1 Extensions

The following points need to be considered to use HockeySDK with WatchKit 1 Extensions:

  1. WatchKit extensions don't use regular UIViewControllers but rather WKInterfaceController subclasses. These have a different lifecycle than you might be used to.

To make sure that the HockeySDK is only instantiated once in the WatchKit extension's lifecycle we recommend using a helper class similar to this:

@import Foundation;

@interface BITWatchSDKSetup : NSObject

* (void)setupHockeySDKIfNeeded;

@end
#import "BITWatchSDKSetup.h"
@import HockeySDK

static BOOL hockeySDKIsSetup = NO;

@implementation BITWatchSDKSetup

* (void)setupHockeySDKIfNeeded {
  if (!hockeySDKIsSetup) {
    [[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
    [[BITHockeyManager sharedHockeyManager] startManager];
    hockeySDKIsSetup = YES;
  }
}

@end

Then, in each of your WKInterfaceControllers where you want to use the HockeySDK, you should do this:

#import "InterfaceController.h"
@import HockeySDK
#import "BITWatchSDKSetup.h"

@implementation InterfaceController

+ (void)awakeWithContext:(id)context {
  [super awakeWithContext:context];
  [BITWatchSDKSetup setupHockeySDKIfNeeded];
}

+ (void)willActivate {
  [super willActivate];
}

+ (void)didDeactivate {
  [super didDeactivate];
}

@end
  1. 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).

3.6 Crash Reporting

The following options only show some of possibilities to interact and fine-tune the crash reporting feature. For more please check the full documentation of the BITCrashManager class in our documentation.

3.6.1 Disable Crash Reporting

The HockeySDK enables crash reporting per default. Crashes will be immediately sent to the server the next time the app is launched.

To provide you with the best crash reporting, we are using PLCrashReporter in Version 1.2 / Commit 356901d7f3ca3d46fbc8640f469304e2b755e461.

This feature can be disabled as follows:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setDisableCrashManager: YES]; //disable crash reporting

[[BITHockeyManager sharedHockeyManager] startManager];

3.6.2 Autosend crash reports

Crashes are send the next time the app starts. If crashManagerStatus is set to BITCrashManagerStatusAutoSend, crashes will be send without any user interaction, otherwise an alert will appear allowing the users to decide whether they want to send the report or not.

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager].crashManager setCrashManagerStatus: BITCrashManagerStatusAutoSend];

[[BITHockeyManager sharedHockeyManager] startManager];

The SDK is not sending the reports right when the crash happens deliberately, because if is not safe to implement such a mechanism while being async-safe (any Objective-C code is NOT async-safe!) and not causing more danger like a deadlock of the device, than helping. We found that users do start the app again because most don't know what happened, and you will get by far most of the reports.

Sending the reports on startup is done asynchronously (non-blocking). This is the only safe way to ensure that the app won't be possibly killed by the iOS watchdog process, because startup could take too long and the app could not react to any user input when network conditions are bad or connectivity might be very slow.

3.6.3 Mach Exception Handling

By default the SDK is using the safe and proven in-process BSD Signals for catching crashes. This option provides an option to enable catching fatal signals via a Mach exception server instead.

We strongly advice NOT to enable Mach exception handler in release versions of your apps!

Warning: The Mach exception handler executes in-process, and will interfere with debuggers when they attempt to suspend all active threads (which will include the Mach exception handler). Mach-based handling should NOT be used when a debugger is attached. The SDK will not enabled catching exceptions if the app is started with the debugger running. If you attach the debugger during runtime, this may cause issues the Mach exception handler is enabled!

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager].crashManager setEnableMachExceptionHandler: YES];

[[BITHockeyManager sharedHockeyManager] startManager];

3.6.4 Attach additional data

The BITHockeyManagerDelegate protocol provides methods to add additional data to a crash report:

  1. UserID: - (NSString *)userIDForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;
  2. UserName: - (NSString *)userNameForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;
  3. UserEmail: - (NSString *)userEmailForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;

The BITCrashManagerDelegate protocol (which is automatically included in BITHockeyManagerDelegate) provides methods to add more crash specific data to a crash report:

  1. Text attachments: -(NSString *)applicationLogForCrashManager:(BITCrashManager *)crashManager

Check the following tutorial for an example on how to add CocoaLumberjack log data: How to Add Application Specific Log Data on iOS or OS X 2. Binary attachments: -(BITHockeyAttachment *)attachmentForCrashManager:(BITCrashManager *)crashManager

Make sure to implement the protocol

@interface YourAppDelegate () <BITHockeyManagerDelegate> {}

@end

and set the delegate:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setDelegate: self];

[[BITHockeyManager sharedHockeyManager] startManager];

3.7 User Metrics

HockeyApp automatically provides you with nice, intelligible, and informative metrics about how your app is used and by whom.

  • Sessions: A new session is tracked by the SDK whenever the containing app is restarted (this refers to a 'cold start', i.e. when the app has not already been in memory prior to being launched) or whenever it becomes active again after having been in the background for 20 seconds or more.
  • Users: The SDK anonymously tracks the users of your app by creating a random UUID that is then securely stored in the iOS keychain. Because this anonymous ID is stored in the keychain it persists across reinstallations.
  • Custom Events: If you are part of Preseason, you can now track Custom Events in your app, understand user actions and see the aggregates on the HockeyApp portal.

Just in case you want to opt-out of the automatic collection of anonymous users and sessions statistics, there is a way to turn this functionality off at any time:

[BITHockeyManager sharedHockeyManager].disableMetricsManager = YES;

3.7.1 Custom Events

By tracking custom events, you can now get insight into how your customers use your app, understand their behavior and answer important business or user experience questions while improving your app.

  • Before starting to track events, ask yourself the questions that you want to get answers to. For instance, you might be interested in business, performance/quality or user experience aspects.
  • Name your events in a meaningful way and keep in mind that you will use these names when searching for events in the HockeyApp web portal. It is your reponsibility to not collect personal information as part of the events tracking.

Objective-C

BITMetricsManager *metricsManager = [BITHockeyManager sharedHockeyManager].metricsManager;

[metricsManager trackEventWithName:eventName]

Swift

let metricsManager = BITHockeyManager.sharedHockeyManager().metricsManager

metricsManager.trackEventWithName(eventName)

Limitations

  • Accepted characters for tracking events are: [a-zA-Z0-9_. -]. If you use other than the accepted characters, your events will not show up in the HockeyApp web portal.
  • There is currently a limit of 300 unique event names per app per week.
  • There is no limit on the number of times an event can happen.

3.8 Feedback

BITFeedbackManager lets your users communicate directly with you via the app and an integrated user interface. It provides a single threaded discussion with a user running your app. This feature is only enabled, if you integrate the actual view controllers into your app.

You should never create your own instance of BITFeedbackManager but use the one provided by the [BITHockeyManager sharedHockeyManager]:

[BITHockeyManager sharedHockeyManager].feedbackManager

Please check the documentation of the BITFeedbackManager class on more information on how to leverage this feature.

3.9 Store Updates

This is the HockeySDK module for handling app updates when having your app released in the App Store.

When an update is detected, this module will show an alert asking the user if he/she wants to update or ignore this version. If update was chosen, it will open the apps page in the app store app.

By default this module is NOT enabled! To enable it use the following code:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setEnableStoreUpdateManager: YES];

[[BITHockeyManager sharedHockeyManager] startManager];

When this module is enabled and NOT running in an App Store build/environment, it won't do any checks!

Please check the documentation of the BITStoreUpdateManager class on more information on how to leverage this feature and know about its limits.

3.10 In-App-Updates (Beta & Enterprise only)

The following options only show some of possibilities to interact and fine-tune the update feature when using Ad-Hoc or Enterprise provisioning profiles. For more please check the full documentation of the BITUpdateManager class in our documentation.

The feature handles version updates, presents update and version information in a App Store like user interface, collects usage information and provides additional authorization options when using Ad-Hoc provisioning profiles.

This module automatically disables itself when running in an App Store build by default!

This feature can be disabled manually as follows:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setDisableUpdateManager: YES]; //disable auto updating

[[BITHockeyManager sharedHockeyManager] startManager];

If you want to see beta analytics, use the beta distribution feature with in-app updates, restrict versions to specific users, or want to know who is actually testing your app, you need to follow the instructions on our guide Authenticating Users on iOS

3.11 Debug information

To check if data is send properly to HockeyApp and also see some additional SDK debug log data in the console, add the following line before startManager:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[BITHockeyManager sharedHockeyManager].logLevel = BITLogLevelDebug;

[[BITHockeyManager sharedHockeyManager] startManager];

4. Documentation

Our documentation can be found on HockeyApp.

5.Troubleshooting

Linker warnings

Make sure that all mentioned frameworks and libraries are linked

iTunes Connect rejection

Make sure none of the following files are copied into your app bundle, check under app target, Build Phases, Copy Bundle Resources or in the .app bundle after building:

  • HockeySDK.framework (except if you build a dynamic framework version of the SDK yourself!)
  • de.bitstadium.HockeySDK-iOS-4.1.0-beta.2.docset

Feature are not working as expected

Enable debug output to the console to see additional information from the SDK initializing the modules, sending and receiving network requests and more by adding the following code before calling startManager:

[BITHockeyManager sharedHockeyManager].logLevel = BITLogLevelDebug;

6. Contributing

We're looking forward to your contributions via pull requests.

Development environment

7. Contributor License

You must sign a Contributor License Agreement before submitting your pull request. To complete the Contributor License Agreement (CLA), you will need to submit a request via the form and then electronically sign the CLA when you receive the email containing the link to the document. You need to sign the CLA only once to cover submission to any Microsoft OSS project.

8. Contact

If you have further questions or are running into trouble that cannot be resolved by any of the steps here, feel free to open a Github issue here, contact us at [email protected] or join our Slack Slack Status

hockeysdk-ios's People

Contributors

0xced avatar alloy avatar ashtom avatar casademora avatar chrismiles avatar derandereandi avatar diederich avatar dtorres avatar felixlam avatar gcox avatar idpaterson avatar ksuther avatar lumaxis avatar m4rr avatar matthiaswenz avatar mlilback avatar navdove avatar nemoeslovo avatar niick avatar philippec avatar pmilanez avatar readmecritic avatar rupert-rr avatar scheinem avatar simx avatar soph avatar steipete avatar tewha avatar tonyarnold avatar yberdnikov avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.