Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static library built against iOS 8 SDK links with Metal framework

Tags:

xcode

ios

When building a static library I write with iOS 8 SDK, the resulting library links with the metal framework:

$ otool -arch all -fl <static library>

...
Load command 12
 519      cmd LC_LINKER_OPTION
 520  cmdsize 32
 521    count 2
 522   string #1 -framework
 523   string #2 Metal
...

I think this is through UIKit; I don't link against it directly and 'Link with standard libraries' is NO. This causes problems on Xcode 5.1.1 with iOS 7 as this framework doesn't exist. Building the static lib with Xcode 5 does not link with metal, but I'd rather build with the latest production release of Xcode, and at some point I'll have to tackle this problem. How can I build with Xcode 6 and work around this issue for Xcode 5 users?

See also another developer with this issue, he simply used the specific frameworks he required which didn't link with Metal, but I can't do that as I need to link with UIKit: https://github.com/card-io/card.io-iOS-SDK/issues/66 https://github.com/CocoaPods/CocoaPods/issues/2457

like image 958
Nick Avatar asked Sep 16 '14 05:09

Nick


1 Answers

Dave from card.io here. I.e., the "another developer" referenced above.

Our solution, which should work for you, was to set to NO two build settings when building our static library: CLANG_ENABLE_MODULES and CLANG_MODULES_AUTOLINK (a.k.a Enable Modules (C and Objective-C) and Link Frameworks Automatically).

Building your library with these module settings disabled will eliminate the LC_LINKER_OPTION commands altogether.

The app that uses your library can either enable those modules settings or not. It's the app (and not your library) that must include UIKit.framework etc., either automatically via modules or manually as a "linked library".

like image 192
Dave Goldman Avatar answered Oct 12 '22 23:10

Dave Goldman