Skip to content

Latest commit

 

History

History
141 lines (99 loc) · 3.82 KB

README.md

File metadata and controls

141 lines (99 loc) · 3.82 KB

ShipBook SDK for iOS

Swift Package Manager

Shipbook SDK for iOS applications. Capture logs, errors, and exceptions from your iOS apps and view them in the Shipbook console. Learn more at shipbook.io.

Installation

Add the package URL in Xcode via Swift Package Manager:

https://github.com/ShipBook/ShipBookSDK-iOS.git

Supports iOS 12+ and tvOS 12+.

Quick Start

import ShipBookSDK

// Initialize Shipbook in AppDelegate (do this once at app startup)
func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ShipBook.start(appId: "YOUR_APP_ID", appKey: "YOUR_APP_KEY")
    return true
}

// Get a logger for your class/component
let log = ShipBook.getLogger("MyViewController")

// Log messages at different severity levels
log.v("Detailed trace information")
log.d("Debug information")
log.i("General information")
log.w("Warning message")
log.e("Error message")

Features

  • Remote Logging - View all your app logs in the Shipbook console
  • Error Tracking - Automatically captures uncaught exceptions
  • Session Tracking - Group logs by user session
  • Offline Support - Logs are queued and sent when connectivity is restored
  • Dynamic Configuration - Change log levels remotely without redeploying
  • User Identification - Associate logs with specific users

Configuration

Enable Inner Logging (Debug Mode)

ShipBook.enableInnerLog(enable: true)

Register User

ShipBook.registerUser(userId: "user-123",
                      userName: "johndoe",
                      fullName: "John Doe",
                      email: "john@example.com",
                      phoneNumber: "+1234567890",
                      additionalInfo: ["role": "admin"])

Logout

ShipBook.logout()

Link Sessions with Your Backend

Add the session headers to requests toward your own backend, and the Shipbook console links this app session to the sessions those requests create in your Node.js backend:

var request = URLRequest(url: URL(string: "https://api.your-backend.com/checkout")!)
for (name, value) in ShipBook.getSessionHeaders() {
  request.setValue(value, forHTTPHeaderField: name)
}

It returns an empty dictionary until login completes, so adding it is always safe.

Screen Tracking

ShipBook.screen(name: "HomePage")

Static Log Methods

You can also use static methods without creating a logger instance:

Log.e("Something went wrong")
Log.w("This is a warning")
Log.i("General info")
Log.d("Debug info")
Log.v("Trace info")

Objective-C

The SDK is fully compatible with Objective-C. Convenience macros are provided:

#import <ShipBookSDK/ShipBookSDK-Swift.h>
#import <ShipBookSDK/ShipBook.h>

LogE(@"Something went wrong");
LogW(@"This is a warning");
LogI(@"General info");
LogD(@"Debug info");
LogV(@"Trace info");

Getting Your App ID and Key

  1. Sign up at shipbook.io
  2. Create a new application in the console
  3. Copy your App ID and App Key from the application settings

For full setup instructions, see the iOS documentation.

Links

Author

Elisha Sterngold (ShipBook Ltd.)

License

ShipBook SDK is available under the MIT license. See the LICENSE file for more info.