美文网首页
swift-cocoaframework中module.map配

swift-cocoaframework中module.map配

作者: ksnowlv | 来源:发表于2018-07-04 16:08 被阅读176次

在swift framework中,如果要引用c库,可采用配置module.map.

那如何配置呢?我们以CommonCrypto为例。

一.工程目录下创建CommonCrypto文件夹,并分别创建module.mapYKBaseFramework-C.h
  • 1.module.map
module CommonCrypto [system] {
    //header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h"

    //header "/usr/include/CommonCrypto/CommonCrypto.h"
    header "YKBaseFramework-C.h"
    link "CommonCrypto"
    export *
}

目录如下图,注意目录的相对路径


屏幕快照 2018-07-04 下午2.23.10.png
  • 2.YKBaseFramework-C.h
//  YKBaseFramework-C.h
//  YKBaseFramework
//
//  Created by ksnowlv on 2018/7/4.
//  Copyright © 2018年 ksnowlv. All rights reserved.
//

#ifndef YKBaseFramework_C_h
#define YKBaseFramework_C_h

#include <CommonCrypto/CommonCrypto.h>

#endif /* YKBaseFramework_C_h */
二.设置module.map编译器目录引用路径。

在Build Settings, Swift Compiler – Search Paths 下 Import Paths中设置目录路径即可。

注意与上图目录实际位置一致!!!

屏幕快照 2018-07-04 下午2.25.53.png
三.引用CommonCrypto

注意clean,在swift code直接引入CommonCrypto即可。

import Foundation
import Security
import CommonCrypto

4.其它

  • 1.为什么不采用直接配置绝对路径引用CommonCrypto.h?

    配置为绝对路径,灵活性通用性实在太差,依赖于系统目录。

  • 2.配置CommonCrypto时,注意目录所在路径

相关文章

  • swift-cocoaframework中module.map配

    在swift framework中,如果要引用c库,可采用配置module.map. 那如何配置呢?我们以Comm...

  • 在ios10用module方式引入sqlite3

    新建module.map,放在程序目录某个文件夹下,例如放在本工程的/module/文件夹里. 进入项目Build...

  • 所谓中配日配大战

    相信所有追动漫的小伙伴们都有过这样的时候,就是在看中配动画片时,总有人说:这个配音真烂,比日本差远了。或者说中...

  • 羊太岁语录39

    药瓶:低配、中配、顶配,究竟哪个更好?徒儿甚是纠结。 太岁:直接选顶配肯定没毛病。

  • 我像是什么样的电脑

    我是一台什么配置的电脑?高配、中配、还是低配。大概算是中配吧,运行速度一般,内存也一般。我需要升级、删除...

  • 蓝牙mesh配网(个人理解)

    1.“配网”中的’网‘具体是什么 配网是将未配网设备加入网络,使其成为网络中的节点的过程。 1.1.未配网设备在程...

  • 中内配印象

    驴肉还真不好消化,聚餐回来这么几天了,怎么去写这个中内配,孟州市的龙头企业,心里半点谱也没有。 其实提起中内配,倒...

  • 象棋中的“红与黑”

    象棋中的颜色为什么是黑红配?为什么不是黑白配,或是黄绿配呢?生活的趣味就在于:无疑处设疑! 我观棋盘中...

  • 中风不省人事

    水沟(人中)配中冲、合谷

  • 眼综合4项大开

    低配:双眼皮 中配:双眼皮➕开眼角 高配:双眼皮➕开眼角➕眼险下至 顶配:双眼皮➕开内外眼角➕眼险下至➕卧蚕➕矫正

网友评论

      本文标题:swift-cocoaframework中module.map配

      本文链接:https://www.haomeiwen.com/subject/kkoeuftx.html