Xcode 不会自动创建桥接头? [英] Xcode not automatically creating bridging header?

查看:42
本文介绍了Xcode 不会自动创建桥接头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个 Obj-C 文件导入到我的 swift 项目中,Xcode 自动提示我按预期创建桥接头文件.但是,我删除了这两个文件(移至垃圾箱)以进行一些更改,但是当我再次尝试导入 Obj-C 文件时,提示不再出现.是什么原因?我什至在另一个项目中测试了同样的场景,似乎一旦我删除了 Xcode 的自动创建的桥接头,它就不会再次出现提示.这是为什么?

解决方案

您的问题的原因是,Xcode 构建设置仍然包含自动生成的桥接头文件的路径.由于头文件 (ProjectName-Bridging-Header.h) 仍然存在于您的项目目录中,因此您不会收到任何构建错误.

如何解决:

点击您的项目目标,转到构建设置标签(

I imported an Obj-C file into my swift project and Xcode automatically prompted me to create a bridging header file as expected. However, I deleted both the files (moved to trash) to make some changes, but when i try to import the Obj-C file once again, the prompt doesn't come up anymore. What is the reason? I even tested this same scenario in another project, It seems once I delete Xcode's auto created bridging header, It won't bring the prompt up again another time. Why is this?

解决方案

The reason of your issue is, the Xcode build settings still holds the path to auto generated Bridging Header file. You cannot get any build errors because of the header file (ProjectName-Bridging-Header.h) still exist in your project directory.

How to resolve:

Click on your project target, Go to Build Settings tab (choose all instead of basic), search for Bridging Header. You can see the Xcode generated path entry. Select it and click on delete button.

Also, make sure to delete the Xcode auto generated bridging header file (ProjectName-Bridging-Header.h) from your Xcode project directory.

Now, try to import the Obj-C file once again. You can see the prompt to create a bridging header file as expected.

这篇关于Xcode 不会自动创建桥接头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆