oc和swift混編關鍵

來源:互聯網
上載者:User

標籤:

1.橋接標頭檔——xx-Bridge-Header.h

    swift和oc混編連接點,必不可少。swift工程或oc工程添加oc或swift時,Xcode提醒,建議手動添加。

    注意引入檔案後Xcode的target->build settings自動添加Swift Compiler * 項,Objective-c Bridging Header項填寫此檔案路徑(xx/xx-Bridge-Header.h,xx為工程名)

 

2.隱藏標頭檔——xx-Swift.h

    必不可少。oc試用swift時,Xcode預設建立,橋接標頭檔建立後生效,可在oc檔案中#import "xx-Swift.h"(xx為項目名)

3.用法

    oc使用swift:oc檔案中#import "xx-Swift.h"

    swift使用oc:oc標頭檔寫在xx-Bridge-Header.h中

oc和swift混編關鍵

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.