使用Swift开发Framework遇到的问题及解决方法

  1. Failed to build module 'xxx'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 effective-4.2 (swiftlang-1300.0.31.1 clang-1300.0.29.1)', while this compiler is 'Apple Swift version 5.5.2 effective-4.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)'). Please select a toolchain which matches the SDK.

在build setting中将BUILD_LIBRARY_FOR_DISTRIBUTION设置为Yes

  1. Include of non-modular header inside framework module
    该问题发生场景为:依赖第三方framework,且项目中只能看到framework,头文件必须在Finder中才能看到。

解决:如果能看到头文件,在build perhaps->Headers中将头文件放到public中。如果看不到,需要在build setting->OTHER_SWIFT_FLAGS中添加-Xcc -Wno-error=non-modular-include-in-framework-module

3.SDK依赖第三方库,在导入SDK后pod对应库后编译出现Undefined symbols
解决:找到对应三方库的TARGETS -> Build Settings -> BUILD_LIBRARY_FOR_DISTRIBUTION 设置为YES

Sandbox: rsync.samba(13741) deny(1) file-write-create

TARGETS -> Build Settings -> ENABLE_USER_SCRIPT_SANDBOXING -> No

5.导入C或者OC的头文件报错

第一种,将header文件在Build Phases -> Headers中设置为Public,然后在xxx.h(如framework叫abc,会有一个abc.h)import。
可能会遇到的错误:
double-quoted include "xxx.h" in framework header, expected angle-bracketed instead
解决:将#import "xxx.h" 改为 #import <framework的名字/xxx.h> ,在c或oc文件中报这个错误也用相同方式解决(include)

第二种,modulemap
暂未遇到问题

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容