IL2CPP stripping still breaks NSData and other wrappers: the packages' link.xml files are ignored and most constructors lack [Preserve]
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start by tracing InteropReference.PointerCast<T> to ReflectionUtility.CreateInstanceOrDefault and inspect the (IntPtr) constructors listed for Apple.Core and Apple.GameKit. Check how Unity discovers package link.xml files through IUnityLinkerProcessor.GenerateAdditionalLinkXmlFile, then reproduce with the stated iOS IL2CPP setup at Managed Stripping Level Low. Done means every wrapper reachable through PointerCast survives stripping without an app supplied link.xml.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Wrapper objects are created through reflection (InteropReference.PointerCast<T> calls ReflectionUtility.CreateInstanceOrDefault, which looks up the (IntPtr) constructor). Nothing calls those constructors directly, so IL2CPP managed stripping (Low and up) removes them, and the fallback Activator.CreateInstance throws MissingMethodException: Default constructor not found for type ....
Each package ships a link.xml with preserve="all", but in our builds Unity never passes those files to UnityLinker. In our Unity 6000.6.4f1 player builds, the link.xml files it uses are the ones under Assets/ and the ones packages generate through IUnityLinkerProcessor (for example Library/com.unity.services.core/link.xml). The files inside com.apple.unityplugin.core and com.apple.unityplugin.gamekit are not among them, and neither is the one inside com.unity.nuget.newtonsoft-json.
Only 14 constructors have [Preserve] today, all in GameKit, most added by #73 for #61. These 35 don't (main, 96e4a04):
- Apple.Core: NSObject, NSData, NSString, NSError, NSException, NSNumber, NSNull, NSArray, NSArray, NSArrayInt64, NSArrayBoolean, NSArrayString, NSMutableArray, NSDictionary<TKey, TValue>, NSDictionary, NSDateComponents, Currency
- Apple.GameKit: GKLeaderboard, GKLeaderboard.Entry, GKLeaderboardScore, GKLeaderboardSet, GKScoreChallenge, GKInvite, GKMatch, GKMatchDelegate, GKMatchedPlayers, GKMatchmakerViewController, GKMatchmakerViewControllerDelegate, GKTurnBasedExchange, GKTurnBasedExchangeReply, GKTurnBasedMatch, GKTurnBasedMatchmakerViewController, GKTurnBasedMatchmakerViewControllerDelegate, GKTurnBasedParticipant, GKVoiceChat
NSData is the one most apps will hit: GKLocalPlayer.FetchItemsForIdentityVerificationSignature() builds its signature and salt with PointerCast<NSData>, so Game Center identity verification (used for server-side sign-in) fails. #54 tried to fix exactly that and was closed because #73 was expected to cover it, but #73 only changed GameKit. #128 hit the same NSData MissingMethodException in October and was closed after the reporter switched to Minimal stripping.
To Reproduce
- iOS project with Apple.Core and Apple.GameKit, IL2CPP, Managed Stripping Level Low, no link.xml of your own.
- Sign in to Game Center and call
GKLocalPlayer.Local.FetchItemsForIdentityVerificationSignature(). - MissingMethodException for
Apple.Core.Runtime.NSData.
Expected behavior
Every wrapper reachable through PointerCast survives stripping without each project adding its own link.xml.
Environment
Unity 6000.6.4f1, iOS, IL2CPP, Managed Stripping Level Low. Apple.Core 3.3.0 / Apple.GameKit 4.1.0 (27.0, ffe6174); also checked main (96e4a04). We haven't re-run this on 4.1.0 because our own link.xml prevents it; the NSData failure is the one #128 reports.
Additional context
Either register the shipped link.xml through IUnityLinkerProcessor.GenerateAdditionalLinkXmlFile (the way com.unity.services.core does), or put [Preserve] on every (IntPtr) constructor. Our workaround is a link.xml under Assets:
<linker>
<assembly fullname="Apple.Core" ignoreIfMissing="1" preserve="all" />
<assembly fullname="Apple.GameKit" ignoreIfMissing="1" preserve="all" />
</linker>
- Lenguaje dominante
- C#
- Estrellas
- 1k
- Forks
- 257
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apple/unityplugins
-
bug Plugin-in - Core
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
apple/unityplugins#132 ·
-
bug Plugin-in - Core
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
apple/unityplugins#131 · 1 asignado ·
-
bug Plugin-in - Core
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
apple/unityplugins#125 · 2 comentarios ·
-
Crash Issue On macOS 27 With Game KitPosiblemente ocupada @ryzngard la tomó hace 40 días. Abiertobug Plug-in - GameKit
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
apple/unityplugins#124 · 1 asignado ·
-
Arguments for Push Message localisation in SendExchange do not seem to workQuizá libre de nuevo @ryzngard la tomó hace 169 días y no hay ningún pull request abierto. Abiertobug Plug-in - GameKit
apple/unityplugins#98 · 2 comentarios · 1 asignado ·
Todos los issues de apple/unityplugins
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
area-ai untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/extensions#7956 ·
Los mantenedores suelen responder en 1 día
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
microsoft/microsoft-ui-reactor#1567 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
QuantConnect/Lean#10191 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
openclaw/openclaw-windows-node#2287 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día