第一次在Swift创建OC文件,或者第一次OC创建Swift时,xcode会提示桥接,Creat Bridging Header即可,这个文件用于Swift调用OC文件,与OC调用Swift无关。
TARGETS ->Build Settings -> Packaging 中 设置Defines Module为YES
#import "TestOcSwitchSwift-Swift.h"
SwiftViewController * tmpVC = [[SwiftViewController alloc]init];
[tmpVC setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:tmpVC animated:YES completion:nil];
在 TestOcSwitchSwift-Bridging-Header.h 中
#import "FirstViewController.h"
//在需要使用的地方直接调用。例如:在这里直接跳转页面
let tmpVC = FirstViewController()
tmpVC.modalPresentationStyle = .fullScreen
present(tmpVC, animated: true, completion: nil)