iOS framework 中引用 CommonCrypto.h

先在工程根目录下或是子目录下创建一个文件夹, 在里面放入一个以 modulemap 为后缀的文件, 比如Module.modulemap.

文件内容模板:

module CCommonCrypto [system] {
header  "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTV  OS.sdk/usr/include/CommonCrypto/CommonCrypto.h"
export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/S DKs/  AppleTVSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPho neOS  .sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SD Ks/i  PhoneSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX . sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/Watch OS.   sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

module CCommonCrypto [system] {
    header      "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDK s/Wa  tchSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

上面都是在引入一个头文件, 只是针对的平台不一样.

然后在 Build Setting 中的 import path 设置中将该文件的文件夹路径填上即可. 比如我在某个子目录下新建了一个 iOS 文件夹(路径是./FoundationExtensions/iOS), 然后再在里面放入 Module.modulemap 文件, 文件内容只是引入了 iOS 端的头文件:

module CCommonCrypto [system] {
    header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/CommonCrypto/CommonCrypto.h"
    export *
}

则 import path 中添加一条内容就是: ./FoundationExtensions/iOS.

混合 swift 和 oc 的库如何暴露 oc 头文件: 先在 Build Phases 的 Headers 内将 oc 头文件加入到 public 一栏中, 然后在 framework 对应的头文件中 import 即可. 比如 #import "DataConverter.h"

你可能感兴趣的:(iOS framework 中引用 CommonCrypto.h)