【问题标题】:XCode will build 'debug' but not 'release' because "<Module>-Swift.h" header is not foundXCode 将构建“调试”而不是“发布”,因为找不到“<Module>-Swift.h”标头
【发布时间】:2015-06-01 08:45:16
【问题描述】:

生日,

这真的让我很生气,我的框架项目在调试配置中构建时没有错误或警告,但是当我尝试构建存档时它失败了,因为找不到 &lt;Module&gt;-Swift.h。显然它没有在此配置中生成。

有时发生这种情况时(在调试中),我可以删除对 swift 标头的引用,构建然后放回然后重新构建以修复它。这在为 Release 构建时没有帮助。

所有与 swift 相关的构建设置对于 Debug 和 Release 都是一样的。

这是一个来自构建日志的错误示例,请注意文件 LBImageView.swift 不导入除 Foundation 之外的任何内容。它没有引用DRHExperimentData 类:

CompileSwift normal x86_64 /Users/l.walsh/Documents/Developer/LabBot/LBImageView.swift
cd /Users/l.walsh/Documents/Developer/LabBot
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/l.walsh/Documents/Developer/LabBot/LBImageView.swift /Users/l.walsh/Documents/Developer/LabBot/LBSize.swift /Users/l.walsh/Documents/Developer/LabBot/LBDataMatrix.swift /Users/l.walsh/Documents/Developer/LabBot/LBCalibratedPair.swift /Users/l.walsh/Documents/Developer/LabBot/LBExtensions.swift /Users/l.walsh/Documents/Developer/LabBot/LBExperimentDelegate.swift /Users/l.walsh/Documents/Developer/LabBot/LBGridView.swift /Users/l.walsh/Documents/Developer/LabBot/LBPoint.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release -F /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release -g -import-underlying-module -module-cache-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-generated-files.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-own-target-headers.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/LabBot-project-headers.hmap -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/BuildProductsPath/Release/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/DerivedSources/x86_64 -Xcc -I/Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/DerivedSources -Xcc -ivfsoverlay -Xcc /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/l.walsh/Documents/Developer/LabBot -emit-module-doc-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView~partial.swiftdoc -O -module-name LabBot -emit-module-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView~partial.swiftmodule -serialize-diagnostics-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.dia -emit-dependencies-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.d -emit-reference-dependencies-path /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.swiftdeps -o /Users/l.walsh/Library/Developer/Xcode/DerivedData/LabBot-hjckzfsxfeqqsxdbhfipevwfcmkx/Build/Intermediates/ArchiveIntermediates/LabBot/IntermediateBuildFilesPath/LabBot.build/Release/LabBot.build/Objects-normal/x86_64/LBImageView.o

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/l.walsh/Documents/Developer/LabBot/LabBot.h"
    ^
/Users/l.walsh/Documents/Developer/LabBot/LabBot.h:16:9: note: in file included from /Users/l.walsh/Documents/Developer/LabBot/LabBot.h:16:
#import "DRHExperimentData.h"
    ^
/Users/l.walsh/Documents/Developer/LabBot/DRHExperimentData.h:12:9: error: 'LabBot/LabBot-Swift.h' file not found
#import <LabBot/LabBot-Swift.h>
    ^
<unknown>:0: error: could not build Objective-C module 'LabBot'

有没有人遇到过这个问题并解决了?有人有什么想法吗?

感谢您对此的任何帮助, 李。

【问题讨论】:

  • 在构建设置中验证您的“标题路径”,用于调试模式
  • @HoaParis 我不确定您指的是哪个设置。没有设置调用“标题路径”。包括搜索路径和界面路径在内的所有各种路径看起来都是正确的,并且对于 Debug 和 Release 设置都是相同的。
  • 我的意思是在 XCode 中为您的应用程序的“构建设置”中的“标题搜索路径”。
  • @HoaParis 谢谢,但正如我所说,各种搜索路径看起来都很好,并且对于调试和发布模式都是相同的。此外,如果它有所作为,它不是一个应用程序而是一个框架,如 OP 中所述。
  • 我突然遇到了同样的问题。然后我必须先在发布模式下构建框架,然后再构建主要目标。它解决了问题。

标签: xcode macos swift xcode6


【解决方案1】:

所以事实证明你不能#import Swift 模块头到 obj-c .h 文件中,你必须把它们放在 .m 文件中。因此,我从 class.h 中删除了 #import &lt;LabBot/LabBot-Swift.h&gt; 并将其放入 .m 文件中。问题解决了。

请注意,如果您的接口引用了在您要导入的 Swift 模块中定义的类,则您需要在 .h 文件中添加 @class 语句。

不幸的是,由于某种原因,XCode 让我在构建 Debug 时无需将模块头导入 .h 文件。它只在为 Release 构建时吐出假人。此外,XCode 不会抛出与有问题的 obj-c 类相关的错误,它会抛出与包含的 Swift 模块中的类相关的错误。

也许有一个构建设置停止让 Debug 允许这个(或让 Release 允许它),但我找不到它。

【讨论】:

  • 非常感谢。您的回答帮助我找出导致此问题的原因。我花了很多时间才找到一个可以正常工作的解决方案。
猜你喜欢
  • 1970-01-01
  • 2014-12-21
  • 2023-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-03
  • 2012-09-19
  • 1970-01-01
相关资源
最近更新 更多