swift混编oc碰到的问题

在swift中混编苹果官方的Reachability OC文件。

因为swift工程的target是生成framework而非app,framework中调用oc与app中使用桥接文件还不一样,参考:

http://blog.csdn.net/cooldragon/article/details/50172649

 

主要步骤为:

1.将Reachablity.m 和.h文件加入到工程中

2.在ESPlus.h 中最后加上 (ESPlus为Framework名称)

#import <ESPlus/Reachability.h>

然后编译可能会出现错误: Include of non-modular header inside framework module 'ESPlus',则进入3

3.进入Build Phases,Headers中,把OC头文件Reachability.h从Project中拖到Public中

编译OK.

 

第2步中,因为手打的文件名少了一个字母(写成Reachablity.h),出现了#import   ‘ .h' file not found 错误,网上搜说是什么路径错误,

其实还是自己路径写错了,保险的方法是选中Reachability.h,看做xcode右侧边栏 查看文件信息,复制文件的相对路径过去。

posted @ 2016-09-04 21:30  mlj318  阅读(614)  评论(0编辑  收藏  举报