An XCFramework bundle, or artifact, is a binary package created by Xcode that includes the frameworks and libraries necessary to build for multiple platforms (iOS, macOS, visionOS, tvOS, watchOS, and DriverKit), including Simulator builds. The frameworks can be static or dynamic and also include headers.

Wrote a build script that will generate xcframework with code signing for iOS and macOS including simulator and macOS Catalyst. I wanted to create reusable libraries as frameworks that supports both iOS and macOS and it took some time to get the whole setup to work properly. Tested with Objective-C code only. But Swift should also work.

The generated framework can be added to any Xcode project like usual, from the Frameworks and Libraries section in Xcode. These will show up with blue color instead of yellow.

Frameworks and Libraries

Note that the current build script also includes macOS catalyst and for the build to work, we must have macOS Catalyst added under "Supported Destinations" for the framework under Xcode. Else remove macos_catalyst_props from destinations array.

Supported Destinations

To build for both macOS Intel and ARM, make sure the Architectures section has the below values. This will also build iOS bundle. (This is optional now as I have included sdk flag during build).

Architectures: $(ARCHS_STANDARD)
Base SDK: macOS
Build Active Architectures Only
  Debug: Yes
  Release: No
Supported Platforms: iOS macOS

Base SDK can be Automatic as well.

Build Settings Architectures

The final bundle will have the following slices.

ls Frameworks/OBLogger.xcframework/
Info.plist
_CodeSignature
ios-arm64
ios-arm64_x86_64-maccatalyst
ios-arm64_x86_64-simulator
macos-arm64_x86_64