/RCProxy

A lightweight inapp http requests logger for your iOS and tvOS apps.

Primary LanguageSwiftMIT LicenseMIT

▶︎ RCProxy

A lightweight inapp HTTP requests logger for your iOS and tvOS apps.

  • Simply log requests in your app with 2 lines of code.
  • Magnified JSON view.
  • cURL sharing.
  • JSON file sharing.
  • Copy a single row on long press.
iPhone 15 Pro Screenshot Apple TV Screenshot

▼ Installation

Use Cocoapods:

pod 'RCProxy'

Use SPM:

  1. In Xcode, go to File -> Add packages...
  2. In the prompt's search bar, copy and paste this URL: https://github.com/RCaroff/RCProxy.git
  3. Select RCProxy an click on Add Package

▼ How to use it

  • import RCProxy
  • When you want to start logging, just write
RCProxy.start()
  • When you want to show the interface, just use
RCProxy.show(in: UIViewController)
  • If you want to present the viewController in a different way, you can simply get the instance with RCProxy.viewController.
  • From SwiftUI view, use RCProxy.view:
@State var showRequests: Bool = false

var body: some View {
    Button {
        showRequests = true
    } label: {
        Text("Show requests")
    }
    .sheet(isPresented: $showRequests) {
        RCProxy.view
    }
}
  • Choose the type of storage you want between .session(), .userDefaults() and .database()
    Be sure to setup this BEFORE calling RCProxy.start().

    Example:
RCProxy.storageType = .database(maxRequestsCount: 50)
RCProxy.start()


Default value is .session(maxRequestsCount: 100).

session(maxRequestsCount: //default: 100): Your requests will be stored in a singleton and will be cleared when app is terminated.

userDefaults(maxRequestsCount: //default: 100): Your requests will be stored in UserDefaults.standard instance, and will persist between sessions but it will allow only a limited amount of data.

.database(maxRequestsCount: //default: 100): Your requests will be stored in a sqlite file on the phone. It uses CoreData behind the hood.

  • RCProxy is listening on URLSession.shared instance by default, but you can also inject your own custom.
    To do so, use the static property urlSession:
let session = URLSession(configuration: URLSessionConfiguration.default)
RCProxy.urlSession = session

Feel free to contribute and / or open issues!