Swift namespace conflict

跟風遠走 提交于 2019-12-31 00:33:25

问题


Consider:

  • A Swift framework called FrameworkA that defines the type Thing.
  • A Swift framework called FrameworkB that also defines the type Thing and the type FrameworkA.
  • An app that imports both frameworks in the same Swift file.

How do I reference FrameworkA.Thing in said file? The following line fails with Thing is not a member of FrameworkA.

let t : FrameworkA.Thing? = nil

回答1:


This appears to be a Swift bug. As a workaround, you can create a new Swift file in the app that imports only FrameworkA and defines a typealias for Thing:

import FrameworkA

typealias ThingA = Thing

Then in the file that needs to import both frameworks, you use ThingA instead of FrameworkA.Thing.



来源:https://stackoverflow.com/questions/26774101/swift-namespace-conflict

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!