Trouble trying to link/distribute a 3rd party library as a framework for iOS

I’m working on an app right now and I’m using Qt to build it. Android and iOS are the targets of mine. Part of my issue is that I need to use a dynamically linked 3rd party library (that uses CMake) in the app. When building the app for Android, the 3rd party library is linking/distributing perfectly fine for Android, but it’s proving to be much more of a problem for iOS. I did get it to work for iOS, but I had to modify the .xcodeproj that was generated by CMake; but this is something I’d like to avoid

I really need some help figuring out how to tell CMake to automatically set this setting. I’m not sure if this is currently possible in CMake (or not). I’m using CMake 3.22.3 BTW. Let explain the process thus far and where the snag is that I want to fix:

  1. For the 3rd party library, I needed to add a FRAMEWORK block at the end of its CMakeLists.txt file:
# Addition for using -framework on iOS
if (APPLE)
  set_target_properties(extra_lib PROPERTIES
    FRAMEWORK TRUE
    FRAMEWORK_VERSION A
    MACOSX_FRAMEWORK_IDENTIFIER "com.example.extra_lib"
  )
endif()

This was able to get the 3rd party library building as a macOS/iOS Framework. I would link it normally like any other library for my main executable target.

  1. I would now do the CMake configuration step in Qt Creator (for iOS) and have it generate the .xcodeproj that I can use to build program for iOS. It would would build fine, but when trying push to my iPad, it would crash on startup. The log console (in Xcode) said that it couldn’t locate extra_lib when running.
  2. In the Xcode IDE, If I select the app in the TARGETS, then click on the General tab, then scroll down to Frameworks, Libraries, and Embedable Content. Click on the + on the lower-left of the section, then add extra_lib.framework/extra_lib. Finally I would have to, off to the right, under the Embed header, I’d need to select Do Not Embed

Screen_Shot_2022-03-24_at_9.36.14_PM

This is what got the 3rd party library working when deploying to the iPad

  1. The issue here is that I don’t want to have to manually go in and modify the .xcodeproj file to add this framework like so. I tried adding XCODE_EMBED_FRAMEWORKS to my main target’s properties. Like so:
set_target_properties(myapp PROPERTIES
  XCODE_EMBED_FRAMEWORKS extra_lib
)

While this did add the extra_lib.framework/extra_lib to the Frameworks, Libraries, and Embedable Content section, this did not work and breaks building/deploying. Instead of being set to Do Not Embed, it’s being set to Embed and Sign. This doesn’t work I still need to manually go in and change the option.

In my CMakeLists.txt, is there some way I can get this framework to be automatically added with Do Not Embed set? I’ve tried scouring the documentation but I can’t find anything.

1 Like

Why? This seems to be explicitly what you don’t want to do. The error is telling you that the framework couldn’t be found at runtime on the device. You need to embed the third party framework to fix that error. I don’t understand how not embedding it could fix that error. You then go on to state:

Can you provide details about what error you get at build time? This seems like the real problem you need to fix. This is what I’d consider the right way to fix your runtime problem, so understanding how it is breaking your build is what I’d be focusing on here.

I also need setup for Framework “Do Not Embed” How to do it?