ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

Swift-framework中objective-c与swift互调

| Comments

swift-framework中objective-c与swift互调实际上与普通工程中的互调类似。

背景:YKDeviceInfo为objective-c的类,KAppInfo为swift类。

1.objective-c调用swift.
  • 引入桥接头文件。
1
#import "YKBaseFrameWork/YKBaseFrameWork-Swift.h"
  • 调用对应swift类的相关方法。
1
2
3
4
5
6
7


  +(NSString *)packageNameX {
       return [KAppInfo packageName];
   }

  

`

2.swift.调用objective-c
1
2
3
4
@objc public class func deviceId() ->String {
        return YKDeviceInfo.deviceId()
    }

3.导出头文件。

1
2
//添加需要导出的头文件,需要在targets->Build Phases->Headers中同时设置。
  #import <YKBaseFrameWork/YKDeviceInfo.h>

image

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory