简体   繁体   中英

how to add only swift static lib's binary executable to swift app, in Xcode?

I need to send a swift lib executable to consultants and don't want to reveal source code.

Consultants have their own iOS GUI app, which needs to call my BLE lib.

In C, I'd send only the lib's .a and .h files. How do I do this in swift?

You can compile a Swift static framework - it's the same as static library, but also has .swiftmodule inside of the framework bundle.

Create a framework target in your project, add your swift files to it, then change MACH_O_TYPE build setting to "Static Library", and set BUILD_LIBRARY_FOR_DISTRIBUTION to "Yes".

You can also compile static frameworks for different architectures and then create a static xcframework out of all of them. This will ensure that consultants can run your framework on simulators, devices and even mac catalyst (if you support it).

Make sure to inspect .swiftinterface after the framework is compiled, in order to ensure that there is nothing exposed in it that should not be there (ie some types or methods that were intended to be private).

Beware that static frameworks can not carry any resources inside - only their binary will be used during linking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM