IL2CPP stripping still breaks NSData and other wrappers: the packages' link.xml files are ignored and most constructors lack [Preserve]
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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>
- 主要語言
- C#
- 星號
- 1k
- 分支
- 257
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apple/unityplugins 的其他 Issue
-
bug Plugin-in - Core
難度 4/5 3-5 天 新手友好度 55/100
apple/unityplugins#132 ·
-
bug Plugin-in - Core
難度 3/5 1-2 天 新手友好度 65/100
apple/unityplugins#131 · 已指派 1 人 ·
-
bug Plugin-in - Core
難度 4/5 3-5 天 新手友好度 55/100
apple/unityplugins#125 · 2 則留言 ·
-
Crash Issue On macOS 27 With Game Kit可能已有人在做 @ryzngard 於 40 天前認領。 未關閉bug Plug-in - GameKit
難度 4/5 3-5 天 新手友好度 35/100
apple/unityplugins#124 · 已指派 1 人 ·
-
Arguments for Push Message localisation in SendExchange do not seem to work可能重新可做 @ryzngard 於 169 天前認領,目前沒有進行中的 PR。 未關閉bug Plug-in - GameKit
apple/unityplugins#98 · 2 則留言 · 已指派 1 人 ·
查看 apple/unityplugins 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
area-ai untriaged
難度 2/5 1-3 小時 新手友好度 78/100
dotnet/extensions#7956 ·
維護者通常 1 天內回覆
-
bug needs-triage
難度 2/5 1-3 小時 新手友好度 67/100
microsoft/microsoft-ui-reactor#1567 ·
維護者通常 1 天內回覆
-
priority:p2
難度 2/5 1-3 小時 新手友好度 82/100
QuantConnect/Lean#10191 · 1 則留言 ·
維護者通常 1 天內回覆
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
難度 2/5 1-3 小時 新手友好度 76/100
openclaw/openclaw-windows-node#2287 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆