FlipMock is a extended Flipper plugin that manipulates network response.
- Support Alomofire
- Mock the response by HTTP method.
- Mock the response by query parameters.
- For response, support HTTP code
- Support Moya
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate FlipMock into your Xcode project using CocoaPods, specify it in your Podfile
:
# ...
# Flipper integration
# ...
pod 'FlipperMockPlugin', :git => 'https://github.com/enciyo/FlipMockiOS', :tag => 'v1.0.4'
How to adding Flipper to IOS apps?
import UIKit
import FlipperMockPlugin
import FlipperKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let client = FlipperClient.shared() // from FlipperKit
//...
client?.add(FlipMock.plugin)
//...
client?.start()
return true
}
FM.request("https://httpbin.org/get").response { response in
debugPrint(response)
}
private lazy var session : Session = {
#if DEBUG
return FM //FlipMock
#endif
return AF //Alomofire
}()
func fetch(onSuccess : @escaping (String?) -> Void){
self.session.request("https://httpbin.org/get").response { response in
debugPrint(response)
}
}
private lazy var customMockSession: Session = {
let configuration: URLSessionConfiguration = {
let configuration = URLSessionConfiguration.af.default
//@Warning => [FlipMockUrlProtocol.self] should be first
let safeProtocolClasses = [FlipMockUrlProtocol.self] + (configuration.protocolClasses ?? [])
configuration.protocolClasses = safeProtocolClasses
return configuration}()
return Session(configuration:configuration)}()
FlipMockUrlProtocol should be first
let safeProtocolClasses = [FlipMockUrlProtocol.self] + (configuration.protocolClasses ?? [])
In this section, you can mock response using FlipMock desktop Plugin on the Flipper.