[CMake] cmake iOS application + framework link error

David Hirvonen dhirvonen at elucideye.com
Sun Apr 26 00:09:41 EDT 2015


I'm hitting a link error when linking an iOS application with an internally
created framework/library using the the CMake Xcode generator and an iOS
toolchain.  I've put together a minimal CMakeLists.txt example here:

https://github.com/headupinclouds/cmake_framework_test/

The problem is described in detail in the the README, and reproduced here
in the email for completeness.

The repository is intended as a simple unit test to illustrate an apparent
link and build location mismatch when linking a framework to an iOS
application using the "standard" iOS toolchain
<https://code.google.com/p/ios-cmake/> (I realize this toolchain isn't
provided with CMake). I've included the ios toolchain in this repository to
make it easy to reproduce the issue. I've include both the iOS application
that reproduces the link error, and an OS X application, which links to the
library in correct framework location. I'm looking for a CMakeLists.txt fix
or possible workaround. There are two top level convenience bash scripts
for building the applications with cmake using an xcode generator.  The
CMake version is 3.2.1.

cmake --version
cmake version 3.2.1

<https://github.com/headupinclouds/cmake_framework_test/blob/master/README.md#ios-framework-and-application-error>iOS
framework and application error:

bash -fx ./test-ios.sh
+ NAME=_builds/ios
+ cmake -GXcode -H. -B_builds/ios -DCMAKE_TOOLCHAIN_FILE=iOS.cmake

<snip>
clang: error: no such file or directory:
'/Users/dhirvonen/devel/cmake_framework_test/_builds/ios/Debug-iphoneos/TF.framework/Versions/A/TF'
** BUILD FAILED **
The following build commands failed:
    Ld _builds/ios/Debug-iphoneos/testa.app/testa normal armv7
(1 failure)
library path:  _builds/ios/Debug-iphoneos/TF.framework/TF

This produces a flat framework layout (ignoring the FRAMEWORK_VERSION
property (which is fine with me if I can get it to work)). It looks like
this:

tree _builds/ios/Debug-iphoneos/TF.framework
_builds/ios/Debug-iphoneos/TF.framework
├── Info.plist
├── TF
└── _CodeSignature
    └── CodeResources

But when it reaches the link command for the ios application:

target_link_libraries(testa TF)

it fails, since it seems to expect the library to be two directories down
within a versioned framework layout:

TF.framework/Versions/A/TF

instead the directory is here:

TF.framework/TF

I'm looking for a solution to either:

   - correct the TF link path to use the actual (non versioned) framework
   layout that is currently generated, or
   - correct the framework so that it uses the versioned layout to make
   that consistent with the link path

<https://github.com/headupinclouds/cmake_framework_test/blob/master/README.md#os-x-framework-and-application-success>OS
X framework and application success:

When I build this for OS X it seems to work fine.

bash -fx ./test-osx.sh
+ NAME=_builds/osx
+ cmake -GXcode -H. -B_builds/osx
<snip>
** BUILD SUCCEEDED **
library path: _builds/osx/Debug/TF.framework/Versions/A/TF

This produces a framework with the following layout:

tree _builds/osx/Debug/
_builds/osx/Debug/
├── TF.framework
│   ├── Resources -> Versions/Current/Resources
│   ├── TF -> Versions/Current/TF
│   └── Versions
│       ├── A
│       │   ├── Resources
│       │   │   └── Info.plist
│       │   ├── TF
│       │   └── _CodeSignature
│       │       └── CodeResources
│       └── Current -> A
└── testb

and the call to

target_link_libraries(testb TF)

picks up the TF library in the correct location.

I'm curious if there is a variable or property that needs to be set for the
iOS example to give the same framework layout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150426/4ae3d718/attachment.html>


More information about the CMake mailing list