Search code examples
xcoderx-swift

Segmentation Fault when running the project


I have just simply added the RxSwift and RxCocoa pods to my project. When I try to run , it ends up with segmentation fault 11

I tried to delete the project and recreate it, it is still happening.

This is the error block

RxSwift/RxSwift/ViewController.swift:10:8: warning: file 'ViewController.swift' is part of module 'RxSwift'; ignoring import
import RxSwift
       ^
<unknown>:0: error: circular dependency between modules 'RxSwift' and 'RxRelay'
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/myMAC/Documents/Debanjan_iOS/RxSwift/RxSwift/ViewController.swift /Users/myMAC/Documents/Debanjan_iOS/RxSwift/RxSwift/AppDelegate.swift -emit-module-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -emit-module-doc-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -serialize-diagnostics-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController.d -emit-reference-dependencies-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController.swiftdeps -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -I /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator -F /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator -F /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxCocoa -F /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxRelay -F /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxSwift -enable-testing -g -module-cache-path /Users/myMAC/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -D COCOAPODS -serialize-debugging-options -Xcc -working-directory -Xcc /Users/myMAC/Documents/Debanjan_iOS/RxSwift -enable-anonymous-context-mangled-names -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/RxSwift-generated-files.hmap -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/RxSwift-own-target-headers.hmap -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/RxSwift-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/RxSwift-project-headers.hmap -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxCocoa/RxCocoa.framework/Headers -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxRelay/RxRelay.framework/Headers -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Products/Debug-iphonesimulator/RxSwift/RxSwift.framework/Headers -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/DerivedSources-normal/x86_64 -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/DerivedSources/x86_64 -Xcc -I/Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -module-name RxSwift -o /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Build/Intermediates.noindex/RxSwift.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/ViewController.o -index-store-path /Users/myMAC/Library/Developer/Xcode/DerivedData/RxSwift-gjewryzxztmluifpnkaqwnrbconi/Index/DataStore -index-system-modules 
0  swift                    0x000000010cbf4ee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010cbf46bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff5ad89b5d _sigtramp + 29
3  libsystem_platform.dylib 0x00000001108c9384 _sigtramp + 3048470596
4  swift                    0x0000000109e21f85 swift::SerializedModuleLoaderBase::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 629
5  swift                    0x0000000109f82de5 swift::ASTContext::getModule(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 245
6  swift                    0x0000000109c655ff swift::performNameBinding(swift::SourceFile&, unsigned int) + 1695
7  swift                    0x000000010954ec1a swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 3562
8  swift                    0x0000000108a4d2f6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 838
9  swift                    0x0000000108a496de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
10 swift                    0x00000001089e77be main + 1246
11 libdyld.dylib            0x00007fff5aba43d5 start + 1
12 libdyld.dylib            0x000000000000005c start + 2772810888
error: Segmentation fault: 11

This is my sample project code

import UIKit
import RxSwift
import RxCocoa

class ViewController: UIViewController {
    @IBOutlet weak var resetBtn: UIButton!
    @IBOutlet weak var validateBtn: UIButton!
    @IBOutlet weak var secondErrorLabel: UILabel!
    @IBOutlet weak var firstErrorLabel: UILabel!
    @IBOutlet weak var secTxtField: UITextField!
    @IBOutlet weak var firstTxtField: UITextField!


    override func viewDidLoad() {
        super.viewDidLoad()

        setUpObservables()
        // Do any additional setup after loading the view.
    }

    func setUpObservables() {

    }

}

This is the podfile of the project

target 'RxSwift' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for RxSwift
  pod 'RxSwift', '~> 5.0.0'
  pod 'RxCocoa', '~> 5.0.0'

end

Solution

  • You named your target RxSwift which is exactly the same as the name of the dependency. This is probably why you made Xcode and Cocoapods mess things up. Rename your project and try again.