Skip to content

Instantly share code, notes, and snippets.

@tareq3
Last active July 12, 2022 12:28
Show Gist options
  • Save tareq3/f384d9db2a0b3f1805753d4b95962004 to your computer and use it in GitHub Desktop.
Save tareq3/f384d9db2a0b3f1805753d4b95962004 to your computer and use it in GitHub Desktop.

Create a xcframework

First create a new project selecting type framework

Step 1:

turn on Build libraries for distribution

Step 2:

Use the following commands from root directory

Here My Framework name is WeavrComponents, replace that with yours

xcodebuild archive \
-workspace WeavrComponents.xcworkspace \
-scheme WeavrComponents \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/WeavrComponents.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES



xcodebuild archive \
-workspace WeavrComponents.xcworkspace \
-scheme WeavrComponents \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/WeavrComponents.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES


If you are supporting mac than add the follwing lines before creating xcframework command on top.

and add

xcodebuild archive \
-workspace WeavrComponents.xcworkspace \
-scheme WeavrComponents \
-configuration Release \
-destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' \
-archivePath './build/WeavrComponents.framework-catalyst.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

If you are not supporting mac

xcodebuild -create-xcframework \
-framework './build/WeavrComponents.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/WeavrComponents.framework' \
-framework './build/WeavrComponents.framework-iphoneos.xcarchive/Products/Library/Frameworks/WeavrComponents.framework' \
-output './build/WeavrComponents-1.0.xcframework'

if you are supporting mac

xcodebuild -create-xcframework \
-framework './build/WeavrComponents.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/WeavrComponents.framework' \
-framework './build/WeavrComponents.framework-iphoneos.xcarchive/Products/Library/Frameworks/WeavrComponents.framework' \
-framework './build/WeavrComponents.framework-catalyst.xcarchive/Products/Library/Frameworks/WeavrComponents.framework' \
-output './build/WeavrComponents.xcframework'

your framework will be build in build directory, before recreating again remove old build directory

Make sure module name and class or file name is not same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment