Latest 2.2.2
Homepage https://github.com/congncif/IDMFoundation
License MIT
Platforms ios 8.0
Frameworks UIKit, Photos, MobileCoreServices, AVFoundation
Authors

CI Status
Version
License
Platform

Summary

IDMFoundation is a collection of what is needed to create a popular ios application that uses web services.

As part of the base project, IDMFoundation includes the foundation classes built into the IDMVC architecture (read more here https://github.com/congncif/IDMCore) and a standard error handling and loading mechanism. IDMFoundation is divided into several sub-specs, which means that it is designed quite flexibly, you can choose which really needed sub-spec to install for your project to not become redundant.

Components

  • Core: includes base classes of Data Provider.

    • ConvertProvider, ForwardProvider or BridgeResponseProvider are support providers. They help to create a sequence provider by connecting some providers together.

    To install it, simply add the following line to your Podfile:

    pod 'IDMFoundation/Core'
  • Alamofire: Use Alamofire to request data.

    • BaseDataProvider handles data request.
    • BaseUploadProvider handles upload request.
    • BaseDownloadProvider handles download request.

    To install it, simply add the following line to your Podfile:

    pod 'IDMFoundation/Alamofire'
  • Parameter:Encode request parameters for Data Provider:

To install it, simply add the following line to your Podfile:

  pod 'IDMFoundation/RequestParameter'
  • Data Mapping: Most of apps use JSON API, so ObjectMapper is an integral part. We built some base models to parse JSON data to custom object which is more useful for real projects.

    To install it, simply add the following line to your Podfile:

    pod 'IDMFoundation/ObjectMapper'
  • Loading: includes methods to handle loading, loading progress and presenting error. These methods are added to UIView and UIViewController by default. This help us use easily.

There are two sub-specs for Loading, you can choose one of them for your project:

pod 'IDMFoundation/JGProgressHUD'

or

pod 'IDMFoundation/MBProgressHUD'
  • Some other sub-specs you can look into:
    • pod 'IDMFoundation/Reachability'
    • pod 'IDMFoundation/CameraAsset'

Requirements

Xcode 9.3+

Swift 4.1+

[Bonus] Template

IDMFoundation provides a template to help quicly create a data flow which follows IDMCore.

To install template, clone this repo then go to the project directory, run command ./install-template.sh.

Once that’s done, when you create a new file, you’ll see IDMFoundation template appears.

alt text

Create one with name of flow GetData, all of necessary classes will be created.

import Foundation
import IDMCore
import IDMFoundation
import Alamofire

class GetDataRequestParameter: RequestParameter {

}

class GetDataResponseModel: DataResponseModel<<#GetDataModel#>>, ModelProtocol {

}

typealias GetDataBaseProvider = RootAnyProvider<GetDataRequestParameter>
typealias GetDataProvider = BaseDataProvider<GetDataRequestParameter>

class GetDataDataProvider: GetDataProvider {
    override func requestPath(parameters: GetDataRequestParameter?) -> String {
        return <#code#>
    }

    override func httpMethod(parameters: GetDataRequestParameter?) -> HTTPMethod {
        return <#.post#>
    }
}

class GetDataService: MagicalIntegrator<GetDataBaseProvider, GetDataResponseModel> {

}

extension GetDataService {
    convenience init() {
        self.init(dataProvider: GetDataDataProvider())
    }
}

Enter your configurations then you have been finished a new flow completely.

Use easily in view controller or wherever you need a service to get data:

fileprivate let getDataService = GetDataService()

[...]

getDataService
            .prepareCall(parameters: param)
            .loading(monitor: self)
            .error(handler: self)
            .onSuccess { responseModel in
                print(responseModel)
            }
            .call()

Happy coding!

Author

congncif, [email protected]

License

IDMFoundation is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "IDMFoundation",
    "version": "2.2.2",
    "summary": "Base classes for new project which follows IDMCore",
    "swift_version": "4.2",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2"
    },
    "description": "To install IDM Xcode Template: clone this repo run install-template.sh",
    "homepage": "https://github.com/congncif/IDMFoundation",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "congncif": "[email protected]"
    },
    "source": {
        "git": "https://github.com/congncif/IDMFoundation.git",
        "tag": "2.2.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "frameworks": [
        "UIKit",
        "Photos",
        "MobileCoreServices",
        "AVFoundation"
    ],
    "default_subspecs": "Default",
    "subspecs": [
        {
            "name": "Default",
            "dependencies": {
                "IDMFoundation/Core": [],
                "IDMFoundation/Networking": [],
                "IDMFoundation/Alamofire": [],
                "IDMFoundation/CameraAsset": [],
                "IDMFoundation/ObjectMapper": [],
                "IDMFoundation/MBProgressHUD": [],
                "IDMFoundation/ModuleHelper": []
            }
        },
        {
            "name": "Core",
            "source_files": "IDMFoundation/Core/**/*",
            "dependencies": {
                "SiFUtilities": [],
                "IDMCore": []
            }
        },
        {
            "name": "Alamofire",
            "source_files": "IDMFoundation/Alamofire/**/*",
            "dependencies": {
                "IDMFoundation/Networking": [],
                "SiFUtilities": [],
                "IDMCore": [],
                "Alamofire": []
            }
        },
        {
            "name": "Networking",
            "source_files": "IDMFoundation/Networking/**/*",
            "dependencies": {
                "IDMFoundation/Core": [],
                "SiFUtilities": [],
                "IDMCore": []
            }
        },
        {
            "name": "ObjectMapper",
            "source_files": [
                "IDMFoundation/Response/Shared/*.swift",
                "IDMFoundation/Response/ObjectMapper/*.swift"
            ],
            "dependencies": {
                "IDMFoundation/Core": [],
                "IDMCore": [],
                "ObjectMapper": []
            }
        },
        {
            "name": "Codable",
            "source_files": [
                "IDMFoundation/Response/Shared/*.swift",
                "IDMFoundation/Response/Codable/*.swift"
            ],
            "dependencies": {
                "IDMFoundation/Core": [],
                "IDMCore": []
            }
        },
        {
            "name": "MBProgressHUD",
            "source_files": [
                "IDMFoundation/MBProgressHUD/*.swift",
                "IDMFoundation/ErrorHandling/*.swift"
            ],
            "dependencies": {
                "SiFUtilities": [],
                "IDMCore": [],
                "MBProgressHUD": []
            }
        },
        {
            "name": "JGProgressHUD",
            "source_files": [
                "IDMFoundation/JGProgressHUD/*.swift",
                "IDMFoundation/ErrorHandling/*.swift"
            ],
            "dependencies": {
                "JGProgressHUD": [],
                "SiFUtilities": [],
                "IDMCore": []
            }
        },
        {
            "name": "Reachability",
            "source_files": "IDMFoundation/Reachability/**/*",
            "dependencies": {
                "CWStatusBarNotification": [],
                "Reachability": [],
                "SiFUtilities": []
            }
        },
        {
            "name": "CameraAsset",
            "source_files": "IDMFoundation/CameraAsset/**/*",
            "dependencies": {
                "IDMFoundation/Networking": [],
                "SiFUtilities": []
            }
        },
        {
            "name": "ModuleHelper",
            "source_files": "IDMFoundation/ModuleHelper/**/*",
            "dependencies": {
                "ViewStateCore": [],
                "IDMCore": []
            }
        }
    ]
}

Pin It on Pinterest

Share This