Skip to content
View ProjectMagick's full-sized avatar
Block or Report

Block or report ProjectMagick

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
ProjectMagick/README.md

ProjectMagick 🔥

ProjectMagick is a Collection of native Swift Extensions, handy methods and classes.

Requirements

Xcode 13+, iOS 13+, Swift 5.4+

Installation

Swift Package Manager

You can use Swift Package Manager to install ProjectMagick in your Project.

Dependencies

  • Alamofire
  • SDWebImage
  • IQKeyboardManagerSwift
  • FittedSheets
  • CodableWrappers

Some of the Use-case

ProjectSetup.swift
  • Use the applyKeyboardSetup() method to setup keyboard in your AppDelegate or SceneDelegate.
  • Use applyFonts() method to setup fonts in your application. Apply system fonts from Storyboard or XIB in order to work this.
  • AppInfo class will provide basic information like Appname, current envrionment, version etc.
  • Use fetchCountries() method to get list of countries in model form. i.e. AppInfo.fetchCountries()
  • Use fetchCurrentCountryCodeDial() method to get current country code with flag. i.e. AppInfo.fetchCurrentCountryCodeDial()
DeviceDetails.swift
  • This class will provide details about iPhone. Check here for more information.
CustomClasses.swift
  • This class is a collection of Custom UIViews. Like TablePlus and CollectionPlus comes with no data label and some interesting properties and UIRefreshControl. Check here for more information.
  • PaddingLabel is useful class for small labels that require some padding around the edges.
ImagePickerManager.swift
  • ImagePickerManager will handle all the requirements of native image picker manager class. Just assign this class to any UIView, you can also use this class programmatically.
  • To allow multiple selection, change selectionLimit = 0.
  • It comes with default alert messages, you can customize it if you want.
CoreDataStack.swift
  • CoreDataStack is CoreData Utility class. You can perform CRUD operation using this class.
  • You can perform batch operation as well using this class.
  • You can create a fetch request for UIViewController.
  • You can store UIColor and URL directly with the help of CoreDataUIColorTransformer and CoreDataURLTransformer.
  • Check here for more information.
UserDefaults
  • UserDefault is a property wrapper that will help you to store any type of native data types.
  • For example
   extension Preferences {
   
       @UserDefault(key : "AnyKey")
       static var x : Bool?
   
       @UserDefault(key : "AnyKey", defaultValue : false)
       static var y : Bool

       Note:- To store model directly, don't forget to set `isObject = true` in initialization. It will consider class name as key automatically.   
       @UserDefault(isObject : true)
       static var z : AnyModel?
   }
UITextfield.swift
  • ThemeTextfield is a feature reach sub-class of UITextfield.

  • Day to day validations comes out of the box with this class. Most of the basic types are covered in this class.

    • Take Password field type for example
        txtfield.validationFamily = .familyOfPassword([.emptyPassword, .emptyConfirmPassword, .minimumCharacters])
        // Just like that you can add validation checks for this textfield
    
    • Take another example of textfield type Email
        txtfield.validationFamily = .familyOfEmail([.emptyEmail, .validEmail])
        // Just like that you can add validation checks for email.
    
    • Once you set validation family it will automatically set keyboard type for you.
    • isValid Property check for its validation and return message in validationMessage.
  • Also, you can prevent user to do such actions like Cut, Copy, Paste and much more very easily as shown below.

   txtfield.setEditActions(actions: [.paste, .cut])
  • You can also set minimumPasswordLength and minimumPhoneNumberLength.
  • Check here for more information.
TextPickerView.swift
  • TextPickerView is a combination of Date and normal Picker. Just assign a type after initialization and it will work as per type.
  • For String type you need to confirm to datasource and delegate.
SwipeNavigationController.swift
  • SwipeNavigationController is a navigation class that comes with swipe to pop functionality and more.
  • There are some handly methods like setBackButtonImage() and setImageInCenter().
  • There are much more to explore about navigation in the file so Check here for more information.
KeyChainServices.swift
  • KeyChainManager helps you to store data in Keychain.
  • You can perform CRUD operation with given access level.
UICollectionFlowLayouts
  • AlignedCollectionViewFlowLayout can help you with tags like layouts.
  • CenteredCollectionViewFlowLayout behaves like carousel effect with one view at the center of the screen at a time.
  • VerticalOverlappingCollectionViewFlowLayout is as name suggest an overlapping layout, makaing isSticky property true, can mirror wallet app layout.
  • There are more layouts to check, go to CollectionViewFlowLayouts folder to see them all.
  • Checkout class files to see in detail. Also, in the begining of file there is a github link for original source, if you need detail description.
BioMetricManager.swift
  • BioMetricManager is a fairly simple class that will help you to deal with FaceID and TouchID authentication.
Codable.swift
  • This class has some useful initializers and generic methods to handle any model type.
  • We will be using CodableWrappers to handle nullable values and lossy collection types. Check out CodableWrappers for more advance and basic usage.
  • Please note if you are planning to integrate local database, DO NOT USE PROPERTYWRAPPERS.

How to perform network request? Follow below steps.

  • Go to APIManager folder and copy the commented code from Router and SessionManager file and put it in your local project.

  • Make minimum two .xcconfig file for development and live server. Don't forget to set this files in project settings.

  • Also, change the archive setting of your project scheme and set live xcconfig file there.

  • Declare BaseURL variables in both the files and also add BaseURL in info.plist file. Add as many as you want.

  • Make on enum or structure that holds all the Project level variable. From that, get the BaseURL and pass it to the request. Something like this or Copy below code.

    enum EnvironmentVariables {
    
        static var baseURL: URL {
            return try! URL(string: Configuration.value(for: "BaseURL"))!
        }
        
    }
    

Some useful Resources

This will be a collection of some ready to use UI and other things like list of countries in JSON.

  • CollectionViewCells
  • TableViewCells
  • JSON of country list
  • Take advantage of some useful snippets and paste it here in your local computer. You can download it from here
        ~/Library/Developer/Xcode/UserData/CodeSnippets/
    

Popular repositories Loading

  1. ProjectMagick ProjectMagick Public

    Swift 1 1