iOS Breakpoints being ignored

I can’t figure this out. When debugging a real device it seems that the app launches before Xojo is aware it’s launched, and then none of the breakpoints work.
More, if the app crashes it still looks like it’s running in the debugger.

Any ideas?

Just a guess, but if you have your app set to build for App Store, Xojo builds it but launches the previous version you built for the debugger on the device. It catches me at least once a week. I tried to report it but wasn’t able to build a good enough case: https://tracker.xojo.com/xojoinc/xojo/-/issues/76027

@Jason_Tait - you can fix this my making sure that the non-release version increments when you debug or build. Just remember to reset it to zero when you increase one of the other version components.

I wrote scripts to do this automatically and haven’t had trouble since.

Thanks @Greg_O but can you explain further about what happens when you do this? The issue I have is that instead of Xojo displaying a warning message in this scenario, eg “Hey you’ve just pressed the Run button to debug the latest build on your device but the app is set to build for App Store so the build you’re about to see is the last Debug build that you made, which might have been from some time back and the debug variables and breakpoints are not going to work” it just launches that old debug version so you lose seconds or minutes running it without realising it doesn’t include your code changes. How does incrementing the non-release version fix this?

If Xojo just displayed a message “You’re running a build for App Store on device so the build settings have been switched to Debug as that’s obviously what you’re intending to do” and then switched the build settings to Debug before building, that would be even better.

Huh. This could be it.

I’ll test today.

The problem is that the simulator doesn’t know the difference. When you do a debug run and the previous version is already “running” on iOS, if the new build has exactly the same version, iOS assumes that nothing has changed and just relaunches the one it has in memory. When you actually increment the version, even the non-release version, iOS should say “oh, this one is newer, I should replace the one I have with the new one and launch that.”

3 Likes

Thanks Greg for clarifying this. Didn’t know about it.

More investigation:

I deleted the app from the device and tried again. It won’t run on a real device.

Same when I build and try to install via Xcode. But, if I send it to TestFlight it’s fine.

This is my only app that fails this way and I can’t figure out why.

If you connect your device to your Mac and then go to Xcode’s device list, you should be able to look at the logs and crash logs. That might help the diagnostics

Not seeing anything obvious. Not sure what to look for either.

I just get a message that compilation of “my app” failed.

An error occurred when attempting to launch the application. Please make sure the device stays awake and unlocked and check the Minimum iOS version.

I’ve set minimum to 14.0 the app isn’t otherwise installed on the phone, and it’s both unlocked.

I feel like this has happened before but I can’t remember the details.

Well I’d search the logs for the words crash, exit or terminate to start.

Just to check, this device you’re testing on is in the development profile that you’re using, correct?

I really hope that’s not being automagically changed by the IDE. There are certain things that don’t work when running on device if App Store isn’t selected.

Yep. I did. Lots of things about it not being installed and not being launched etc. But I can’t find the culprit.

I just went through the motions of creating new certificates and profiles.

Very frustrating.

Of course the worst thing is that there is a crash on the phone from the distributed app that does not happen in the simulator. No way to get to the bottom of it.

Just remember that the simulator doesn’t have all of the hardware that a physical device does. For instance, touchID and FaceID are completely emulated. Bluetooth is also emulated.

So is there any hardware that your app uses?

Yes, it uses bluetooth, can use camera.

But I have other apps that use bluetooth the same way and they run.

I also setup a project in Xcode with the same team, bundle id etc and it will debug on the hardware.

I don’t know if there is a problem and Xojo is picking the wrong profiles certs or whatever, or if it’s something deeper.

How can I see which dev profile Xojo is using when I’m debugging?

Something is really fishy.

I have several developer accounts, and I’m wondering if something is getting selected incorrectly.