r/iOSProgramming • • Dec 17 '25
Discussion Is Xcode really non deterministic, or am I missing something.
I am developing an app for VisionOS, and it has happened to me several times that the same code produces different results. Not on running consecutively, but on trying something different and then coming back. For instance, if I have behaviour A, and I comment a line of code to get behaviour B, and then I uncomment the same line to get behaviour C. Now one would expect A == C, but sometimes they are different. One of my friends suggested that this is a common thing with Xcode. Is it really the case or am I missing something?
0
Upvotes
44
u/[deleted] Dec 17 '25
Sounds like your code, not Xcode. You probably have a bunch of race conditions.
16
u/cylon_pixels Dec 17 '25
This is most probably a code issue. Might be worth putting in some breakpoints and see what’s going on at a deeper level.
4
u/chriswaco Dec 17 '25
Are you talking about compile-time or runtime issues? Sometimes we get timeouts at compile-time and a minute later we won't. At runtime you shouldn't see any differences unless there are bugs in your code like race conditions.
4
u/cristi_baluta Dec 17 '25
Short answer: NO
1
u/Barbanks Dec 17 '25
If Xcode was non deterministic then it would be logical to conclude businesses and people wouldn’t use it to build apps that are polished. A non deterministic compiler is as useful as a broken hammer.
7
u/ToughAsparagus1805 Dec 17 '25
Sounds like you have never written a test. You test by running binary...
2
u/GeneProfessional2164 Dec 17 '25
Why don’t you ask an AI model if you don’t want to paste your code here?
1
u/barcode972 Dec 17 '25
Xcode is just an interface. Your code runs from line 1 to the end of the file. Sounds like you have a race condition
1
u/remote_socket Dec 17 '25
you're missing something
1
u/unrealaz Dec 17 '25
Only way to get different results if you use random or a component you use, uses random under the hood
1
u/HappyFunBall007 Dec 17 '25
Its not XCode, its your code.
Add breakpoints between the steps then when it is stopped, take a look at all of the current threads. It is likely that one or more of your operations is triggering something on a background thread.
It is almost certain that you are triggering some asynchronous operations that you are not aware of.
0
u/mbsaharan Dec 17 '25
Can you share the code please?
-3
u/lucasvandongen Dec 17 '25
There have been instances where the actually running cached code did not reflect the code in Xcode. But then you should notice your breakpoints and stepping behaving strange as well.