OC工程中使用Swift静态库 - ShenYj/ShenYj.github.io GitHub Wiki
手动操作探索 Swift 静态库在 OC工程 中使用时
-
要确保以下两点来确立
Module
和头文件的关系-
OTHER_CFLAGS
(other C flag) 指定.modulemap
传递给编译C或者OC的编译器,即clang
-
SWIFT_INCLUDE_PATHS
(build settings - swift compiler - search paths - import path)传递给编译swift的编译器,即swiftc
xcode 在为我们生成 framework 产物时,会将
.modulemap
与.swiftmodule
存放在一个Modules
文件夹下,Modules
与Headers
存在同级目录下-
参考
. └── DashLine.framework ├── DashLine ├── Headers │ ├── DashLine-Swift.h │ └── DashLine.h └── Modules ├── DashLine.swiftmodule └── module.modulemap
而实际在编译时
.modulemap
与.swiftmodule
会与Headers
存在于同级目录下-
模拟实际
. └── DashLine.framework ├── DashLine ├── Headers │ ├── DashLine-Swift.h │ └── DashLine.h ├── DashLine.swiftmodule └── module.modulemap
-