Test target X encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted

I have my notes and demo applications for both Cocoapods and Carthage here https://github.com/onmyway133/TestTarget

  • Make sure all frameworks are linked to the Test targets
  • Configure Runpath Search Paths to point to $(FRAMEWORK_SEARCH_PATHS)

More info

  • Run-Path Dependent Libraries

I'm using carthage and problem for me was searching for dependencies in a test target. Fix:

Add $(PROJECT_DIR)/Carthage/Build/iOS to Runpath Search Paths

You can find reference here: Carthage issue


There might another solution, if you are using CocoaPods and the UI test target is embedded inside the app target, which is, unfortunately, the case in the default template (pod init).

Try move the UI test target out of the app target as follows:

from:

platform :ios, '11.0'
use_frameworks!

target 'MyApp' do
  # Pods for MyApp

  target 'MyAppUITests' do
    inherit! :search_paths
    # Pods for testing

  end
end

to:

platform :ios, '11.0'
use_frameworks!

# Pods shared between MyApp and MyAppUITests    

target 'MyApp' do
    # Pods for MyApp only

end

target 'MyAppUITests' do
    # Pods for testing

end

Credit goes to SpacyRicochet in this issue thread: https://github.com/CocoaPods/CocoaPods/issues/4752#issuecomment-305101269