【问题标题】:Swift and objective-c name clash when using core graphics使用核心图形时 Swift 和 Objective-c 名称冲突
【发布时间】:2014-10-21 16:33:30
【问题描述】:

在 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)

只有当我从我的 swift 类中调用 CGPointMake 时才会发生这种情况 swift 类使用在导入核心图形的桥接头中导入的objective-c 类。

我已清除模块缓存和所有派生数据并重新启动只是为了更好地衡量。如果这不是模块缓存中的错误,并且核心图形功能在两个地方定义,我不知道如何解决它,除了“只是不要使用那个 Objective-C 文件”,这就是我同时已经完成了解决它的工作:/

【问题讨论】:

    标签: objective-c swift xcode6.1


    【解决方案1】:

    不要在 Swift 中使用CGPointMake

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

    【讨论】:

    • 谢谢!有时是简单的事情让你大吃一惊!
    猜你喜欢
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 2014-10-03
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多