Cmake Swift framework with C files - setting target membership and properties

213 Views Asked by At

I am trying to build a framework with a combination of swift and C files and using cmake to generate the XCode Project:

After generating the project using this command:

add_library(MyLibrary STATIC ${FLAT_LIBRARY_FILES})
set_target_properties(MyLibrary PROPERTIES
    FRAMEWORK TRUE
    MACOSX_FRAMEWORK_IDENTIFIER com.MyLibrary.MyLibrary
    # "current version" in semantic format in Mach-O binary file
    VERSION 16.4.0
    # "compatibility version" in semantic format in Mach-O binary file
    SOVERSION 1.0.0
    PUBLIC_HEADER MyLibrary.h
    DEFINES_MODULE YES
    XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")

with command:

cmake -G Xcode -B ./build/sdk/ios ./sdk/ios

but after this project is generated, I still have to do the following to be able to build the library for iOS:

  1. Add iOS as platform
  2. Add swift files to target (C files are added to the target correctly)
  3. Set defines_module to true
  4. Set swift_version
  5. Uncheck test file from target
  6. Make headers public

There have been scant documentation about dealing with this scenario and I have tried various set() commands that I was able to find, to no success. How can I handle this?

0

There are 0 best solutions below