【发布时间】:2020-11-10 08:30:41
【问题描述】:
我得到一个未定义的符号:OBJC_CLASS$_Intro 在链接时尝试构建。
我可以使用 Xcode 的智能感知在 Xcode 的 swift 文件中访问类 Intro,但它似乎在构建时无法识别它。对 swift 和 Xcode 有更多经验的人可以帮帮我吗?
class OldLoginViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
NotificationCenter.default.addObserver(self, selector: #selector(OldLoginViewController.goIntro), name: NSNotification.Name("ROOTGOINTRO"), object: nil)
ClsUtil.skip(toViewController: self.navigationController!, viewControllerName: "Intro", isViewDidLoad: true)
}
var style : UIStatusBarStyle = UIStatusBarStyle.default;
@objc
override func viewDidAppear(_ animated: Bool) {
let intro = Intro()
self.navigationController?.pushViewController(intro, animated:false)
}
Obj C 代码:
#import "BaseViewController.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface Intro : BaseViewController
@end
NS_ASSUME_NONNULL_END
桥接头:
#ifndef ObjectiveCBridgingHeader_h
#define ObjectiveCBridgingHeader_h
#import "Base/Util/ClsUtil.h"
#import "Base/ViewController/BaseViewController.h"
#import "Intro/Intro.h"
#endif /* ObjectiveCBridgingHeader_h */
无需涉及介绍的代码即可正常构建并访问 ClsUtil,因此我假设在项目设置中正确设置了桥接头
ps - 原谅菜鸟。 iOS 的第 4 天。之前的开发者离开了,我们没有开发者来处理与 iOS 相关的问题或完成之前的应用程序的移植。我想改用 swift 而不是 obj c,因为它看起来更干净/可以访问最新的工具。
【问题讨论】:
标签: objective-c swift xcode