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:
- For the 3rd party library, I needed to add a
FRAMEWORK
block at the end of itsCMakeLists.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.
- 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 locateextra_lib
when running. - In the Xcode IDE, If I select the app in the
TARGETS
, then click on theGeneral
tab, then scroll down toFrameworks, Libraries, and Embedable Content
. Click on the+
on the lower-left of the section, then addextra_lib.framework/extra_lib
. Finally I would have to, off to the right, under theEmbed
header, I’d need to selectDo Not Embed
This is what got the 3rd party library working when deploying to the iPad
- 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 addingXCODE_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.