使用Realm Swift Pod的APP无法运行(CMD + R,崩溃编译Realm)但它确实测试(CMD + U)并且还存档

少年乘勇气,百战过乌孙。这篇文章主要讲述使用Realm Swift Pod的APP无法运行(CMD + R,崩溃编译Realm)但它确实测试(CMD + U)并且还存档相关的知识,希望能为你提供帮助。
我在与当前项目进行一些概念证明编辑时遇到了一个奇怪的问题。
我们试图测试的是,如果我们的项目在XCode 10.2下编译正常(截至今天的Beta 2,我们知道我们也有beta 3和4可用)。我们知道它是测试版的东西,我们必须小心它等等......
无论如何......我们正在处理的奇怪情况是使用Realm作为Pod(典型用法,otoh)。版本是RealmSwift 3.13.1
在XCode 10.1(Swift 4 world)下,我们整个项目编译。在XCode 10.2(Betas 2和4,再次是Swift 4 World)下,我们的项目无法编译。事实上,它崩溃编译Realm,带有令人讨厌的“分段错误代码:11”错误。
我们试图在Realm论坛,Stack Overflow等内部四处寻找......但收效甚微。我们不确定XCode 10.2对Realm的支持,因此我们的问题是:
-XCode 10.2编译Realm以将典型的“CMD + R”运行命令部署到模拟器上吗?
为了使事情变得更复杂,CMD + U(运行测试套件)和归档命令,请编译我们的整个项目,即编译REALM时没有任何问题(在XCode 10.2 beta 2和4下)。所以我们怀疑是奇怪的,我们不确定我们是否做错了什么,或者“运行”与“测试/编译”在领域编译阶段是不同的命令。
关于在哪里检查/测试的任何提示?我们开始没有想法了(除了为Realm提供正式支持XCode 10.2 beta 2,3和4以防它不受支持)。
问候
编辑:我们一直试图确定“领域编译部分错误:代码11”的确切原因。据我们所知,我们有这些情况:
1.-我们的代码中使用的SWIFT版本与崩溃无关。无论我们使用SWIFT 4还是SWIFT 5,在编译某些Realm .swift文件时(通过Podfile包含),Xcode 10.2仍会崩溃
2.-所有版本的XCode 10.2都会崩溃(beta2,beta4和最终正式官方)。 Xcode 10.1没有任何问题。
3.-我们试图在一个空项目(我们的Realm依赖项所在的项目)中隔离我们的“数据模块”。在隔离此模块时,REALM完全正确编译。
4.-当我们将“数据模块”集成到我们的“大项目”中时,在编译Realm时会出现SegFault崩溃。
我们得到的典型“崩溃转储”是(例如)这个(建议将其粘贴到您喜欢的文本编辑器中,前面是丑陋的行):

0.Program arguments: /Applications/Xcode_10.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Aliases.swift -primary-file /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Error.swift -primary-file /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/LinkingObjects.swift -primary-file /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/List.swift -primary-file /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Migration.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Object.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/ObjectiveCSupport.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/ObjectSchema.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Optional.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Property.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Realm.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/RealmCollection.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/RealmConfiguration.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Results.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Schema.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/SortDescriptor.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/SwiftVersion.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Sync.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/ThreadSafeReference.swift /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/RealmSwift/RealmSwift/Util.swift -supplementary-output-file-map /var/folders/zw/lb043_2n0ng097crfq3rzfc00000gr/T/supplementaryOutputs-137c0f -target x86_64-apple-ios8.0-simulator -enable-objc-interop -sdk /Applications/Xcode_10.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -I /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Products/Debug-iphonesimulator/RealmSwift-iOS -F /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Products/Debug-iphonesimulator/RealmSwift-iOS -F /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Products/Debug-iphonesimulator/Realm-iOS -application-extension -enable-testing -g -import-underlying-module -module-cache-path /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -profile-generate -profile-coverage-mapping -sanitize=thread -swift-version 4 -enforce-exclusivity=checked -Onone -D DEBUG -D COCOAPODS -serialize-debugging-options -Xcc -working-directory -Xcc /Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods -enable-anonymous-context-mangled-names -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/RealmSwift-generated-files.hmap -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/RealmSwift-own-target-headers.hmap -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/RealmSwift-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/RealmSwift-project-headers.hmap -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Products/Debug-iphonesimulator/RealmSwift-iOS/include -Xcc -I/Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/Headers/Private -Xcc -I/Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/Headers/Public -Xcc -I/Users/MYUSERNAME/proyectos/MY_PROJECT_FOLDER_NAME/dev/MYMAINPROJECTNAME/Pods/Headers/Public/HockeySDK -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/DerivedSources-normal/x86_64 -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/DerivedSources -Xcc -DPOD_CONFIGURATION_DEBUG=1 -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -ivfsoverlay -Xcc /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/unextended-module-overlay.yaml -module-name RealmSwift -o /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/Aliases.o -o /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/Error.o -o /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/LinkingObjects.o -o /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/List.o -o /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/Migration.o -index-store-path /Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Index/DataStore -index-system-modules 1.Running pass 'CallGraph Pass Manager' on module '/Users/MYUSERNAME/Library/Developer/Xcode/DerivedData/MYMAINPROJECTNAME-efvegromitzyfvcolcgynqojoooi/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RealmSwift-iOS.build/Objects-normal-tsan-ubsan/x86_64/LinkingObjects.o'. 2.Running pass 'Dominator Tree Construction' on function '@"$s10RealmSwift14LinkingObjectsCyxSicir.resume.0"' 0swift0x00000001073b8ee3 PrintStackTraceSignalHandler(void*) + 51 1swift0x00000001073b86bc SignalHandler(int) + 348 2libsystem_platform.dylib 0x00007fff6acdeb3d _sigtramp + 29 3libsystem_malloc.dylib0x00007fff6aca6a61 small_malloc_from_free_list + 166 4swift0x0000000107291991 llvm::DomTreeBuilder::SemiNCAInfo< llvm::DominatorTreeBase< llvm::BasicBlock, false> > ::CalculateFromScratch(llvm::DominatorTreeBase< llvm::BasicBlock, false> & , llvm::DomTreeBuilder::SemiNCAInfo< llvm::DominatorTreeBase< llvm::BasicBlock, false> > ::BatchUpdateInfo*) + 1025 5swift0x0000000107291583 llvm::DominatorTreeWrapperPass::runOnFunction(llvm::Function& ) + 19 6swift0x00000001072d45ad llvm::FPPassManager::runOnFunction(llvm::Function& ) + 1613 7swift0x0000000105eb0e27 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module& ) + 2311 8swift0x00000001072e0a00 llvm::legacy::PassManager::run(llvm::Module& ) + 1696 9swift0x00000001033f6518 swift::performLLVM(swift::IRGenOptions& , swift::DiagnosticEngine*, llvm::sys::SmartMutex< false> *, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, swift::version::Version const& , llvm::StringRef, swift::UnifiedStatsReporter*) + 5816 10 swift0x000000010321d91e performCompile(swift::CompilerInstance& , swift::CompilerInvocation& , llvm::ArrayRef< char const*> , int& , swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 51566 11 swift0x000000010320d6de swift::performFrontend(llvm::ArrayRef< char const*> , char const*, void*, swift::FrontendObserver*) + 6862 12 swift0x00000001031ab7be main + 1246 13 libdyld.dylib0x00007fff6aaf3ed9 start + 1

答案我发现为什么在我们的“大”项目中编译Realm导致Swift编译器崩溃。显然,罪魁祸首是当前架构的RUN部分内的“Thread Sanitizer”选项。
看起来,新的Swift编译器版本对某些文件存在这个问题,因为我们的团队忽略了一些“已知问题”(对我们感到羞耻(?)!)。
*Known Issues The Swift compiler may crash during a build when the Thread Sanitizer is enabled. (48719789)Workaround: Disable Thread Sanitizer in the Scheme Editor’s Diagnostics tab.

只是禁用“Thread Sanitizing”选项会使Swift感到高兴并且不再崩溃。
【使用Realm Swift Pod的APP无法运行(CMD + R,崩溃编译Realm)但它确实测试(CMD + U)并且还存档】现在让我们希望Apple尽快解决这个问题。问候。

    推荐阅读