Is it possible to include a .framework in a .framework and how?

谁说我不能喝 提交于 2019-12-02 19:14:31

问题


i'd like to mention this question Include a framework into another one, is it possible? and this Include an iOS Framework into another one.

Also there is a similar to the target question from me as well, https://stackoverflow.com/questions/23022211/create-framework-including-plcrashreporter-linked-xcodeproj-source-code-to-the.

I want to achieve the same thing. Don't want the developer to have to link to both frameworks but only mine which is merged with the other.

Both questions in the link have no answer. Any update on the subject?

P.S. I have the source code also but this is not an option since it introduces several problems.

How can I do it, any tutorials, blog, book etc?

Thank you.


回答1:


Yes, it is possible to include a .framework in a .framework. I've never done it, but i know coacoapods does that and older version of parse framework used to include the facebookSDK so you could start researching into how parse did it, by downloading older versions of parse.

This doesn't answer the question so i will delete it when an answer is posted, but at least you have a information you could use to do research to find the answer :D

Here try using this Wenderlich Tutorial to make a static library. From there you can start toying around with the settings. Make sure that any framework you create has the #import statement in the main header file. You know the -Project/Project.h- that is common in most frameworks, in that .h file have all the import statements.




回答2:


I have found the solution creating an aggregate target and adding the following run script in the build phase section.

I will name the static library target name as StaticLibraryName for the example.

xcodebuild -project "StaticLibraryName.xcodeproj" -configuration "Release" -target "StaticLibraryName" -sdk iphoneos
xcodebuild -project "StaticLibraryName.xcodeproj" -configuration "Release" -target "StaticLibraryName" -sdk iphonesimulator

mkdir -p "${SRCROOT}/Products/StaticLibraryName.framework"
mkdir -p "${SRCROOT}/Products/StaticLibraryName.framework/Versions"
mkdir -p "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A"
mkdir -p "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/Resources"
mkdir -p "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/Headers"

ln -s "A" "${SRCROOT}/Products/StaticLibraryName.framework/Versions/Current"
ln -s "Versions/Current/Headers" "${SRCROOT}/Products/StaticLibraryName.framework/Headers"
ln -s "Versions/Current/Resources" "${SRCROOT}/Products/StaticLibraryName.framework/Resources"
ln -s "Versions/Current/StaticLibraryName" "${SRCROOT}/Products/StaticLibraryName.framework/StaticLibraryName"

cp -R "build/Release-iphoneos/usr/local/include/" "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/Headers/"

lipo -create "build/Release-iphoneos/libStaticLibraryName.a" "build/Release-iphonesimulator/libStaticLibraryName.a" -output "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/StaticLibraryName"

libtool -static -o "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/TheOtherFrameworkName" "${SRCROOT}/Products/StaticLibraryName.framework/Versions/A/TheOtherFrameworkName" "${SRCROOT}/Vendor/TheOtherFrameworkName.framework/Versions/A/TheOtherFrameworkName"


来源:https://stackoverflow.com/questions/23113316/is-it-possible-to-include-a-framework-in-a-framework-and-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!