So I have xcframework which have fonts file (from react-native-vector-icons).
In test project (testApp), I am importing xcframework and I was expecting it to copy resources from my framework but unfortunately it doesn’t copy these fonts which are there inside the xcframework and I have to manually add it in Copy Bundle Resources.
For end user, I don’t want them to go inside framework and add manually.
In my framework, I have Cops Pods resources in Build Phase but haven’t done anything such which would tell the project consuming this framework to copy these fonts (or resources).
What do I need to do so that in project it copies fonts (or resources) by itself? instead of manually doing it?
2
Answers
You need to register the fonts with the font manager. I did this extending
UIFont
Then, you need use this.
and in your main project (app) register the fonts
If you distribute your xcframework using Cocoapods then you can have any resource file automatically copied in the destination .app bundle by Cocoapods.
In your podspec you define the resources you need to copy and the xcframework (and NO spec.sources):
Or from within the xcframework:
When you execute
pod install
Cocoapods will create a "[CP] Copy Pods Resources" phase that will copy in the destination app whatever you have defined in the resources:To avoid collisions(the user or other pod might copy the same file), better use resource_bundles instead of resources.