DRYな備忘録

Don't Repeat Yourself.

【Xcode】/usr/lib/swift/libswiftCore.dylib: mach-o, but not built for iOS simulator

問題

UITest実行時に、以下のエラーが出てテストがコケる。

2020-02-26 15:34:47.656498+0200 ExampleUITests-Runner[2134:4937234] +[CATransaction synchronize] called within transaction
2020-02-26 15:34:47.665527+0200 ExampleUITests-Runner[2134:4937234] Running tests...
2020-02-26 15:34:47.690928+0200 ExampleUITests-Runner[2134:4937234] The bundle “ExampleUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2020-02-26 15:34:47.691036+0200 ExampleUITests-Runner[2134:4937234] (dlopen_preflight(/Users/hiromu/Library/Developer/Xcode/DerivedData/Example-cfyafhhbbnwfizglyzbfwoouudes/Build/Products/Debug-iphonesimulator/ExampleUITests-Runner.app/PlugIns/ExampleUITests.xctest/ExampleUITests): Library not loaded: /usr/lib/swift/libswiftCore.dylib
  Referenced from: /Users/hiromu/Library/Developer/Xcode/DerivedData/Example-cfyafhhbbnwfizglyzbfwoouudes/Build/Products/Debug-iphonesimulator/ExampleUITests-Runner.app/PlugIns/ExampleUITests.xctest/ExampleUITests
  Reason: no suitable image found.  Did find:
    /usr/lib/swift/libswiftCore.dylib: mach-o, but not built for iOS simulator)

環境

調査

$ ls -la /usr/lib/swift/libswiftCore.dylib
-rwxr-xr-x  1 root  wheel  6698944  7 29  2019 /usr/lib/swift/libswiftCore.dylib

dylibは、たしかに有る。but not built for iOS simulatorとあるので、UITestのために使用しているiOS simulatorのバージョンを変えればいいのだろうか?プロジェクトのビルドターゲットがiOS 12.0+なので、12.0などを使っていたが、いろいろ試して

通った。

とりあえず結論

なので、プロジェクトのビルドターゲットに関わらず、使っているXcodeがサポートしているiOSのバージョンのSimulatorのlibswiftCore.dylibしかないよ、ということなのだと思う。さもありなん、という感じ。

Xcode 11 で iOS 12.0 上のUITestをしたい

// TODO: こんどかく

NOT DRY YET