ios Xcode 9 - 无法发出预编译头文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46293028/
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
Xcode 9 - failed to emit precompiled header
提问by Shubham
I have a project in Objective-C as well as in swift by taking MyProjectName-Bridging-Header.h
and i also configured the Objective-C Bridging Header.
Also i have added 'MyprojectName-Swift.h' in .pch file.
我在 Objective-C 和 swift 中都有一个项目,MyProjectName-Bridging-Header.h
我还配置了 Objective-C 桥接头。我还在 .pch 文件中添加了“MyprojectName-Swift.h”。
This works fine on xcode 8.2 but when i build my project from xcode 9 i am getting the below error.
这在 xcode 8.2 上工作正常,但是当我从 xcode 9 构建我的项目时,我收到以下错误。
failed to emit precompiled header '/Library/Developer/Xcode/DerivedData/MyprojectName-lajanjvhqjnfjksdsndsfkads/Build/Intermediates.noindex/PrecompiledHeaders/MyprojectName-Bridging-Header-swift_44AHJm3Z96qu-clang_2BIMGQVXGEZ09.pch' for bridging header '/Documents/MyProjectLocaiton/FoneApp-Bridging-Header.h'
未能发出预编译的头文件 '/Library/Developer/Xcode/DerivedData/MyprojectName-lajanjvhqjnfjksdsndsfkads/Build/Intermediates.noindex/PrecompiledHeaders/MyprojectName-Bridging-Header-swift_44AHJm3Z96qu-clang_2BIMGQVXpingsfkads/MyprojectName-lajanjvhqjnfjksdsndsfkads/Build/Intermediates.noindex/PrecompiledHeaders/MyprojectName-Bridging-Header-swift_44AHJm3Z96qu-clang_2BIMG9.VXpgings/MyProjectName-lajanjvhqjnfjksdsndsfkads/ Bridging-Header.h'
Please help me out from this. Thanks!
请帮我解决这个问题。谢谢!
采纳答案by Shubham
Finally i got the solution of this issue.
In my project the Prefix Header
path is not clearly defined. Earlier the path was
最后我得到了这个问题的解决方案。在我的项目中,Prefix Header
路径没有明确定义。之前的路径是
$(SRCROOT)/MyPrefixHeaderFile.pch
$(SRCROOT)/MyPrefixHeaderFile.pch
MyPrefixHeaderFile.pch
is in another folder inside the project folder, So i update the Prefix Header
path to
MyPrefixHeaderFile.pch
位于项目文件夹内的另一个文件夹中,因此我将Prefix Header
路径更新为
$(SRCROOT)/FolderName/MyPrefixHeaderFile.pch
$(SRCROOT)/FolderName/MyPrefixHeaderFile.pch
回答by ua24
Read this if you using cocoapods in project. I just update deployment target to iOS 10 or 11 in my case after updating pods and xcode make first build success. So problem was inside podfile where I had line
如果您在项目中使用 cocoapods,请阅读此内容。在我的情况下,我只是在更新 pods 和 xcode make first build 成功后将部署目标更新到 iOS 10 或 11。所以问题出在我有线路的 podfile 里面
platform :ios, '11.0'
and my deployment target in project was 9.0 after I change my podfile to platform to
在我将 podfile 更改为平台后,我在项目中的部署目标是 9.0
platform :ios, '9.0'
project was fixed.
项目已修复。
回答by nikdange_me
I found out that I accidentally opened the ProjectName.xcodeprojfile rather than the ProjectName.xcworkspacefile.
我发现我不小心打开了ProjectName.xcodeproj文件而不是ProjectName.xcworkspace文件。
Open the xcworkspacefile, project will start working again!
打开xcworkspace文件,项目将重新开始工作!
回答by Harris
Also make sure your import of "ProductModuleName-Swift.h" is in your .m file, and not your .h file.
还要确保您导入的“ProductModuleName-Swift.h”在您的 .m 文件中,而不是您的 .h 文件中。
回答by Li Yakun
回答by Anand
When you are getting this error in terminal upon running the xcodebuild command, do make sure you pass -workspace YourWorkspace.xcworkspace
当您在运行 xcodebuild 命令时在终端中收到此错误时,请确保通过 -workspace YourWorkspace.xcworkspace
回答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 Alessio Campanelli
in my point of view I solved simply switch the order of import statements and build works fine.
在我看来,我解决了简单地切换导入语句的顺序并且构建工作正常。
回答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 Marc-Alexandre Bérubé
Adding my very own situation to the loop.
将我自己的情况添加到循环中。
In my bridging header file, le'Ts say I added an import
在我的桥接头文件中,我说我添加了一个导入
#import "File.h"
#import "File.h"
Inside the File.h
header file, there was a type referenced from an import that was inside the Prefix.pch, had to add the missing #import in my File.h
在File.h
头文件中,有一个类型引用自 Prefix.pch 中的导入,必须在我的 File.h 中添加缺少的 #import