EarlGrey: Running Xcode Generated UITest Crashes on eDistantObject`SetupBlockInvocationForward

  1. Add EG2UITests UI Testing Bundle to our project
  2. Add Pod file changes:
    pod 'EarlGreyApp' (added to app target definition)
    
    target 'EG2UITests' do
        pod 'EarlGreyTest'
        pod 'iOSSnapshotTestCase'
        test_pods
    end
  1. Run pod install
  2. Run (generated) UI Test
  3. App crashes on launch:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
  * frame #0: 0x000000012a198324 eDistantObject`SetupBlockInvocationForward at NSBlock+EDOInvocation.m:49:5
    frame #1: 0x00000001075bf3a7 dyld_sim`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 517
    frame #2: 0x00000001075bf7b8 dyld_sim`ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
    frame #3: 0x00000001075ba9a2 dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 456
    frame #4: 0x00000001075ba90f dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 309
    frame #5: 0x00000001075ba90f dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 309
    frame #6: 0x00000001075b97a6 dyld_sim`ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 188
    frame #7: 0x00000001075b9846 dyld_sim`ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 82
    frame #8: 0x00000001075b10f1 dyld_sim`dyld::runInitializers(ImageLoader*) + 82
    frame #9: 0x00000001075b501e dyld_sim`dlopen_internal + 909
    frame #10: 0x000000010db109d9 libdyld.dylib`dlopen + 171
    frame #11: 0x00000001081cc7a7 CoreFoundation`_CFBundleDlfcnLoadBundle + 151
    frame #12: 0x0000000108099302 CoreFoundation`_CFBundleLoadExecutableAndReturnError + 274
    frame #13: 0x0000000107a3021a Foundation`-[NSBundle loadAndReturnError:] + 356
    frame #14: 0x0000000107906184 XCTest`_XCTestMain + 1508
    frame #15: 0x000000010759dedd EG2UITests-Runner`_XCTRunnerRunTests + 258
    frame #16: 0x000000010759dddb EG2UITests-Runner`__67-[_XCTRunnerAppDelegate application:didFinishLaunchingWithOptions:]_block_invoke + 9
    frame #17: 0x000000010811f29c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #18: 0x000000010811ea08 CoreFoundation`__CFRunLoopDoBlocks + 312
    frame #19: 0x0000000108119894 CoreFoundation`__CFRunLoopRun + 1284
    frame #20: 0x0000000108119066 CoreFoundation`CFRunLoopRunSpecific + 438
    frame #21: 0x000000011179fbb0 GraphicsServices`GSEventRunModal + 65
    frame #22: 0x000000010a27cd4d UIKitCore`UIApplicationMain + 1621
    frame #23: 0x000000010759e098 EG2UITests-Runner`main + 183
    frame #24: 0x000000010db0cc25 libdyld.dylib`start + 1

About this issue

Most upvoted comments

@AlbertWang0116 I was able to get passed this error/crash 😅 . We have a rather complicated Podfile setup. To prevent duplicate linkage of static libraries, I added EarlGreyApp & EarlGreyTest to a list static frameworks passed toremove_static_framework_duplicate_linkage inside Podfile

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = '$(inherited)'
        end
    end

    static_frameworks = [
      'EarlGreyApp',
      'EarlGreyTest'
    ]
    remove_static_framework_duplicate_linkage({
      'Framework' => static_frameworks
    })
end

remove_static_framework_duplicate_linkage as defined here

Albert, I checked the Podfile and eDistantObject version is 0.9.0.

Sorry for the latency. It is likely to be the dependency corruption at EarlGrey podspec. Could you check your Podfile.lock (auto generated beside your Podfile after pod install) that if the eDistantObject version is 0.9.1? If that’s the case, try changing it back to 0.9.0 and rerun the test (this was how I make Demo/EarlGreyExample work).

Downgrading to eDistantObject 0.9.0 as suggested in this seemingly similar issue did not work.