# Wrong apple platform or variant when linking xcframework in 3.28+

**URL:** https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342
**Category:** Usage
**Tags:** gen:xcode, os:ios
**Created:** [March 12, 2024, 2:34am UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342 "2024-03-12T02:34:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mjz48](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mjz48/32/4394_2.png) [@mjz48](https://discourse.cmake.org/u/mjz48)
#### Post date: [March 12, 2024, 2:34am UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342/1 "2024-03-12T02:34:19Z")

</div>

Hi, I’m trying to use the new xcframework support for `find_library` and `target_link_libraries` for apple. I’m trying to build for both ios and ios-simulator, but I’m running into this xcode error with my generated project:

```auto
ld: building for 'iOS-simulator', but linking in object file (/<library path>/google-mobile-ads-sdk-ios/10.14.0/GoogleAppMeasurement.xcframework/ios-arm64/GoogleAppMeasurement.framework/GoogleAppMeasurement[3](apm_experimentation.pb.o)) built for 'iOS'

```

I have the relevant area in my cmake files:

```auto
set(CMAKE_SYSTEM_NAME iOS)

# omitted...

find_library(
        GOOGLE_APP_MEASUREMENT_LIB
        NAMES GoogleAppMeasurement
        PATHS "${THIRDPARTY_DIR}/google-mobile-ads-sdk-ios/${GMA_VERSION}"
        NO_CMAKE_FIND_ROOT_PATH
        REQUIRED
)

target_link_libraries(<my target> PRIVATE "${GOOGLE_APP_MEASUREMENT_LIB}")

```

I have some sort of idea that I need to set some other variable to tell cmake what platform variant I’m using. I have set `CMAKE_SYSTEM_NAME` and I think that is somehow causing the `ios-arm64` target to be selected, but I don’t know which variables I need to set to tell it to use the simulator target. (`ios-arm64_x86_64-simulator` in my case).

I’ve search a whole bunch, but there doesn’t seem to be much documentation, or that I’m not familiar enough with the ecosystem to know which terms to use. (Sorry, I’m new to this…)

Thank you for your attention!

---

<div class="post-metadata">

### Author: ![mjz48](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mjz48/32/4394_2.png) [@mjz48](https://discourse.cmake.org/u/mjz48)
#### Post date: [March 13, 2024, 3:05am UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342/2 "2024-03-13T03:05:10Z")

</div>

Update: I found some relevant conversations in the CMake gitlab.

1. [https://gitlab.kitware.com/cmake/cmake/-/issues/21752#note\_1440301](https://gitlab.kitware.com/cmake/cmake/-/issues/21752#note_1440301)

This looks like this person is having the same exact error. I’m not entirely sure I followed the chain, but it looks like the person’s problem was fixed. I’m using cmake 3.28.3, and looking into the repo, it looks like the relevant PR was included in this version, however, my build is still failing. I even tried setting `CMAKE_XCODE_LINK_BUILD_PHASE_MODE` to `KNOWN_LOCATION`, but there was no difference.

1. [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/8619#note\_1399635](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8619#note_1399635)

This person had a similar error in a slightly newer build, except instead of iOS and iOS-simulator, it’s between ios-arm64\_x86\_64-simulator and maccatalyst. Somehow the user’s issue was resolved, and I again confirmed that the mentioned PR was merged and included in 3.28.3.

The search continues…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 10, 2024, 9:48pm UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342/3 "2024-04-10T21:48:28Z")

</div>

Cc: @brad.king @kyle.edwards

---

<div class="post-metadata">

### Author: ![mjz48](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mjz48/32/4394_2.png) [@mjz48](https://discourse.cmake.org/u/mjz48)
#### Post date: [April 29, 2024, 11:19pm UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342/4 "2024-04-29T23:19:00Z")

</div>

Hello, it’s been a while, but I think I figured out my problem…

So I got my hands on a minimal example where xcframework support /was/ working, and then trying to see what was different from my full-blown build system where it wasn’t.

I got it working yesterday and it turns out there is some duplication in the code and I was linking this library in one place but not linking it in a different target that needed the same library. I think xcode was then defaulting to the iOS target in the library that didn’t get the change for that product and causing this issue.

False alarm, looks like. My apologies that the error was so mundane.
