Missing module map for CommonCrypto

Number:rdar://33305419 Date Originated:13-Jul-2017 05:40 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 8.3.3 (8E3004b)
Classification:Other Bug Reproducible:Always
This is a duplicate of radar #26276263

It’s currently very difficult to use CommonCrypto in Swift frameworks and scripts. The work-around solution is to define our own module map as outlined in the first suggestion in this dev forum post: https://forums.developer.apple.com/thread/36217

Steps to Reproduce:
1. Create Swift file sample.swift with the lines:
#!/usr/bin/env xcrun swift

import Foundation
import CommonCrypto

extension String {
    func sha1() -> String {
        let data = self.dataUsingEncoding(NSUTF8StringEncoding)!
        var digest = [UInt8](count:Int(CC_SHA1_DIGEST_LENGTH), repeatedValue: 0)
        CC_SHA1(data.bytes, CC_LONG(data.length), &digest)
        let hexBytes = digest.map { String(format: "%02hhx", $0) }
        return hexBytes.joinWithSeparator("")

print("Hello world".sha1())

2. chmod +x sample.swift

3. ./sample.swift

Expected Results:

Actual Results:
./sample.swift:3:8: error: no such module 'CommonCrypto'
import CommonCrypto

Version 8.3.3 (8E3004b)



Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!