How to Make a Universal Framework in iOS | XCFramework | Swift

Step 1:

Create New Framework from Xcode

Choosing Framework option

Step 2:

Write all your code inside framework

LogFile.swift

Step 3:

Change ‘Build Libraries for Distribution’ to Yes

Step 4:

Navigate to your framework via Terminal

Step: 5

Archiving Framwork

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

Final Step:

Testing our Framework

Drag and Drop Universal Framework

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store