In my UI test, I have a test where I am using the UIPasteboard to throw the input around. Just before I use it, I store the current value of the pasteboard into a local temporary variable like so: let currentClipboard = UIPasteboard.general.string ?? ""
and it will be restored again at the end of the test like so: UIPasteboard.general.string = currentClipboard
. However, sometimes the let currentClipboard = UIPasteboard.general.string ?? ""
line takes forever to complete, if at all. I've waited like 1-2 minutes and it still stuck there. I know this because I actually added a breakpoint right below that line and it was never called. Can anybody tell me what's wrong with my code? Thanks.
Asked
Active
Viewed 517 times
3

Bawenang Rukmoko Pardian Putra
- 1,311
- 1
- 17
- 33
1 Answers
4
I've faced the same issue in the simulator only. If you're testing in simulator then just reset the simulator and it'll start working fine. And I didn't find this type of issue in the real device.

Kishan Barmawala
- 153
- 12
-
IC. Thanks for the answer. You are right, it only happens in simulator because it's only for UITesting. But it still happens even though I've restarted simulator so many times. – Bawenang Rukmoko Pardian Putra Jan 07 '21 at 08:20
-
@BawenangRukmokoPardianPutra You can workaround with reset/format instead of restart. – Kishan Barmawala Jun 19 '23 at 06:48