Unused variables causing build failures?

OK I’m up to build # 6 trying to get a project built for iOS. The builds fail after about 10 minutes of time and the logs show two particular errors:

[error] [2025-02-28T04:41:02Z - Unity] ERROR: Unable to fall back to CPU lightmapper.

[error] [warning] [2025-02-28T04:41:03Z - Unity] ERROR: Player export failed. Reason: Assets/Scripts/GUI/CardInfoController.cs(132,22): warning CS0414: The field 'CardInfoController.allowEscBack' is assigned but its value is never used

The game is 2D and doesn’t use lighting. And this project has several “unused variables” but only ONE warning in the log complaining. If I comment it out, then a DIFFERENT “never used” variable ends up in the log as an error. But I’ve never seen this cause a build failure before. Usually errors with “warning” in them don’t also have a stacktrace in the log, but this one does.

This project builds to Windows and Android without issue.

Unity 2022.3.49
Tried building with Mac Sonoma, Ventura, Sonoma Experimental.
Tried with 15.2, 15.3, 15.4 and now trying with 16

No success and very strange.

I’m trying now with “Strict” turned off (but I’ve always had strict turned on for other iOS projects).

Hey @LilGames,

We were coincidentally investigating something similar earlier today and we believe it might’ve related to an editor bug in the strict setting that forces lightbaking to happen regardless of lightbaking being needed.

Can you try again with strict mode turned off. And if possible please use Xcode 16.0 / 16.1 and sonoma arm to benefit from the new apple silicon machines we have (you should see a performance boost on the arm editors which should reduce build minutes)

Update: we believe the issue was introduced in 2022.3.18f1, but we’re not certain and are checking with the editor team.

1 Like

No luck. Xcode 16.1, Mac Sonoma (experimental), Strict mode off, and “Clean Build”.

This resulted in many more errors than before, including a whole bunch related to the GoogleMobileAds package, such as:

[error] [2025-02-28T06:32:05Z - Unity] [AssemblyUpdater] Reference to method System.Void Google.PackageManagerClient/Error::.ctor(System.Object) ignored in IL_005c: newobj System.Void Google.PackageManagerClient/Error::.ctor(System.Object) (not a callsite)

[error] [2025-02-28T06:32:05Z - Unity] [AssemblyUpdater] Reference to method System.Void GoogleMobileAds.Android.AdErrorClient::.ctor(UnityEngine.AndroidJavaObject) ignored in IL_0016: newobj System.Void GoogleMobileAds.Android.AdErrorClient::.ctor(UnityEngine.AndroidJavaObject) (not a callsite)

Several repeated PhysX errors:

[error] [2025-02-28T06:33:01Z - Unity] Start importing Packages/com.unity.2d.animation/Editor/Assets/ComponentIcons/d_ErrorIcon_Small@2x.png using Guid(11e6f279ade864c6d951e8db74c11b54) Importer(-1,00000000000000000000000000000000) [PhysX] Initialized MultithreadedTaskDispatcher with 4 workers.

And the lightmapper error now appeared multiple times instead of just once:

[error] [2025-02-28T06:44:38Z - Unity] ERROR: Unable to fall back to CPU lightmapper.

By the way, should the minimum target iOS be higher than 12? I’ll try 13 now. [Edit: It failed]

@LilGames

I encountered this and was working with the UBA team trying to find the cause.

After making sure all lighting was removed from the game in question (confirmed by the log) it was still failing with the error you’re seeing above.

By any chance, are you seeing…

  1. Any [error] entries for [AssemblyUpdater] in your logs?
  2. Any [error] entries that end in ‘because it’s in an immutable folder’?

They were showing in my log on Silicon builds, but not Intel. That said, the API updater is disabled on Intel builds.

PS: My game was also 2D and targeting iOS 15.

No to both questions.

1 Like

Hi @LilGames

Could you create a ticket with the UBA team via DevOps > Help & Support > File a ticket ?
Or DM me the link to the failed build so we can take a closer look.

Following up here, since there was some private direct communications regarding this.

  1. The errors in the main logs were not the issue. I should have been looking in the additional “Xcode Logs” for deeper clues.

  2. In there, it was found that there was some old Google Play Services related files somehow in my project, despite not using GPS. Those referenced non-existent files.

  3. Deleting the two “GPGS” files and building with Xcode 16.1 solved the issue.

2 Likes

Thanks for the feedback @LilGames

I heard back from a Unity engineer as well and they’re confident my issue was a bug with the Silicon editor not honouring the strict mode setting correctly (which was enabled)

The potential fix is to temporarily disable strict mode, which I’ve yet to try. Alternatively switching to Intel also fixes the issue.

Regarding the Google Play Services files…

Were these part of the Unity\Google package that was once installed? Would you be able to list the file locations\names please, so others can check as well?

The Google files in question were legacy files that somehow didn’t delete when upgrading to the 9.6.0 Google Mobile Ads package. The files in question were:

/Assets/Plugins/IOS/GPGSAppController.h
/Assets/Plugins/IOS/GPGSAppController.mm

Deleting them was enough to resolve my issue.

Build was successful with these settings:

  • Unity version: Unity 2022.3.49f1
  • Builder OS and version: macOS Sonoma - Silicon (experimental)
  • XCode version: Xcode 16.1.0 (Experimental)
  • Unity Editor architecture: Apple-Silicon

I believe Strict Mode was OFF. I’ll be trying again later today with it ON.

UPDATE: It fails if strict is on. Due to Lightmapper errors.

1 Like

After disabling strict mode (as recommended by the Unity engineer) I finally managed a successful Silicon build last night. It was quicker than Intel, but not significantly.

I also found this (old) issue describing what appears to be the problem, so maybe this is a regression…

https://issuetracker.unity3d.com/issues/builds-in-strict-mode-fail-when-lightmapper-falls-back-to-cpu

1 Like