Coder Social home page Coder Social logo

kunalvmore / mknetworkmanager Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 12 KB

MKNetworkManager is a XCframework simplifying network operations for iOS apps. Its NetworkManager class fetches data from URLs, handling errors like invalid URLs or decoding issues.

Objective-C 28.40% Swift 71.60%

mknetworkmanager's Introduction

MKNetworkManager

MKNetworkManager is a Swift framework designed to simplify network operations in iOS applications. It provides a convenient solution for fetching data from remote servers and handling common networking scenarios.

Features

  • Data Fetching: Asynchronously fetch data from URLs.
  • Error Handling: Handle common networking errors such as invalid URLs or decoding failures.
  • Generic Support: Supports generic types to accommodate diverse data models.
  • Simplicity: Provides a concise and intuitive interface for easy integration into projects.

Usage

  1. Import MKNetworkManager into your Swift file:
import KMNetworkManager
  1. Import MKNetworkManager into your Swift file:
let manager = NetworkManager<MyModel>()
manager.fetchData(from: "https://api.example.com/data") { result in
    switch result {
    case .success(let data):
        // Handle successful data retrieval
    case .failure(let error):
        // Handle error
    }
}

MKNetworkManager XCFramework Creation

This guide explains how to create a Universal XCFramework for MKNetworkManager, a simple network manager tool, which can be used across iOS projects. This framework allows for seamless integration and usage within your iOS applications.

Prerequisites

  • Xcode installed on your system.
  • Basic knowledge of using Terminal.

Steps to Create XCFramework

Step 1: Navigate to the Root Folder

Open Terminal and navigate to the root folder of your MKNetworkManager project.

cd path/to/your/project

Step 2: Run Xcodebuild Commands

Option 1: Separate Commands Run the following commands one by one in Terminal:

  1. For iOS Simulator:
xcodebuild archive \
-scheme MKNetworkManager \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/MKNetworkManager.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
  1. For iOS Device:
xcodebuild archive \
-scheme MKNetworkManager \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/MKNetworkManager.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
  1. Create XCFramework:
xcodebuild -create-xcframework \
-framework './build/MKNetworkManager.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/MKNetworkManager.framework' \
-framework './build/MKNetworkManager.framework-iphoneos.xcarchive/Products/Library/Frameworks/MKNetworkManager.framework' \
-output './build/MKNetworkManager.xcframework'

Option 2: Combined Command Alternatively, you can run all commands at once:

xcodebuild archive \
-scheme MKNetworkManager \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/MKNetworkManager.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme MKNetworkManager \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/MKNetworkManager.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild -create-xcframework \
-framework './build/MKNetworkManager.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/MKNetworkManager.framework' \
-framework './build/MKNetworkManager.framework-iphoneos.xcarchive/Products/Library/Frameworks/MKNetworkManager.framework' \
-output './build/MKNetworkManager.xcframework'

Output Files

After running the provided commands, you'll find the following files within the "build" folder in your project directory:

  1. MKNetworkManager.xcframework (as folder)
  2. MKNetworkManager.framework-iphoneos.xcarchive
  3. MKNetworkManager.framework-iphonesimulator.xcarchive

Integration Instructions

To integrate the MKNetworkManager framework into your Xcode project:

  1. Drag and drop the MKNetworkManager.xcframework folder into your Xcode project's file navigator.

  2. Ensure that the framework is properly embedded and signed:

    • Select your project target in Xcode.
    • Go to the "General" tab.
    • Scroll down to the "Frameworks, Libraries, and Embedded Content" section.
    • Make sure the status for MKNetworkManager.xcframework is set to "Embed & Sign".

By following these steps, you'll successfully incorporate the MKNetworkManager framework into your project for seamless usage.

Using Swift Package

Link: MKNetworkManager

https://github.com/kunalvmore/MKNetworkManager-SwiftPackage

Note

If you are creating your own Universal Framework and using the above commands note the below points

  • Replace 'MKNetworkManager' with the actual name of your framework throughout the terminal commands.
  • If you're using a custom framework name, ensure to substitute it wherever 'MKNetworkManager' is mentioned in the terminal commands.
  • This ensures that the commands are tailored to your specific framework, avoiding any potential errors during the XCFramework creation process.

License

MKNetworkManager is available under the MIT license.

mknetworkmanager's People

Contributors

kunalvmore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.