Swiftpack.co - MobileUpLLC/Utils as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MobileUpLLC.
MobileUpLLC/Utils 0.0.45
Utilities for fast, neat and convenient IOS-development
⭐️ 0
🕓 Yesterday
iOS
.package(url: "https://github.com/MobileUpLLC/Utils.git", from: "0.0.45")

Utils

Swift5 Platform iOS License: MIT SPM Compatible Cocoapods Compatible

Utils for iOS development.

Features

Initable

Initialize views/controllers from code/xib/storyboard with one simple interface .initiate()

Controllers example:

// Controller without nib.
class FooController: UIViewController, CodeInitable { }
let foo = FooController.initiate()

// Controller with xib named "FooContoller"
class BarController: UIVewController: XibInitable {
    static var xibName: String { "FooContoller" }
}
let bar = BarController.initiate()

// Controller with storyboard named "BazStoryboard" with id "BazControllerId"
class BazController: UIVewController: StoryboardInitable {
    static var storyboardId: String { "BazControllerId" }
    static var storyboardName: String { "BazStoryboard" }
}
let baz = BazController.initiate()

Initable Example

BundleFileReader

Reading custom object/JSON/Data from Bundle.

Bundle contains foo.json file.

{
    "bar": 100
}

Reading:

struct Foo {
    let bar: Int
}

let foo: Foo = BundleFileReader.readObject("foo")

More about BundleFileReader in action here.

LocalNotificationService

Lightweight tool for managing local notifications. Tools:

  1. Use requestAuthorization to request User's approve for sending notifications
  2. Use getAuthorizationStatus to check current authorization status
  3. Use willPresent to ask the delegate what to do after receiving notification
  4. Use didRecieve to inform delegate about receiving notification

Example:

LocalNotificationService.shared.getAuthorizationStatus { status in
    if status == .authorized { 
        // Do some...
    } else {
        // Do another...
    }
}

LocalNotificationService examle

Extensions

Useful extensions for all code situations

let number = Float.two // 2.0
let closure = Closure.Int // (Int) -> Void
let color = UIColor(hex: "#FFFFFF") // White Color
// and others

Extensions example

MulticastDelegate

MulticastDelegate hepls to manage more than one delegate.

protocol FooDelegate: AnyObject { 
    func bar()
 }

let multicastDelegate = MulticastDelegate<FooDelegate>()

multicastDelegate.add(delegate: object)
multicastDelegate.remove(delegate: object)

multicastDelegate.invokeForEachDelegate { delegate in
    delegate.bar()
}

UIKit.View(Controller) Preview

Live preview for UIKit views/controllers.

class FooView: UIView { ... }

struct FooView_Previews: PreviewProvider {
    static var previews: some View {
        ViewPreview {
            FooView()
        }
    }
}

Button

Base button class with a lots of customization.

Usage from code:

class FooButton: Button { }

Usage from nib:

  1. Set your button class to Button in IB
  2. Set Type = Custom in IB
  3. Set Style = Default in IB

Layout

Simple view layout

let superview = UIView()
let subview = UIView()

superview.layoutSubview(subview, with: LayoutInsets.zero, safe: true)

Requirements

  • Swift 5.0 +
  • iOS 12.0 +

Installation

Utils contain Alamofire 5.6 as external dependencies.

CocoaPods

  1. Make pod init
  2. Add the following to Podfile
pod 'Utils', :git => 'https://github.com/MobileUpLLC/Utils', :tag => '0.0.43', :branch => 'develop'
  1. Make pod install

Manual

Download and drag files from Source folder into your Xcode project.

Swift Package Manager Install

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/MobileUpLLC/Utils", .upToNextMajor(from: "0.0.43"))
]

License

Utils is distributed under the MIT License.

GitHub

link
Stars: 0
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

AsyncServerClient
13 weeks ago

add AsyncServerClient with example

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