Swift UI tests failing to launch on pre iOS 12.3 devices

前端 未结 3 1644
太阳男子
太阳男子 2021-01-27 02:58

I\'m trying to setup some UI tests but can\'t get them to run on devices running pre iOS 12.3.

Even if I start a fresh swift project with \'include UI tests\' ticked and

相关标签:
3条回答
  • 2021-01-27 03:18

    The answer to this is infuriatingly simple. Just make sure, in your build settings, that the UI tests target has the same deployment target as the app.

    I'd changed the app to target down to iOS 10 but hadn't thought I'd need to make the same change for the UI tests target.

    I'd imagine this is something that should be auto-synced for us, presumably no reason to have them targeting different versions really

    0 讨论(0)
  • 2021-01-27 03:25

    I have 2 guesses,

    1. dyld: Library not loaded: @rpath/libswiftCore.dylib

    2. Did you download the the components for the ios versions in components?

    Turn your computer on and off & worse case uninstall and reinstall xcode.

    0 讨论(0)
  • 2021-01-27 03:25

    I've found a workaround for this issue, though it's not necessarily reliable for future versions of Xcode so be wary if you decide to try this out (maybe you'd need to repeat the process after an Xcode upgrade).

    If you go to the following directory you'll find all the swift libraries for iPhone devices:

     Applications⁩ ▸ ⁨Xcode⁩ ▸ ⁨Contents⁩ ▸ ⁨Developer⁩ ▸ ⁨Toolchains⁩ ▸ XcodeDefault.xctoolchain⁩ ▸ ⁨usr⁩ ▸ ⁨lib⁩ ▸ ⁨swift⁩ ▸ ⁨iphoneos
    

    You can copy those into your UI tests target (not the app being tested) and then add a copy files build phase to bundle the libraries into the test runner, such that they can be found at runtime. You don't need all the swift libraries, the following image shows which ones I found to be required:

    ⁩It's also worth noting that this messes up running the tests on simulator (no doubt in part because these swift libraries that have been copied are the versions for a device), though there may be a way to get around that or maybe that's fine if you don't intend to run them on the simulator

    0 讨论(0)
提交回复
热议问题