我无法在任何地方找到解决方案:
我的应用程序有 Swift 协议(protocol),我需要在旧的 Objective-C 类中实现它。在我创建Objective C类的对象时实现协议(protocol)后,Xcode显示segmentation fault error 11。挖了很多帖子找到了解决方案,但没有成功。
为了说明问题,我在这里创建了一个演示 iOS 项目:
https://github.com/tusharbhatta/SwiftSegmentationFault
UPDATE:
Made a work around to the problem. Check it out on branch 'solved' in the above same repo. :)
但是,如果您知道任何更好的解决方案,请提供帮助。非常感谢
最佳答案
我发现您的代码存在一些问题,请按照以下步骤操作。希望这能解决您的问题。
1)。转到 Build Settings 并搜索“Defines Module”,将其值更改为 YES。
2)。转到“HatchbackCar.h”现在删除“@protocol CarProtocol;”和它的“CarProtocol”。
3)。现在清除项目。
4)。转到“HatchbackCar.m”添加以下代码。
@interface HatchbackCar() <CarProtocol>
@end
5)。现在再次清除项目。
6)。构建项目。
关于ios - 无法在 Objective C 类中使用 Swift 协议(protocol),因为它会导致段错误 : 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42134774/