MacOS/Xcode fails in simulator first time only

I get this error when Building/Running any of the C examples on MacOS with Xcode.
But it only happens on the first time after I change code.

So ... change code ... build ... build succeeds .. get error message running in Sim.
Build again ... build succeeds ... runs fine in Sim.

And if I don't change any code, I can hit the Build/Run arrow over and over and it's fine.

macOS Monterey v12.3.1
Xcode v13.3.1
Playdate SDK 1.11.0

This is a bug in macOS. If you open the Terminal and enter this command (replacing the SDK path) it will fix it:

sudo xattr -r -d com.apple.quarantine <path to playdate sdk>/PlaydateSDK

That didn't seem to work.

I entered:
sudo xattr -r -d com.apple.quarantine /Users/derekmorris/Developer/PlaydateSDK
Then I entered my system password.

I tried rebooting too.

Oh, in your case you have to run it on the location you're building your game, e.g. /Users/derekmorris/GitHub/PlaydateGame

That doesn't work either. I wonder if it's stopped working on Monterey?

I can live with it. Just wondered if there was an easy fix. Thanks.

Hum, I just ran into this issue this morning with downloaded code and that fixed it for me. I'm at a bit of a loss as to why it's not working for you. Try deleting your game completely and rebuilding it after running this command if you haven't already.

Tried cleaning all build files and rebuilding.
I also ran that command on the build and build/Debug folders as that's what's showing up in the error but no joy.

I'm having the same problem as described here and wondering if anyone has had any luck in resolving?

I'm on an M1 Mac, Ventura 13.1 and Xcode 14.2.

Did you try the solution above? @twenty3

You could also try giving the Simulator full access in macOS system preferences privacy file access.

@matt, I did try all the above without any luck so far. It is interesting that doing a 'build' command, followed by a 'run' command from Xcode it will succeed.

Need to get some time to look at what happens in the run step in Xcode to see if I can isolate what is changing. Part of me wonders if it is a timing thing, like perhaps if the launch to the sim was a little delayed would it work in one step?

Related? Missing/incorrect dependencies for simulator DYLIB rule in common.mk - #4 by dave

Possibly, though when I build with Xcode there is always a zero size pdex.bin. I assume this is because the Xcode project only builds the pdex.dylib needed for the simulator?

That's correct; it is zero size because it's not needed in the Simulator builds.

1 Like

The zero-byte pdex.bin also happens when make is doing parallel builds, because there's a bug in our C_API/buildsupport/common.mk file: The pdc target should depend on device as well as simulator so that it finishes compiling pdex.bin before running pdc.

1 Like

Has this been finally resolved?

I have added the com.apple.quarantine attribute to both the SDK folder and the project folder, but no change.

For some reason, the problem goes away the second time around, so it's not that big of a deal, but it is a subtle and stressful issue.

Well, I understand that it is probably an Apple issue, not a Panic issue. :slight_smile:

Same here, removing quarantine attributes did not help.
As @dave said, I think it's just an issue related to the simulator trying to load the pdx bundle (that is passed as argument in the Xcode Run scheme configuration) while is someway not ready to be loaded.
Of course by hitting run twice simulator finds the pdx ready and starts without complaints.

As dumb workaround, I usually use this shortcut combo:
cmd+b (just build, no run)
then immediately
cmd+r (run)

This way simulator finds the pdx for sure and starts the game, without annoying error message.
It's not ideal, but it's someway better.

I'm not a cmake/make expert, but I really think that fixing build phases dependencies as @dave suggested will fix the issue.

1 Like