简体   繁体   中英

# Imported Obj-C class through automatically created Bridging header, Bridging header seems to find it but Swift class won't

  1. I added the files directly to my project from finder to Xcode.
  2. Bridging header was automatically created by Xcode.
  3. #import the Class into the Bridging header - no issues on the Bridging Header.
  4. I try to instantiate Class var into swift class - " use of undeclared type " error shows up.

    • Notes: When I try to COMMAND + click on the #import I get the message "Symbol Not Found".

You need to have your bridging filename set to the "Objective-C Bridging Header" field under the Swift Compiler section in Build Settings for it to be included by the Compiler.在此处输入图片说明

"Symbol Not Found" is just an Xcode bug, I get that but I have no issues using bridged files.

Turns out that file ( A.swift ) that was trying to reference the "other file" ( B.swift ) had " test target membership " selected! So I either had to add the "other file"( B.swift ) to the test target membership or remove file ( A.swift ) from the test target membership. I hope that makes sense and that it is of help to someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM