Clicking 'Export iOS' while on a different build target (like android) will result in an incomplete export.
The same might happen from the command line if -buildTarget iOS is omitted from the arguments.
This results in errors like
Value of type 'UnityAppController' has no member 'unityMessageHandler and
Value of type 'UnityAppController' has no member 'unitySceneLoadedHandler.
This issue is a sequel to #782, and might be a cause for issues like #426 #377 #486 #756 and more.
Problem
The build script will switch to iOS using SwitchActiveBuildTarget() and then continue the export.
However #if UNITY_IOS still returns false during this export, which ensures some code in XcodePostBuild will never be executed.
Unity needs a full recompile to change #if UNITY_ values, which can't happen within the same function.
Solution
I tried multiple approaches that wait for and detect a recompile, but none were reliable in all supported Unity versions.
In the end I decided to show a dialog requesting the user to run 'Export iOS' again, after the buildtarget has switched and scripts have been recompiled.
Type of Change
[ ] ✨ New feature (non-breaking change which adds functionality)
[x] 🛠️ Bug fix (non-breaking change which fixes an issue)
[ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
Description
Clicking 'Export iOS' while on a different build target (like android) will result in an incomplete export.
The same might happen from the command line if
-buildTarget iOS
is omitted from the arguments.This results in errors like
Value of type 'UnityAppController' has no member 'unityMessageHandler
andValue of type 'UnityAppController' has no member 'unitySceneLoadedHandler
.This issue is a sequel to #782, and might be a cause for issues like #426 #377 #486 #756 and more.
Problem
The build script will switch to iOS using
SwitchActiveBuildTarget()
and then continue the export.However
#if UNITY_IOS
still returns false during this export, which ensures some code in XcodePostBuild will never be executed.Unity needs a full recompile to change
#if UNITY_
values, which can't happen within the same function.Solution
I tried multiple approaches that wait for and detect a recompile, but none were reliable in all supported Unity versions.
In the end I decided to show a dialog requesting the user to run 'Export iOS' again, after the buildtarget has switched and scripts have been recompiled.
Type of Change