GoogleMobileAds (SWIFT) - 命令因信号而失败:分段错误:11

GoogleMobileAds (SWIFT) - Command failed due to signal : Segmentation fault: 11

我已经通过 CocoaPods 添加了 GoogleMobileAds,正如此处所解释的那样:admob iOS quick start

我的代码如下所示:

import Firebase
import GoogleMobileAds
....
var interstitial: GADInterstitial!

我每次尝试编译都会遇到这个错误:

 Command failed due to signal : Segmentation fault: 11

清理和重新启动没有帮助。我在这个文件中没有任何其他导入,所以 this answer 对我没有帮助。 我正在使用 pods 获取的最新版本的 adMob,因此将代码更改为 suggested here 似乎也不是正确的方向。 这怎么能解决?

这是日志:

MergeSwiftModule normal x86_64 /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/Playbuzz.swiftmodule cd /Users/luda/Documents/Development/playbuzz.ios /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-module /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/QuizResult~partial.swiftmodule +++++++++++++++++++++++++++++++++++ I/Users/luda/Documents/Development/playbuzz.ios/Pods/Headers/Public/GoogleUtilities -Xcc -I/Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/DerivedSources/x86_64 -Xcc -I/Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/luda/Documents/Development/playbuzz.ios -emit-module-doc-path /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/Playbuzz.swiftdoc -module-name Playbuzz -emit-objc-header-path /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/Playbuzz-Swift.h -o /Users/luda/Library/Developer/Xcode/DerivedData/Playbuzz-cexhbhfyfhomayguuohivuzvrlzx/Build/Intermediates/Playbuzz.build/Debug-iphonesimulator/Playbuzz.build/Objects-normal/x86_64/Playbuzz.swiftmodule

  1. While loading members for 'ItemViewController' at
  2. While deserializing decl #182 (PATTERN_BINDING_DECL)
  3. While deserializing decl #21 (VAR_DECL)

是的,这个问题让我困扰了好几天...我终于通过启用整个模块优化找到了解决方案。 link 解释了如何:

http://useyourloaf.com/blog/swift-whole-module-optimization/

祝你好运!

这个段错误对我们来说是因为我们 在我们的开发 pods 之一。值得一提的是,虽然我们的错误信息是一样的,但我们没有使用 AdMob,启用全模块优化并没有解决我们的问题。

我们正在开发 pods 各种内部库。当我们在将新的核心数据实体添加到我们的开发之一 pods(称为此 pod A)后尝试编译我们的主要应用程序项目时,我们将得到 "Segmentation fault: 11" 而 Xcode 构建 pods B 和 C 依赖于 A。 Xcode 报告 pod A 本身没有错误。 运行 MergeSwiftModule 时出现构建 B 和 C 的错误。这是我们收到的堆栈跟踪的清理版本:

MergeSwiftModule normal x86_64 /Users/me/Library/Developer/Xcode/DerivedData/MyApp-xyz/Build/Intermediates/Pods.build/Debug-iphonesimulator/PodB.build/Objects-normal/x86_64/PodB.swiftmodule
cd /Users/me/Code/ios/MyApp/Pods
"/Applications/Xcode 8.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift" -frontend -emit-module ... (long command omitted here)
0  swift                    0x00000001091bf3ad PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x00000001091beb56 SignalHandler(int) + 790
2  libsystem_platform.dylib 0x00007fff9916552a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1726589680
4  swift                    0x00000001067cb996 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 806
5  swift                    0x00000001067c4178 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 18664
6  swift                    0x00000001067cfb2c swift::ModuleFile::maybeReadPattern() + 332
7  swift                    0x00000001067cfece swift::ModuleFile::maybeReadPattern() + 1262
8  swift                    0x00000001067c2d82 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 13554
9  swift                    0x00000001067d44a7 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 647
10 swift                    0x0000000106b6706a (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 314
11 swift                    0x0000000106b6501b (anonymous namespace)::Traversal::doIt(swift::Decl*) + 219
12 swift                    0x000000010651cc2f swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 1423
13 swift                    0x0000000106521cef swift::runSILDiagnosticPasses(swift::SILModule&) + 159
14 swift                    0x00000001061cbf7e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 19758
15 swift                    0x00000001061c52b3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17859
16 swift                    0x00000001061815cf main + 8239
17 libdyld.dylib            0x00007fff956745ad start + 1
18 libdyld.dylib            0x0000000000000068 start + 1788394172
Stack dump:
0. Program arguments: /Applications/Xcode 8.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -emit-module ... (long command omitted here)

当我们单独打开 pod A 的项目文件并尝试编译它时,Xcode 抱怨我们有 。一旦我们通过将有问题的实体的 Codegen 设置更改为 "Manual/None" 来修复该问题,在构建 pod A 的项目和整个主应用程序项目时,所有问题都神奇地消失了。

我遇到了不同 pods 的相同问题。不幸的是,每次我清洁产品时,它都是其他豆荚。

所以我只是 de-installed 逐个 pod,每次都 x-code 清理产品并尝试 运行 应用程序(这是个婊子,因为 pods 正在使用中)。

再次 运行ning 之后,我安装了 pods(一步到位)- 一切都恢复正常了。