IOS Static Framework with resources inside
Short answer: you can't.
When you compile the app, the bundle is generated with the resources of the "main" project, ignoring the resources in linked frameworks. This includes images, xib's, plist's, etc. (anything that isn't a source file)
What you need to do is add those resources to your main project so that they are available for use inside your application, not the happiest way around it but it'll work.
How to compile resource files into a custom framework or static library or Mach-O file?
Assuming by "resource files" you mean arbitrary binary files, you can include them into any binary by creating an assembly file (e.g. resources.S
) like so:
.section __RESOURCE,__file1
_symbol_file1:
.incbin "file1.zip"
.no_dead_strip _symbol_file1
.section __WHATEVER,__file2
_symbol_file2:
.incbin "file2.bin"
.no_dead_strip _symbol_file2
// etc, you get the pattern
If you don't have a project in which you can include this file already, then you can turn it into an iOS arm64 framework by itself like so:
mkdir MyResources.framework
xcrun -sdk iphoneos clang -arch arm64 -shared -o MyResources.framework/MyResources resources.S
Why do we have this confusing setup about Static Library and Framework in Xcode
There are many concepts that must be clear
Libraries have two categories based on how they are linked to the executable file
- Static library
.a
,.so
. link at compile time. wiki - Dynamic libraries
.dylib
.dll
etc. link at runtime. only apple can use it for iOS for some safe reason, we cannot build this.
ps, a special kind in apple platform
Text Based .dylib
stubs — .tbd
Framework
Framework is a package that can contain resources such as dynamic libraries, strings, headers, images, storyboards etc.
vs Libraries, Framework has more features
Framework also has static and dynamic
iOS 8 later, we can use a dynamic framework, why Apple releases this. maybe Extension and App share code
this Dynamic Framework for iOS is named embedded frameworks, because when we build the app copy the framework in app bundle.
so the embedded framework is different from system dynamic Frameworks like UIKit.Framework
Why there's no "Dynamic Library" option?
the embedded library is allowed with the Framework
option, but dynamic framework shared in muti app is also not allowed
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
well, Xcode not only support Objective-c and Swift, but also support C, C++ which may use the static library
Related Topics
iOS 9.3:An Ssl Error Has Occurred and a Secure Connection to the Server Cannot Be Made
Making Video from Uiimage Array with Different Transition Animations
Uiviewcontroller Prevent View from Unloading
Text Color Based on Background Image
Swift: Testing Optionals for Nil
Xcode Is Creating Generic Xcode Archive Instead of iOS App Archive
How to Rotate an Uiimageview by 20 Degrees
Nsurlsession "Http Load Failed Kcfstreamerrordomainssl, -9813 ; Self Signing Certificate
How Does One Print All Wkwebview on and Offscreen Content Osx and iOS
Using Custom Fonts in Interface Builder
iOS Provisioning and Certifcates - Will Revoke/Renew Effect App Store Apps
Accessorybuttontappedforrowwithindexpath: Not Getting Called
Can a Standard Accessory View Be in a Different Position Within a Uitableviewcell
Ionic 2, Using Angular 2 Pipe Breaks on iOS-"Can't Find Variable: Intl"
Launch Images in iOS 7 with Xcode 5
Separation Between Header and First Cell -- in Plain Uitableview