You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. APIKit
  2. ======
  3. [![Build Status](https://travis-ci.org/ishkawa/APIKit.svg?branch=master)](https://travis-ci.org/ishkawa/APIKit)
  4. [![codecov](https://codecov.io/gh/ishkawa/APIKit/branch/master/graph/badge.svg)](https://codecov.io/gh/ishkawa/APIKit)
  5. [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
  6. [![Version](https://img.shields.io/cocoapods/v/APIKit.svg?style=flat)](http://cocoadocs.org/docsets/APIKit)
  7. [![Platform](https://img.shields.io/cocoapods/p/APIKit.svg?style=flat)](http://cocoadocs.org/docsets/APIKit)
  8. [![Swift Package Manager](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
  9. APIKit is a type-safe networking abstraction layer that associates request type with response type.
  10. ```swift
  11. // SearchRepositoriesRequest conforms to Request protocol.
  12. let request = SearchRepositoriesRequest(query: "swift")
  13. // Session receives an instance of a type that conforms to Request.
  14. Session.send(request) { result in
  15. switch result {
  16. case .success(let response):
  17. // Type of `response` is `[Repository]`,
  18. // which is inferred from `SearchRepositoriesRequest`.
  19. print(response)
  20. case .failure(let error):
  21. self.printError(error)
  22. }
  23. }
  24. ```
  25. ## Requirements
  26. - Swift 5.3 or later
  27. - iOS 9.0 or later
  28. - Mac OS 10.10 or later
  29. - watchOS 2.0 or later
  30. - tvOS 9.0 or later
  31. If you use Swift 2.2 or 2.3, try [APIKit 2.0.5](https://github.com/ishkawa/APIKit/tree/2.0.5).
  32. If you use Swift 4.2 or before, try [APIKit 4.1.0](https://github.com/ishkawa/APIKit/tree/4.1.0).
  33. If you use Swift 5.2 or before, try [APIKit 5.3.0](https://github.com/ishkawa/APIKit/tree/5.3.0).
  34. ## Installation
  35. #### [Carthage](https://github.com/Carthage/Carthage)
  36. - Insert `github "ishkawa/APIKit" ~> 5.0` to your Cartfile.
  37. - Run `carthage update`.
  38. - Link your app with `APIKit.framework` in `Carthage/Build`.
  39. #### [CocoaPods](https://github.com/cocoapods/cocoapods)
  40. - Insert `pod 'APIKit', '~> 5.0'` to your Podfile.
  41. - Run `pod install`.
  42. Note: CocoaPods 1.4.0 is required to install APIKit 5.
  43. ## Documentation
  44. - [Getting started](Documentation/GettingStarted.md)
  45. - [Defining Request Protocol for Web Service](Documentation/DefiningRequestProtocolForWebService.md)
  46. - [Convenience Parameters and Actual Parameters](Documentation/ConvenienceParametersAndActualParameters.md)
  47. ### Advanced Guides
  48. - [Customizing Networking Backend](Documentation/CustomizingNetworkingBackend.md)
  49. ### Migration Guides
  50. - [APIKit 3 Migration Guide](Documentation/APIKit3MigrationGuide.md)
  51. - [APIKit 2 Migration Guide](Documentation/APIKit2MigrationGuide.md)