Swift Framework

Framework Project

From XCode 6, Framework project is added. Before it, we need to create Framework by ourselves
Compare to static library

Universal Framework

By default, Framework becomes one platform Simulator(i386, x86_64) or Device(arm)
To use both at the same time, we need to merge these platform result

How to


  • Build Simulator
  • Build
  • Add Aggregate target to your project
  • Add run script

Screen Shot 2015-12-07 at 4.58.40 PM

Screen Shot 2015-12-07 at 4.58.34 PM

Release or Debug are not matter

Screen Shot 2015-12-07 at 5.02.17 PM

Screen Shot 2015-12-07 at 5.01.02 PM



# make sure the output directory exists

# 1. Copy the iphone device's framework structure to the universal folder

# 2. Copy the Modules content from simulator's framework to universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/x86_64.swiftmodule" "${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/"

# 3. Create universal binary file using lipo and place the combined executable in the copied framework directory

To run script, your universal-framework is build under your simulator and device framework directory


By default, header is created by XCode.
Open it, and you can find this is like Objective-C.
Yeah, it’s objective-C integration material.
Actually, we can call swift class from Objective-C(need a bit technical)