VCore is a Swift collection containing objects, functions, and extensions that I use for all my projects

Overview

VCore

Table of Contents

Description

VCore is a Swift collection containing objects, functions, and extensions that I use for all my projects

Library supports iOS 13.0 and up.

Library Structure

Project files are grouped as:

  • Views and ViewContollers. Reusable non-scene views and viewcontrollers.

  • Services and Managers. Services, managers, controllers, and formatters. For instance, NetworkClient.

  • Helpers. Non-service, non-extension objects and methods. For instance, helper methods for creating GenericStateModel's and StandardNavigable.

  • Global Functions. Global functions. For instance, TODO and operators.

  • Extensions. Global extensions. Methods and properties are grouped by frameworks of origin—Foundation, UIKit, and SwiftUI.

Project incudes folder Extra, which contains:

  • XCode Templates. Templates that can be used for accelerating workflow. Currently, templates cover scenes and gateways.

  • Misc. Objects and methods that cannot be included in a library as they require additional customization or access to AppDelegate/SceneDelegate.

Architecture

Library includes templates for developing scenes using a VIPER architecture. Architecture is highly-decoupled, follows modular design, obeys the single-responsibility principle, and is built on the interface communication pattern.

To avoid writing boilerplate for every scene, the project includes XCode templates.

Scene Components

Factory

A factory and a dependency injector that creates a scene and injects all related objects.

Factory takes a viewModel as parameter if there is a data passed from the previous scene in the navigation. Factory is a non-initializable struct with static factory methods. By default, Factory includes a single method, that creates a default instance of the scene.

Since objects are communicating using protocols, some can be swapped out with a non-default implementation. For instance, we can place Presenter and ViewController in a shared framework, and implement different Interactor's and Router's in two separate apps, subsequently reusing the same scene while only changing endpoints that they connect to and scenes to which we can navigate to. When even just one scene component is replaced, a new method must be added to Factory, as it requires a different dependency injection.

Interface

While not technically an object, this file lists all protocols that explain communication within the objects.

Interface has five protocols:

Protocol Conformance Owner Ownership
Viewable ViewController Presenter unowned
Navigable Router Presenter unowned
Presentable Presenter ViewController strong
Routable Router Presenter strong
Interactive Interactor Presenter strong

ViewController (Viewable + Navigable)

Definition

View of the scene.

Responsibilities

Responsibilities of the ViewController include:

  • Initializing and storing views
  • Adding them to subviews
  • Setting up a layout
  • Reconfiguring self and subviews

Responsibilities of the ViewController do not include:

  • Storing and managing data, as it's entirely taken by a Presenter
Viewable

Viewable protocol is used by Presenter for configuring and modifying the view during runtime. Some properties and methods used in the protocol may include:

func setContinueButtonState(to isUserInteractionEnabled: Bool)
func setInfoLabelText(to text: String)
Navigable

Navigable protocol is used by Router to perform navigation and presentation of scenes. By default, Navigable protocol conforms to StandardNavigable protocol—a helper protocol used in all scenes. StandardNavigable has a default implementation for UIViewController, and thus, additional implementation is required. API of StandardNavigable is the following:

protocol StandardNavigable {
    func push(_ viewController: UIViewController, animated: Bool)
    func pop(animated: Bool)
    func popToRoot(animated: Bool)
    
    func present(_ viewController: UIViewController, animated: Bool, completion: (() -> Void)?)
    func dismiss(animated: Bool, completion: (() -> Void)?)
    
    func setRoot(to viewController: UIViewController)
}

Presenter (Presentable) (Optional)

Definition

The Central object in the scene that controls the logic and binds everything together.

Responsibilities

Responsibilities of the Presenter include:

  • Connecting all scene components
  • Communicating with Router to trigger navigation towards or presentation of scenes, which in turn communicates with ViewController
  • Communicating with Interactor to fetch data
  • Storing the majority of the present in the scene. This includes viewModel passed from the previous scene.

Responsibilities of the Presenter do not include:

  • Importing UIKit and managing UI-specific data, unless absolutely necessary
Presentable

Presentable protocol is used by ViewController to notify Presenter that an event or an action has occurred. Some properties and methods used in the protocol may include:

func viewDidLoad()
func didTapContinueButton()

Router (Routable) (Optional)

Definition

Navigator of the scene that performs navigation towards and presentation of scenes.

Responsibilities

Router has access to ViewController view Navigable protocol, which allows it to access the navigation stack. By default, Navigable protocol conforms to StandardNavigable protocol.

Routable

Routable protocol is used by Presenter to trigger navigation towards or presentation of scenes. Some methods used in the protocol may include:

func toSomeScene()
func toSomeOtherScene(viewModel: SomeOtherSceneViewModel)

Interactor (Interactive) (Optional)

Definition

Performs fetch request to remote or local databases.

Responsibilities

Responsibilities of the Interactor include:

  • Calling Gateway's for fetch request. That's why an Interactive has a combined protocol body of all the Gateway's it has access to.

Responsibilities of the Interactor do not include:

  • Performing fetch requests on its own independent of a Gateway.
Interactive

Interacive protocol is used by Presenter to perform fetch requests. Some methods used in the protocol may include:

func fetchSomeData(with parameters: SomeParameters) async throws -> SomeEntity

ViewModel (Optional)

Definition

Data passed to the scene from the previous one.

Responsibilities

Owned by Presenter.

Model (Optional)

Definition

A non-initalizable static object that contains information needed for laying out a ViewController.

Responsibilities

Object breaks down into 5 sub-objects—Layout, Colors, Fonts, Animations, and Misc.

Gateway

Protocol that defines a method by which a single fetch request is performed to a relational database—either remote or local.

To avoid writing boilerplate for every gateway, the project includes XCode templates.

Gateway Components

Gatewayable

Defines an interface by which a fetch request can occur. Gateway should only contain a single method.

Parameters

Parameters used for the fetch request. A struct, that can conform to Encodable.

Entity

Entity that's returned from the fetch request. Also a struct, that can conform to Decodable.

_ Gateway

A specific implementation of a gateway. To differentiate the gateways from one another, a prefix is used. For instance, UpdateUserDataNetworkGateway or UpdateUserDataCoreDataGateway.

Interactor-Gateway Relation

Although an Interactor component in VIPER is part of the scene, Gateways are not bound to specific scenes.

This design choice follows CLEAN architecture. But I am not using UseCase's as their responsibility is entirely covered by Interactor's.

Relation between an Interactor and Gateway is the following:

protocol UpdateUserDataGatewayable {
    func fetch(with parameters: UpdateUserDataParameters) async throws -> UpdateUserDataEntity
}

struct UpdateUserDataNetworkGateway: UpdateUserDataGatewayable {
    func fetch(with parameters: UpdateUserDataParameters) async throws -> UpdateUserDataEntity {
        // Implementation
    }
}
protocol HomeInteractive {
    func updateUserData(with parameters: UpdateUserDataParameters) async throws -> UpdateUserDataEntity
}

struct HomeInteractor: HomeInteractive {
    func updateUserData(with parameters: UpdateUserDataParameters) async throws -> UpdateUserDataEntity {
        try await UpdateUserDataNetworkGateway().fetch(with: parameters)
    }
}

Demo

Project contains demo app, that can be used to test functionality of the library.

Installation

Library doesn't support CocoaPods or Carthage.

Swift Package Manager

Add https://github.com/VakhoKontridze/VCore as a Swift Package in Xcode and follow the instructions.

SPM1

Manual

  1. Download VCore.xcframework.

  2. Extract the zip.

  3. Drag VCore.xcframework into your project.

ManualInstallation1

  1. Select "Copy items if needed" and click Finish.

ManualInstallation2

  1. Go to the target settings for your app, under "General" tab, find "Frameworks, Libraries, and Embedded Content". Set the VCore.xcframework to “Embed & Sign”.

ManualInstallation3

Building Your Own Target

Since VCore is open-source, you can clone the project and build the framework target yourself.

Versioning

Major. Major changes, such as big overhauls

Minor. Minor changes, such as new objects, function, and extensions

Patch. Bug fixes and improvements

Contact

e-mail: [email protected]

You might also like...
SwiftUI animation tutorials, all of demos are consisted of youtube videos at website of kavsoft
SwiftUI animation tutorials, all of demos are consisted of youtube videos at website of kavsoft

SwiftUI animation tutorials, all of demos are consisted of youtube videos at website of kavsoft

ChainPageCollectionView  A custom View with two level chained collection views and fancy transition animation
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat “cutting” animations.
SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat “cutting” animations.

SamuraiTransiton is a ViewController transition framework in Swift. It is an animation as if Samurai cut out the screen with a sword. transition types

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.
List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.

CAROUSEL List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center. We speci

A collection of animations for iOS. Simple, just add water animations.
A collection of animations for iOS. Simple, just add water animations.

DCAnimationKit A collection of animations for iOS Simply, just add water! DCAnimationKit is a category on UIView to make animations easy to perform. E

A collection of bugs present in the SwiftUI beta.

Gosh Darn Bugs! GoshDarnBugs is a collection of... you guessed it, bugs. Usage Clone the repository. Open GoshDarnBugs.xcodeproj Click Run. Why? Swift

Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Releases(4.2.1)
  • 4.2.1(Dec 15, 2022)

  • 4.2.0(Oct 29, 2022)

  • 4.1.0(Oct 2, 2022)

    Views

    • SecurableTextField now takes Text as placeholder
    • ProgressViewParameters now causes View to ignore interaction, instead of disabling it

    Models

    • Underlying type _textLineType in TextLineType is no longer public. Instead, it's being replaced by textAlignment and textLineLimitType.

    Architectural Pattern Helpers

    • isInteractionDisabled no longer has a default value in ProgressViewParameters
    Source code(tar.gz)
    Source code(zip)
  • 4.0.1(Sep 15, 2022)

    Services and Managers

    • Issue with Data being empty in NetworkResponseProcessor.response(_:_:) when calling noData(from:) in NetworkClient is fixed
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Sep 14, 2022)

    General

    • Errors are now structs, backed by ErrorCode enumerations
    • VCoreLog(_:) is added that logs errors throws by objects, such as NetworkClient, KeychainService, JSONEncoderService, and JSONDecoderService

    Services and Managers

    • status is added to NetworkReachabilityService
    • KeychainService API is changed from Result types to throwing methods
    • SessionManager is now an actor
    • error(_:) is removed from NetworkErrorProcessor
    • JSONEncoderService and JSONDecoderService now have instance-based APIs

    Views

    • CapsuleUIView and CapsuleUIImageView will now round corners based on width, if width is less than height

    Models

    • ObservableContainer is added
    • AtomicContainer is added
    • AtomicInteger is now an actor
    • AtomicInteger now contains many methods for incrementation and decrementation
    • TextLineType and TextLineLimitType are added
    • horizontalAverage and verticalAverage are added to EdgeInsets
    • horizontal is renamed to horizontalSum in EdgeInsets_LeadingTrailingTopBottom
    • vertical is renamed to verticalSum in EdgeInsets_LeadingTrailingTopBottom

    Architectural Pattern Helpers

    • CoordinatingNavigationStack is added for SwiftUI
    • AlertPresentable is added for SwiftUI
    • ConfirmationDialogPresentable is added for SwiftUI
    • ProgressViewPresentable is added for SwiftUI
    • SwiftUI VIPER documentation and demo is added
    • UITableViewDequeueable is renamed to ConfigurableUITableViewCell
    • ConfigurableUITableViewCell.dequeueID is renamed to ConfigurableUITableViewCell.reuseID
    • UICollectionViewDequeueable is renamed to ConfigurableUICollectionViewCell
    • ConfigurableUICollectionViewCell.dequeueID is renamed to ConfigurableUICollectionViewCell.reuseID

    Extensions

    • NavigationPath.append(contentsOf:) method is added
    • NavigationPath.removeAll() method is added
    • SwiftUIFirstAppearLifecycleManager is removed
    • CALayerCornerCurve parameter is added to UIView.roundCornersAndApplyShadow(cornerRadius:color:radius:offset)
    • View.fitToAspect(_:contentMode) method is added
    • View.shadow(color:radius:offset) method is added

    API

    • keychainServiceErrorDescription(_:) is added to VCoreLocalizationProvider

    XCode Templates

    • Project now includes templates for SwiftUI
    Source code(tar.gz)
    Source code(zip)
  • 3.20.2(Sep 5, 2022)

  • 3.20.1(Aug 24, 2022)

  • 3.20.0(Aug 18, 2022)

  • 3.19.1(Aug 11, 2022)

    Extensions

    • UIDevice.hasNotch is renamed to UIDevice.hasNoPhysicalHomeButton
    • View.onFirstAppear(perform:) is deprecated in favor of View.onFirstAppear(didAppear:perform)
    Source code(tar.gz)
    Source code(zip)
  • 3.19.0(Aug 5, 2022)

    Models

    • BasicAnimation.toCAMediaTimingFunction is added
    • BasicAnimation.toUIViewAnimationOptions is added

    Architectural Pattern Helpers

    • UIActionSheetViewable is added

    Extensions

    • Array.firstIndexAndElement(where:) is expanded to Collection
    • UIView.removeSubviews() is renamed to UIView.removeSubviewsFromSuperview()
    Source code(tar.gz)
    Source code(zip)
  • 3.18.4(Jul 26, 2022)

  • 3.18.3(Jul 26, 2022)

  • 3.18.2(Jul 26, 2022)

    Architectural Pattern Helpers

    • Missing public modifier is added to extension method of pop(count: Int, animated: Bool) in StandardNavigable
    Source code(tar.gz)
    Source code(zip)
  • 3.18.1(Jul 26, 2022)

    Views

    • CapsuleImageView is renamed to CapsuleUIImageView

    Architectural Pattern Helpers

    • Missing public modifier is added to default implementation of pop(count: Int, animated: Bool) method in StandardNavigable
    Source code(tar.gz)
    Source code(zip)
  • 3.18.0(Jul 26, 2022)

    Views

    • CapsuleUIView is added
    • CapsuleUIImageView is added

    Network Client

    • NetworkError is renamed to NetworkClientError

    Architectural Pattern Helpers

    • func pop(count: Int, animated: Bool) is added to StandardNavigable

    Extensions

    • UIStackView.removeArrangedSubviewsFromSuperview() is added
    Source code(tar.gz)
    Source code(zip)
  • 3.17.0(Jul 23, 2022)

    Services and Managers

    • KeychainService is added

    Models

    • KeychainStorage PropertyWrapper is added

    Architectural Pattern Helpers

    • UIAlertParameters now builds actions using resultBuilder
    Source code(tar.gz)
    Source code(zip)
  • 3.16.2(Jul 20, 2022)

    Views

    • keyboardResponsivenessContainerView property is added in KeyboardResponsiveUIViewControllerOffsettingContainerByObscuredSubviewHeight
    • Issue with KeyboardResponsiveUIViewController offset-based animation, not considering pre-offsetted container is fixed
    Source code(tar.gz)
    Source code(zip)
  • 3.16.1(Jul 19, 2022)

    Views

    • Issues with KeyboardResponsiveUIViewController animations are fixed

    Models

    • Double.convertDecimalBytes(to:) is renamed to Double.decimalBytesConverted(to:)
    • Double.convertBinaryBytes(to:) is renamed to Double.binaryBytesConverted(to:)
    Source code(tar.gz)
    Source code(zip)
  • 3.16.0(Jul 15, 2022)

    View

    • KeyboardResponsiveUIViewControllerOffsettingContainerByObscuredSubviewHeight is added that handles keyboard notifications and calls UIView.animateKeyboardResponsivenessByOffsettingContainerByObscuredSubviewHeight

    Models

    • DataUnit protocol is added, alongside with DecimalDataUnit and BinaryDataUnit

    Helpers

    • KeyPath-based UILayoutGuideType case is replaced with closure-based one

    Extensions

    • UIImage.sizeInKilobytes, UIImage.sizeInMegabytes, UIImage.sizeInKibibytes, and UIImage.sizeInMebibytes properties are added

    Other

    • Platform-specific compilation errors are fixed
    Source code(tar.gz)
    Source code(zip)
  • 3.15.2(Jul 14, 2022)

  • 3.15.1(Jul 13, 2022)

  • 3.15.0(Jul 13, 2022)

    Views

    • InnerShadowUIView is added
    • InteractivePoppingUINavigationController is added
    • nonZeroAnimationDuration is added to SystemKeyboardInfo
    • UIView.childFirstResponder and UIView.childFirstResponderView properties are added
    • Default static properties are exposed to public in SystemKeyboardInfo
    • LeftAlignedCollectionViewFlowLayout is renamed to LeftAlignedUICollectionViewFlowLayout
    • CenterAlignedCollectionViewFlowLayout is renamed to CenterAlignedUICollectionViewFlowLayout
    • RightAlignedCollectionViewFlowLayout is renamed to RightAlignedUICollectionViewFlowLayout
    • KeyboardResponsiveViewController is renamed to KeyboardResponsiveUIViewController
    • InfiniteScrollingTableView is renamed to InfiniteScrollingUITableView
    • InfiniteScrollingTableViewDelegate is renamed to InfiniteScrollingUITableViewDelegate
    • InfiniteScrollingCollectionView is renamed to InfiniteScrollingUICollectionView
    • InfiniteScrollingCollectionViewDelegate is renamed to InfiniteScrollingUICollectionViewDelegate
    • ScrollableView is renamed to ScrollableUIView

    Helpers

    • UIView helper NSLayoutConstraint API has been updated

    Extensions

    • Double.rounded(fractions:) and Double.round(fractions:) methods are added
    • String.diacriticInsensitiveString(locale:) method is added
    • UIViewController.isRootViewController and UIViewController.isNonRootViewController properties are added
    • NSLayoutConstraint.init(item:attribute:relatedBy:toItem:attribute:multiplier:constant:priority) initializer is added
    Source code(tar.gz)
    Source code(zip)
  • 3.14.0(Jul 12, 2022)

    Views

    • UIView animation methods are added that support KeyboardResponsiveViewController
    • KeyboardResponsiveViewController.notifiesWhenKeyboardIsAlreadyShownOrHidden is added
    • KeyboardResponsiveViewController.notifiesWhenViewControllerIsNotVisible is added
    • KeyboardResponsiveViewController.keyboardIsShown is exposed to public

    Extensions

    • NSAttributedString.init(attributedStrings:) initializer is added
    Source code(tar.gz)
    Source code(zip)
  • 3.13.2(Jul 11, 2022)

  • 3.13.1(Jul 11, 2022)

  • 3.13.0(Jul 9, 2022)

    Views

    • Several members in SwiftUIBaseButtonState and UIKitBaseButtonState are now marked as public

    Extensions

    • UIView.addSubviews(:_) and UIView.removeSubviews() methods are added
    • Issue with UIStackView.addArrangedSubviews(_:) is fixed
    • UIStackView.addArrangedSubviews(_:) method is added that takes variadic UIViews
    Source code(tar.gz)
    Source code(zip)
  • 3.12.1(Jul 7, 2022)

    Extensions

    • Issue with minimumScaleFactor in UILabel.configure(alignment:lineBreakMode:numberOfLines:minimumScaleFactor:color:font:) is fixed
    Source code(tar.gz)
    Source code(zip)
  • 3.12.0(Jul 7, 2022)

  • 3.11.0(Jul 6, 2022)

    Extensions

    • AppKit extensions are added, but only for supporting underlying SwiftUI types
    • Several UIKit extension are expanded to macOS, and are move to Core Frameworks directory
    • Color.blend(_:ratio1:with:ratio2) method is added
    • Color.lighten(by:) and NSColor.darken(by:) methods are added
    • Color.rgbaValues and NSColor.rgbaComponents properties are added
    • Color.isRGBAEqual(to:) method is added
    • NSColor.blend(_:ratio1:with:ratio2) method is added
    • NSColor.lighten(by:) and NSColor.darken(by:) methods are added
    • NSColor.rgbaValues and NSColor.rgbaComponents properties are added
    • NSColor.isRGBAEqual(to:) method is added
    • NSFont.withBoldStyling and NSColor.withItalicStyling properties are added
    Source code(tar.gz)
    Source code(zip)
  • 3.10.3(Jul 4, 2022)

Owner
Vakhtang Kontridze
Vakhtang Kontridze
BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous loading of images, animation, custom is very high.

BWMCoverView BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous l

Bi Weiming 31 Mar 10, 2021
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

Artur Rymarz 23 Aug 23, 2022
Gravity is a simple Swift Package Manager to add gravity to UI objects easily.

Gravity -- Gravity is a simple Swift Package to add gravity to UI objects easily. -- How to use: Add a new Swift Package from XCode and paste the url

alberto 1 Nov 23, 2021
Simple IOS App About KSA Leaders and Future Projects.

KSA-App Simple IOS App About KSA Leaders and Future Projects. This project made by Swift and SwiftUI. The Project Applies the following: Reusable comp

Ruba Yahya 3 Oct 3, 2022
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
Sample way of integrating animations into a design system for iOS app projects.

Animations in Design System The project presents a sample way of integrating animations into a design system for iOS developers. Project setup A sampl

Bulat Khabirov 1 Nov 26, 2021
Base projects for Devpass' Dev Sprints

Animations Challenge - Finance App ?? In this challenge, you will develop micro-interactions, screen transitions, and reusable animations with best pr

Devpass 3 Oct 10, 2022
Accessbility workshop by hacking with swift. Make every app more usefull for the all the users

Accessibility Accessbility workshop by hacking with swift. Make every app more u

Pavel Surový 0 Dec 26, 2021
This repo contains swift collection of gui, games, menu, animations, music, payment, etc... for iOS, macOS, watchOS and tvOS

Swift-Collections About: This repo contains a collection of projects built using swift and objective-c Contains projects for macOS iOS iPad watchOS tv

Krisna Pranav 6 Nov 15, 2022