Exceptions disabled when building for iOS

I am trying to package a project for iOS which uses exception handling. Even when exceptions are force turned on with UEBuildConfiguration.bForceEnableExceptions = true;, packaging fails with the following error:

Cannot use try with exceptions disabled.

Hello ,

What configuration are you trying to build for? If it’s for shipping, that could be related as it may not be allowed in the shipping configuration.

Actually, after looking up that error message I came across this: Cannot use 'try' with exceptions disabled - Programming & Scripting - Epic Developer Community Forums

I wasn’t aware as I never tried using it, but it seems that Unreal doesn’t support exception handling.

Well Unreal does support it. In the OSX build configuration everything works as expected. When I build from Source I can also change UBT so that iOS gets exception support. But I think if you force enable the exceptions it should work without building from source, shouldn’t it?

Is it possible that it’s being added in the wrong area? It seems like people were having some confusion here at first that was causing the same error you’re seeing How can I enable unwind semantics for C++-style exceptions? - Programming & Scripting - Epic Developer Community Forums

No, as the source code does not consider the option. So the option is completely useless when building for iOS

Just to clarify, this working perfectly fine when building from source but doesn’t work properly when packaging with a Binary build, correct? I’ll ask RCL about the subject and see if he can give any ideas.

No. You have to change the source of the Engine to get it to compile correctly. It’s not an error, but rather - I think - unintended behavior. When you force exceptions on with bForceEnableExceptions, it should build on all Platforms with exceptions enabled. However, this is not the case and you have to change the source of Unreal Build Tool to get it to do that.

I spoke to RCL and someone else who’s our owner of iOS development and it seems that the iOS toolchain itself is completely ignoring bForceEnableExceptions. They’re also assuming it’s legacy from UE3. There’s currently a task in to add support for exception handling in iOS but hasn’t been completed yet. Unfortunately it seems that you’ll need to use the workaround of doing it through source for the time being. I’ll watch the task and update you here if there are any changes or updates to it.

That sounds great. Thank you!

Hello Matthew, please, is there any update on the iOS toolchain exception handling issue? Right now I am standing before a decision how to deal with exceptions coming from a third party library and a vision of solution from the Unreal side wold save me a lot a work.

It’s currently not a high priority task and is backlogged with no estimate of when it’ll be completed. I’ve updated the community interest section of it since you’ve expressed interest but this isn’t much more I can do to speed it along.

@Matthew Is this issue still not fixed? I have a few custom C++ classes which use exception handling. When I try to package the project for Mac, it gives the same error stated here. Please provide the latest progress on this issue