I'm having a strange problem doing some Proof of Concept compilations with my current project.
What we're trying to test is if our project compiles ok under XCode 10.2 (Beta 2 as of today, we know we also have betas 3 and 4 available). We know it's beta stuff, we have to be careful with it, etc...
Whatever... The strange situation we're dealing with is using Realm as a Pod (typical usage, otoh). Version is RealmSwift 3.13.1
Under XCode 10.1 (Swift 4 world) our whole project compiles. Under XCode 10.2 (Betas 2 and 4, again Swift 4 World), our project doesn't compile. In fact it crashes compiling Realm, with a nasty "segmentation fault code: 11" error.
We've tried to look around inside Realm forums, Stack Overflow, etc... with not much success. We're not sure about XCode 10.2 support for Realm and hence our question:
-Does XCode 10.2 compile Realm for a typical "CMD + R" run command deployment onto the simulator?
To make things a bit more complicated, CMD + U (run test suites) and Archive commands, DO COMPILE OUR WHOLE PROJECT ok, that is, no problem whatsoever when compiling REALM (Under XCode 10.2 beta 2 and 4). So our doubt is strange, we're not sure if we're doing something wrong, or if "run" vs "test/compile" are different commands in terms of the Realm compilation phase.
Any hint about where to check/test? We're starting to run out of ideas (beyond wating for Realm to officially support XCode 10.2 beta 2 ,3 and 4 in case it's not supported).
Greetings
EDIT: We've been trying to nail down the exact cause of the "Realm Compilation Segementation Fault: Code 11". As far as we know, we have these situations:
1.- SWIFT version used in our code has nothing to do with the crash. No matter if we use SWIFT 4 or SWIFT 5, Xcode 10.2 still crashes when compiling certain Realm .swift files (included via Podfile)
2.- ALL versions of XCode 10.2 do crash (beta2, beta4 and final full official). Xcode 10.1 has no problem whatsoever.
3.- We've tried to isolate our "Data Module" inside an empty project (which is the one where our Realm dependency lives). When isolating this module, REALM COMPILES PERFECTLY.
4.- When we integrate the "Data Module" into the "big project" of us, then, when compiling Realm the SegFault crash appears.
The typical "crash dump" we get is (for example) this one (it's advisable to copy paste it into your favourite text editor, ugly lines ahead):
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"'
0 swift 0x00000001073b8ee3 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x00000001073b86bc SignalHandler(int) + 348
2 libsystem_platform.dylib 0x00007fff6acdeb3d _sigtramp + 29
3 libsystem_malloc.dylib 0x00007fff6aca6a61 small_malloc_from_free_list + 166
4 swift 0x0000000107291991 llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::CalculateFromScratch(llvm::DominatorTreeBase<llvm::BasicBlock, false>&, llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::BatchUpdateInfo*) + 1025
5 swift 0x0000000107291583 llvm::DominatorTreeWrapperPass::runOnFunction(llvm::Function&) + 19
6 swift 0x00000001072d45ad llvm::FPPassManager::runOnFunction(llvm::Function&) + 1613
7 swift 0x0000000105eb0e27 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 2311
8 swift 0x00000001072e0a00 llvm::legacy::PassManager::run(llvm::Module&) + 1696
9 swift 0x00000001033f6518 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 swift 0x000000010321d91e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 51566
11 swift 0x000000010320d6de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
12 swift 0x00000001031ab7be main + 1246
13 libdyld.dylib 0x00007fff6aaf3ed9 start + 1
I've discovered why compiling Realm inside our "big" project caused Swift compiler to crash. Apparently the culprit is the "Thread Sanitizer" option inside the RUN section for the current schema.
As it seems, the new Swift compiler version has this problem with certain files, as it's noted in some "known issue" that our team overlooked (shame on us (?)!).
Just disabling the "Thread Sanitizing" option makes Swift happy and it doesn't crash anymore.
Now let's hope Apple fixes this as soon as they can. Greetings.