ios 无法为桥接标头发出预编译标头
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45779591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to emit precompiled header for bridging header
提问by Ringo
I downloaded a project from GitHub, then pod the following files, some of which are written by OBJ-C and I used a bridge header.
我从 GitHub 上下载了一个项目,然后 pod 了以下文件,其中一些是由 OBJ-C 编写的,我使用了桥头。
pod ‘SnapKit'
pod ‘MJRefresh'
pod ‘Alamofire'
pod ‘Kingfisher'
pod ‘MBProgressHUD'
pod ‘pop'
pod ‘EVReflection'
pod ‘StreamingKit'
pod ‘iCarousel'
pod ‘ReflectionView'
When I run the project with Xcode 9.0 beta 2, but unfortunately the error log as follows :
当我使用 Xcode 9.0 beta 2 运行项目时,不幸的是错误日志如下:
error: failed to emit precompiled header '/var/folders/kd/4gh0_kxx3jx4thjb_sssmmcw0000gn/T/EvoRadio-Bridging-Header-97bd5f.pch' for bridging header '/Users/ringo/Downloads/EvoRadio-master/EvoRadio/Resources/EvoRadio-Bridging-Header.h'
错误:未能发出预编译头文件 '/var/folders/kd/4gh0_kxx3jx4thjb_sssmmcw0000gn/T/EvoRadio-Bridging-Header-97bd5f.pch' 用于桥接头文件 '/Users/ringo/Downloads/EvoRadio-master/EvoRadio-master/EvoRadio Bridging-Header.h'
I have googled, but no such issue.The error means it needs a PCH file?
This is my .pch
header configuration:
It can't solve it.
我用谷歌搜索过,但没有这样的问题。错误意味着它需要一个 PCH 文件?这是我的.pch
标题配置:
它无法解决它。
How to make it?
如何制作?
采纳答案by D4ttatraya
I also got exact same issue (Xcode9 beta 6) after I added cocoa pods for Encrypted Core Data.
This is my PodFile
:
在为Encrypted Core Data添加可可豆荚后,我也遇到了完全相同的问题(Xcode9 beta 6)。
这是我的PodFile
:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
target 'Root' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Root
target 'RootTests' do
inherit! :search_paths
# Pods for testing
end
target 'RootUITests' do
inherit! :search_paths
# Pods for testing
end
end
Solution:
1 I added $(inherited) non-recursive
to Search Path -> Header Search Paths
2 Then added ${PODS_ROOT} recursive
to Search Path -> User Header Search Paths
Both the above in my projects' target build settings.
解决方案:
1 我添加$(inherited) non-recursive
到Search Path -> Header Search Paths
2 然后
在我的项目的目标构建设置中添加${PODS_ROOT} recursive
到Search Path -> User Header Search Paths
上述两个。
Please have a look at these SO answers:
1 Inherit Header Search Paths
2 Inherit User Search Paths
请看看这些 SO 答案:
1 Inherit Header Search Paths
2 Inherit User Search Paths
回答by Hari Karam Singh
Note this can also happen if your bridging header imports Objective-C code that itself imports your app's Swift modulevia myproject-Swift.h
. The solution is to use forward declarations for your Swift types and import the project Swift module in the .m
file.
请注意,如果您的桥接头导入 Objective-C 代码,而该代码本身通过myproject-Swift.h
. 解决方案是对 Swift 类型使用前向声明,并在.m
文件中导入项目 Swift 模块。
@class MySwiftClass
or...
@class MySwiftClass
或者...
typedef NS_ENUM(NSInteger, MySwiftEnumType)
typedef NS_ENUM(NSInteger, MySwiftEnumType)
MySwiftEnumType
is the lowest level name even for classes. So Swift enum MyClass.MySwiftEnumType
becomes just MySwiftEnumType
MySwiftEnumType
即使对于类,也是最低级别的名称。所以 Swift 枚举MyClass.MySwiftEnumType
就变成了MySwiftEnumType
回答by BAP
Make sure you're opening the proper project workspace, otherwise, the Podfile
may not have all the resources it needs to compile.
确保您打开了正确的项目工作区,否则,它Podfile
可能没有编译所需的所有资源。
I saw this same error on a project that had been working fine previously.
我在一个之前运行良好的项目中看到了同样的错误。
I discovered that I had accidentally opened the ProjectName.xcodeproj
file rather than the ProjectName.xcworkspace
file. Opened the xcworkspace
file and presto, project was working again!
我发现我不小心打开了ProjectName.xcodeproj
文件而不是ProjectName.xcworkspace
文件。打开xcworkspace
文件并快速,项目又开始工作了!
回答by Aliens
For me, this problem occurred when I added new build configuration and scheme to the existing project.
对我来说,这个问题发生在我向现有项目添加新的构建配置和方案时。
The solution was to run pod install
on newly created scheme. After that, project was built successfully.
解决方案是pod install
在新创建的方案上运行。之后,项目就搭建成功了。
回答by paras gupta
I have tried all of the above steps mentioned in the answers but nothing worked for me, the problem was basically with the deployment target version for the project and in the podfile.
我已经尝试了答案中提到的所有上述步骤,但没有任何效果对我有用,问题基本上出在项目和 podfile 中的部署目标版本上。
In my project deployment target was 10.0 while in my podfile it was 11.0.
在我的项目部署目标中是 10.0,而在我的 podfile 中它是 11.0。
回答by Okan
You can try this solution. I have solved the same problem by this way.
你可以试试这个解决方案。我已经通过这种方式解决了同样的问题。
Product > Scheme > Edit Scheme > Select "Build" on Left Menu > Find implicit dependencies
产品 > 方案 > 编辑方案 > 在左侧菜单上选择“构建”> 查找隐式依赖项
Under the build tab, check 'Find implicit dependencies':
在构建选项卡下,选中“查找隐式依赖项”:
Then make a clean and build again.
然后进行清理并再次构建。
回答by Genki
For my case I had a typo in folder name "Supporing FIles" instead of "Supporting Files".
对于我的情况,我在文件夹名称“支持文件”而不是“支持文件”中有一个错字。
回答by Benzi Heler
In my case I had the same compiler error with additional errors like "Unknown type" in one of my project files, So I just added this to the problematic file, and it solved it instantly.
在我的情况下,我的一个项目文件中出现了相同的编译器错误和其他错误,例如“未知类型”,所以我只是将其添加到有问题的文件中,它立即解决了它。
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
回答by Randoramma
My experience with this is that Xcode is unable to find header files for pods/frameworks imported in the project.
我的经验是 Xcode 无法找到项目中导入的 pods/frameworks 的头文件。
My Project experience with this:
Updating Xcode9.2 - 9.3 where many cocoapods had to be updated due to implicit definitions now unavailable or being outdated.
I had changed the Podfile to now include 'use_frameworks!'. Following this and after dealing with other compile issues I found the error you are experiencing. I believe adding 'use_frameworks! was preventing some pods with support prior to iOS 8 from compiling correctly. Steps I took to correct this issue:
我的项目经验:更新 Xcode9.2 - 9.3,由于隐式定义现在不可用或已过时,因此必须更新许多 cocoapods。
我已将 Podfile 更改为现在包含“use_frameworks!”。在处理完其他编译问题之后,我发现了您遇到的错误。我相信添加'use_frameworks!阻止了一些在 iOS 8 之前支持的 pod 无法正确编译。我采取的纠正这个问题的步骤:
- I tried deleting the Pods/ directory using cocoa
pod deintegrate
- I then open project with Xcode and cleaned the build folder and the project. (delete content within derived data folder)
I then
pod install
again but the issue persisted.Ultimately I removed the use_frameworks line in Podfile and then repeated steps 1-3 and the project was now able to find the missing header files and the issue never presented it self again.
- 我尝试使用可可删除 Pods/ 目录
pod deintegrate
- 然后我用 Xcode 打开项目并清理构建文件夹和项目。(删除派生数据文件夹中的内容)
然后我
pod install
再次,但问题仍然存在。最终,我删除了 Podfile 中的 use_frameworks 行,然后重复步骤 1-3,项目现在能够找到丢失的头文件,并且问题再也没有出现过。
回答by Zack Shapiro
Deleting Podfile.lock
and re-running pod install
fixed this for me.
删除Podfile.lock
并重新运行pod install
为我解决了这个问题。