I have a an Xcode project which produces a static library. My team plans all new development in Swift. It is not possible to add Swift files to the static library project. We are dropping support for iOS 7, so it is now possible to include frameworks in our iOS app. Therefore, I intend to convert my static library project to a framework project.
I have looked but I cannot find any tools or advice for how to perform this conversion. The static library is large (more than 100 .m files).
I'm hoping for a better answer than create a new parallel framework target. I've attempted this twice. The first time as a swift target, but I wasn't able to easily import all the Objective C files. Next, as an Objective C target, but there is no .pch anymore.
Remove the architectures (using lipo -remove ) that aren't necessary for the device slice of the XCFramework. Remove the architectures (using lipo -remove ) that aren't necessary for the simulator slice of the XCFramework. Combine the two slices into an XCFramework using xcodebuild -create-xcframework .
To include a framework in your Xcode project, choose Project > Add to Project and select the framework directory. Alternatively, you can control-click your project group and choose Add Files > Existing Frameworks from the contextual menu.
A framework target means that your project compiles your code into a library which can then be consumed by other programs. CocoaPods are examples of frameworks. Unless you are building your own frameworks, you should pick "App Target".
An XCFramework can be either static or dynamic and can include headers.
To convert the static/dynamic linked framework from static linked library,
Then for the app that wants to use this framework just need to include the headers as #import and add the framework into "Build Phases\Link Binary With Libraries" of your App Target. If the converted framework is dynamic linked framework, you will need to put it into "Embedded Binaries".
I saw that someone created the framework manually, creating a module.framework file and copying all the header files in a module.framework/Headers folder. This solution seems to work, the project can import correctly the files and see them as a framework correctly.
I'm not sure this is the best way to do it tough, I'm trying it on a big project that ATM is importing the static library through cocoapods, but it seems like I have some problem with the visibility of some of the classes using the framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With