How do I expose a C framework that isn’t in the standard library to a playground in Xcode 7.0b2?
Xcode 7.0 beta 2 (7A121l), current scheme is for a 10.11 target, playground is for OS X.
I want my OS X Swift file-utility struct to use a SHA1 digest to test two files for equality. The service is available through CommonCrypto, an all-C library.
What works in target-member source:
Adding
#import <CommonCrypto/CommonCrypto.h>to the projectname_Bridging-Header.h file makes the CommonCrypto API visible to Swift source in the target. No import statement is needed in Swift.
Common Crypto seems not to be a framework nor is it modularized:
Objective-C headers do not accept
@import CommonCrypto;even after doing a build with the #import (I understand that creates a per-project module). Nor does Swift accept
import CommonCrypto // No such module 'CommonCrypto'Trying a find (in /System/Library or the equivalent 10.11 SDK inside Xcode) turns up nothing:
find /System/Library/Frameworks/ -type f -iname 'CommonCrypto.*'The library browser in the target editor lists `libcommoncrypto.tbd`. TBD? As in “to be determined,” and not available yet? Can’t be. How does El Capitan even work if there’s no library? Maybe that means it’s not available to developers?
What I tried for a playground:
Simply using Common Crypto in a playground gets you unresolved symbols. I have to bridge it in. That suggests I need a bridging header, copied into playground/Sources under either the name of the target’s header or playgroundame_Bridging-Header.h. The symbols are still unresolved.
It’s not limited to auxiliary sources:
Defining the struct in the playground itself (I hate doing that for nontrivial definitions — I’ve been burned by unstable playground editors and long code) yields the same errors.
Plea:
Is there a way to bridge into a C framework? Does it matter that (as I suspect) CoreCrypto does not have a defined module?