[CMake] cmake iOS application + framework link error
David Hirvonen
dhirvonen at elucideye.com
Mon May 4 14:12:02 EDT 2015
Thanks for the response. I've moved to a more standard *nix layout for all
platforms, and will rely on a post-build step to create my framework (for
now). If I find a fix, I'll be sure to share it here.
On Wed, Apr 29, 2015 at 5:22 AM, Eric Wing <ewmailing at gmail.com> wrote:
> On 4/25/15, David Hirvonen <dhirvonen at elucideye.com> wrote:
> > 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.
> >
>
>
> I have not tried this (yet), but my guess is that CMake needs to be
> patched to understand iOS frameworks. iOS frameworks are new as of iOS
> 8. 3rd parties were not allowed to make frameworks before that.
> Additionally, CMake's framework support was implemented for Mac like a
> decade ago. Because the iOS framework structure (and .app structure
> for another matter) is different, CMake will likely need to be taught
> how to make a proper structure for iOS.
>
> If you do any work on this, I am interested in your results.
> Eventually, I would like to support iOS frameworks, though I'm
> probably at least 6 months from that since I need iOS 7 to drop off
> the face of the earth, which means after iOS 9 is released.
>
> (Note to non-iOS developers reading this: iOS does not allow flat
> .dylib files for shared libraries. You must build a framework.)
>
> -Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150504/2f0e1319/attachment.html>
More information about the CMake
mailing list