Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用swift和objective-c桥接头和框架时的命名空间冲突_Ios_Objective C_Swift - Fatal编程技术网

Ios 使用swift和objective-c桥接头和框架时的命名空间冲突

Ios 使用swift和objective-c桥接头和框架时的命名空间冲突,ios,objective-c,swift,Ios,Objective C,Swift,我有一个混合项目,它使用了Objective-C和Swift 使用Cocoapods,我导入了一个框架,其中包含一个名为User的类。但是在我自己的项目中,我还有一个名为User的Objective-C类 在我的Swift文件中,我想使用Objective-CUser类,但也要导入Cocoapod Swift框架 我的User类被导入到桥接头文件中,但我遇到了以下错误: 'User' is ambiguous for type lookup in this context 在这一行代码中: l

我有一个混合项目,它使用了Objective-CSwift

使用Cocoapods,我导入了一个框架,其中包含一个名为
User
的类。但是在我自己的项目中,我还有一个名为
User
的Objective-C类

在我的Swift文件中,我想使用Objective-C
User
类,但也要导入Cocoapod Swift框架

我的
User
类被导入到桥接头文件中,但我遇到了以下错误:

'User' is ambiguous for type lookup in this context
在这一行代码中:

let user = DTKSession.getShared().user as! User
当我搜索这个错误时,我找不到任何与我的情况相关的东西,但我认为这可能与名称空间冲突有关,因为这个问题是在我导入了包含另一个用户类的Swift框架之后开始的

我读到如果我想指定框架类,我可以编写
FrameWorkName.User
,但是我找不到如何在桥接头上指定类


我能做什么?

尝试给
用户
类命名。它看起来是这样的:

// use the class from different frameworks
let user1 = Framework1.User()
let user2 = Framework2.User()

// use the class from the main project
let user4 = User()
let user3 = MyProject.User()    // also works like this, if you want to be explicit. Here MyProject is the product module name
尝试第四个选项

否则最简单的方法就是重命名objective-c
User
class