Swiftpack.co -  yusufozgul/YTools as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A few tools for iOS - MacOS apps and Simple Network Manager
.package(url: "https://github.com/yusufozgul/YTools.git", from: "1.1.2")

A few tools for iOS - MacOS apps and Simple Network Manager

UIKit Tools

  • Some Device info
  • Convert Int - Double - Float - Data to String eg: SomeData.stringValue
  • UIImage: averageColor: UIColor? & resizeImage(targetSize: CGSize) -> UIImage
  • UIImageView: setImageColor(color: UIColor)
  • UILabel: calculateMaxLines() -> Int
  • UIView: Auto loadable from xib

Combine Netorking

Flexible, cancellable, error safe

import YNetworkKit

ApiConstant.apiDefault.set(defaultDomain: "https://api.mocki.io")

class Interactor: Networkable {
    var someDataRequests: BaseRequestModel?
    func getSomeData(result: @escaping (Result<TestResponse, Error>) -> Void) {
        someDataRequests = BaseRequestModel(path: "/v1/d0e7928e", method: .GET([]))
        guard let someDataRequests = someDataRequests else { return }
        send(requestData: someDataRequests, modelType: TestResponse.self, result: result)
    func cancel() {


public protocol Networkable {
    func send<T>(requestData: BaseRequestProtocol,
                 modelType: T.Type,
                 decoder: JSONDecoder,
                 urlSession: NetworkProtocol,
                 result: @escaping (Result<T, Error>) -> Void) where T : Decodable

For Tests

When you used MockURLSession, json file from url last path and uses

public class MockURLSession: NetworkProtocol {
    let bundle: Bundle
    /// MockURLSession: Request handle json file content
    /// - Parameter bundle: Your json file bundle
    public init(bundle: Bundle) {
        self.bundle = bundle
    public func dataTaskPublisher(for request: URLRequest) -> URLSession.DataTaskPublisher {
        let stubReply = request.url?.lastPathComponent ?? "stub_error"
        return URLSession.shared.dataTaskPublisher(for: bundle.url(forResource: stubReply, withExtension: "json")!)

// Send Request with mock URLSession
send(requestData: someDataRequests,
             modelType: TestResponse.self,
             urlSession: MockURLSession.init(bundle: Bundle(for: type(of: self))),
             result: result)


Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API