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

**URL:** https://discourse.cmake.org/t/trouble-trying-to-link-distribute-a-3rd-party-library-as-a-framework-for-ios/5299
**Category:** Code
**Tags:** os:macos, os:ios
**Created:** [March 26, 2022, 2:46am UTC](https://discourse.cmake.org/t/trouble-trying-to-link-distribute-a-3rd-party-library-as-a-framework-for-ios/5299 "2022-03-26T02:46:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![def-pri-pub](https://discourse.cmake.org/user_avatar/discourse.cmake.org/def-pri-pub/32/2299_2.png) [@def-pri-pub](https://discourse.cmake.org/u/def-pri-pub)
#### Post date: [March 26, 2022, 2:46am UTC](https://discourse.cmake.org/t/trouble-trying-to-link-distribute-a-3rd-party-library-as-a-framework-for-ios/5299/1 "2022-03-26T02:46:50Z")

</div>

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`](https://cmake.org/cmake/help/latest/prop_tgt/FRAMEWORK.html) block at the end of its `CMakeLists.txt` file:

```auto
# 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](https://discourse.cmake.org/uploads/default/original/2X/b/beb129253c1b4ec732b425a3cf590bf36ca1406d.png)

**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`](https://cmake.org/cmake/help/v3.23/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.html#prop_tgt:XCODE_EMBED_%3Ctype%3E_CODE_SIGN_ON_COPY) to my main target’s properties. Like so:

```auto
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.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [April 2, 2022, 1:05am UTC](https://discourse.cmake.org/t/trouble-trying-to-link-distribute-a-3rd-party-library-as-a-framework-for-ios/5299/2 "2022-04-02T01:05:02Z")

</div>

> [@def-pri-pub](#):
>
> I’d need to select `Do Not Embed`

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:

> [@def-pri-pub](#):
>
> > 1. …I tried adding [`XCODE_EMBED_FRAMEWORKS`](https://cmake.org/cmake/help/v3.23/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.html#prop_tgt:XCODE_EMBED_%3Ctype%3E_CODE_SIGN_ON_COPY) to my main target’s properties. Like so:
> > 
> > ```cmake
> > 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.

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.

---

<div class="post-metadata">

### Author: ![irov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/irov/32/2552_2.png) [@irov](https://discourse.cmake.org/u/irov)
#### Post date: [June 29, 2022, 5:49pm UTC](https://discourse.cmake.org/t/trouble-trying-to-link-distribute-a-3rd-party-library-as-a-framework-for-ios/5299/3 "2022-06-29T17:49:59Z")

</div>

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

> <https://stackoverflow.com/questions/57687170/do-not-embed-embed-sign-embed-without-signing-what-are-they-what-th>
