Manage first-party dependencies with Universal Dynamic Framework without using cocoapods or carthrage
Should be able to setup your first party dependencies (dynamic frameworks) and the updates must reflect without re-integrating the new .framework
repeatedly
cocoapod
, carthage
are great when you have third party or well-defined first party dependencies, without doubt.
But there will be instances when you don't want to create a git repository for a dependency or the dependency just sits in your project and you just want the.framework
file instead of subproject.
- You have a first party framework
- You don't want to create a new dedicated repository for them (so using Carthage / Cocoapods are out of question [Citation Needed])
- You want to keep the Dependencies under your main project directory
- You do not want to add a sub project to your workspace just for a framework
Note : This will still require you to setup things for the first time
One Time Setup
- Open
Dependecy.xcodeproject
- Select Target
- [ ⌘ + ⌥ + i] Command + alt + i.
- Archive > Post-actions > + > New run script action
- Provide build settings from : SELECT YOUR TARGET
- copy and paste this script in the script area.
- Select Target > Build Settings >
Skip Install
- Ensure that it is set to
NO
- While in the
post actions
script - Change the
DESTINATION_ABSOLUTE_PATH
to your main project's root path
- Archive the dependency project
- Close the organizer ( we don’t want to export anything)
- Wait for 1 - 2 sec while a fat
.framework
file is generated and pasted inDESTINATION_ABSOLUTE_PATH
path
- Drag the
Dependency.framework
to main project's embedded binaries section. - Compile and check if everything works in main project.
Every time you make changes in dependency project
- Archive the dependency project
- That's it
This will create a fat file and replace the existing .framework
file in project rood and update the references appropriately.
Apple has started complaining if app contains simulator architectures during distribution.
One solution, if you wish to do it only once. But be careful though as after doing following steps, you will not be able to run app on simulator. Do it just before deploying the app on Testflight/App-store.
Go inside the your MainProjectFramework.framework folder of your project from terminal. Run following commands:
lipo -remove i386 ProjectFramework_SDK -o ProjectFramework_SDK
lipo -remove x86_64 ProjectFramework_SDK -o ProjectFramework_SDK
Please feel free to help improve this document.