简体   繁体   中英

Embedding a framework within a framework (iOS 8+)

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 eg, with Swift frameworks in CocoaPods ).

Found the answer. Here's how it's done:

  • Navigate to Target > Build Phases
  • Click the small "+" icon and select "New Run Script Build Phase"
  • 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

要创建包含子框架的Umbrella Framework,您可以按照此处记录的分步指南进行操作: Umbrella框架

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM