When you want to create a framework that can run both on the iOS simulator and on device you can resort to using the lipo tool in terminal. You could make a run script phase in Xcode so that at build time the script takes care of running lipo on both architectures and create the universal framework version.
Here I’m just posting my preferred solution. I don’t tend to use Cocoa Pods that much, so I usually pull down the the framework project version of what I want to add to my project. For example, I used this script on the Lottie project once when I needed to link against Lottie for a project I worked on.
So if you have the Xcode project that builds the framework you want to bring into your own project you can follow these steps to get the universal version:
1. build for simulator
2. build for device
3. drop the shell script found on this page in the Products folder
4. run the script [if we were to name the script ‘lipoyo.sh’, at the prompt in the Products folder you can run: sh lipoyo.sh]
That’s it. The script will generate the universal framework right in the Products folder. You can then bring it into your own project and it’ll work on both architectures.
You can find solutions online that will show you how to put the script into the actual Xcode project. I like those solutions, but, for situations where you don’t keep the project around and you need to run this once on a project and then will run it again only when updating the framework by downloading a new project altogether, I find this solution better. I can keep the script around, and always follow the same steps when I need to create a universal framework.
This is the shell script:
framework_name=$(basename $(find ./Debug-iphoneos -type d -name '*.framework' -maxdepth 1) | cut -f 1 -d '.') && \
cp -R Debug-iphoneos/$framework_name.framework ./$framework_name.framework && \
lipo -create -output "$framework_name.framework/$framework_name" \
And this this an example of what the folder structure looks like once the universal framework is ready: