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.
- 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.
- Import MKNetworkManager into your Swift file:
import KMNetworkManager
- 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
}
}
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.
- Xcode installed on your system.
- Basic knowledge of using Terminal.
Open Terminal and navigate to the root folder of your MKNetworkManager project.
cd path/to/your/project
Option 1: Separate Commands Run the following commands one by one in Terminal:
- 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
- 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
- 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'
After running the provided commands, you'll find the following files within the "build" folder in your project directory:
- MKNetworkManager.xcframework (as folder)
- MKNetworkManager.framework-iphoneos.xcarchive
- MKNetworkManager.framework-iphonesimulator.xcarchive
To integrate the MKNetworkManager framework into your Xcode project:
-
Drag and drop the MKNetworkManager.xcframework folder into your Xcode project's file navigator.
-
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.
Link: MKNetworkManager
https://github.com/kunalvmore/MKNetworkManager-SwiftPackage
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.
MKNetworkManager is available under the MIT license.