简体   繁体   English

使用核心图形时Swift和Objective-C名称冲突

[英]Swift and objective-c name clash when using core graphics

With Xcode 6.1 I'm suddenly getting this error. 使用Xcode 6.1时,我突然收到此错误。

/...-Bridging-Header.h:5:2: note: in module 'CoreGraphics' imported from /...-Bridging-Header.h:5:
@import CoreGraphics;
 ^

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGeometry.h:271:1: error: definition with same mangled name as another definition CGPointMake(CGFloat x, CGFloat y)

It only occurs when I call CGPointMake from my swift class The swift class is using an objective-c class imported in the bridging header that imports core graphics. 它仅在我从我的swift类调用CGPointMake时发生CGPointMake类使用在导入核心图形的桥接头中导入的Objective-C类。

I've cleared the module cache and all the derived data and restarted just for good measure. 我已经清除了模块缓存和所有派生数据,并重新启动只是出于很好的考虑。 If this isn't an error in the module cache and the core graphics functions are defined in two places i don't know quite how to address it apart from "just don't use that objective-c file" which is what I've done in the mean time to work around it :/ 如果这不是模块缓存中的错误,并且核心图形功能在两个地方定义,那么我不知道该如何解决它,而不仅仅是“只是不使用那个Objective-C文件”已经在平均时间内完成了工作:/

不要在Swift中使用CGPointMake

let point = CGPoint(x: 123, y: 456)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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