简体   繁体   English

存档应用程序时找不到Swift Objective-C标头

[英]Swift Objective-C header is not found when archiving the app

I am trying to add Swift class in one objective-c file for which I had to add *-Swift.h file in my objc file. 我正在尝试在一个Objective-C文件中添加Swift类,为此我不得不在我的objc文件中添加* -Swift.h文件。 While the project works fine in debug mode but when I try to archive my app it's throwing error saying that particularly that *-Swift.h file is not found. 虽然该项目在调试模式下可以正常工作,但是当我尝试存档我的应​​用程序时,它抛出错误,特别是未找到* -Swift.h文件。 I tried many solutions but none of them worked. 我尝试了许多解决方案,但没有一个起作用。 Then I got this question on apple website which is exactly the same problem but his solution which was to set precompile prefix header to YES also did not work for me. 然后我在苹果网站上得到了一个完全相同的问题,但是他的解决方案(将预编译前缀标头设置为YES)对我也不起作用。 ( https://forums.developer.apple.com/thread/7512 ). https://forums.developer.apple.com/thread/7512 )。

I do understand that this header is generated in derived data and build process for debug and archive is different but nothing is working in my case. 我确实知道此标头是在派生数据中生成的,用于调试和存档的构建过程有所不同,但在我的情况下没有任何作用。

I have one framework inside which my app target is located. 我的应用程序目标位于其中一个框架。 I am adding the header in my objc as #import "My_Project-Swift.h" 我在我的objc中将标头添加为#import "My_Project-Swift.h"

I am using XCode 10. 我正在使用XCode 10。

Here is what worked for me: 这对我有用:

  1. In Xcode: Product -> Clean (Shift+Cmd+K) 在Xcode中:产品->清理(Shift + Cmd + K)
  2. Delete Derived Data 删除衍生数据
  3. Change Precompiled Prefix Header to YES in the target build settings 在目标构建设置中将“ 预编译的前缀头 更改为“是”
  4. Close Xcode 关闭Xcode
  5. Open Xcode 开启Xcode
  6. Archive 档案

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

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