iOS applications built with Xcode 6 or higher allow embedding dynamic iOS frameworks within them. I am building a shared framework and would like to embed a sub-framework. How can I accomplish this?
Note: This is possible and is being used in production (for e.g., with Swift frameworks in CocoaPods).
Embedding a Framework in iOS, macOS, watchOS, and tvOS AppsOpen the app's Xcode project or workspace. Go to the app target's General configuration page. Add the framework target to the Embedded Binaries section by clicking the Add icon, highlighted in Figure 5. Do not drag in the framework from Finder.
You can create it on Build Phases tab! Just click in the "+" icon and select "New Copy Files Phase". After that, rename the item created to "Embed Frameworks" and set the "Destination" field to "Frameworks".
Found the answer. Here's how it's done:
Paste the following:
cd $BUILT_PRODUCTS_DIR
mkdir $PROJECT_NAME.framework/Frameworks &>/dev/null
for framework in *.framework; do
if [ $framework != $PROJECT_NAME.framework ]; then
cp -r $framework $PROJECT_NAME.framework/Frameworks/ &>/dev/null
fi
done
@Vatsal Manot's answer was very helpful for me. I modified it a bit and also had a need to sign the copied embedded framework. My script is below.
cd $BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Frameworks/Custom.framework/Frameworks
for framework in *.framework; do
mv $framework $BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Frameworks/
/usr/bin/codesign --force --sign "iPhone Developer" --preserve-metadata=identifier,entitlements --timestamp=none $BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Frameworks/$framework
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With