-
Notifications
You must be signed in to change notification settings - Fork 247
Fix OnApplicationStart DllNotFoundException in Unity Editor for Windows - #42
Fix OnApplicationStart DllNotFoundException in Unity Editor for Windows #42Pomdap wants to merge 1 commit into
Conversation
* Microsoft's Unity linter asked me to fix this. * Reorganizing some calls and order of operations for two reasons: - Compatibility with Unity's batchmode - Avoid interactions with the Asset Database while it's in an undefined state - defer to `OnPostprocessAllAssets` * Unity project version bump. * I feel like this is pretty close to what it needs to be. I'll test it out tomorrow - but currently it works in just the local Apple.Core Unity project. I'll go through various builds in both Editor and Batch mode builds to check. * Addressing review feedback and cleaning up some comment formatting here and there. * No gelpers allowed. * Version bump. * Tested with the following and works: - Built all plug-ins - Created new project and imported Apple.Core and the GameKit plug-ins - Built in the Editor for iPad, generated Xcode project works as expected - Built on command line with batch mode, generated Xcode project works as expected. --------- Co-authored-by: Adam Szofran <aszofran@apple.com>
AdamSzApple
commented
Jan 17, 2025
Hopefully this issue is fixed by Apple.Core 3.1.7, merged on January 7. Thanks for bringing it to our attention. Please reopen this PR if issues remain.
Niezoor
commented
Jan 21, 2025
This issue still persists in Apple.Core 3.1.7 and Apple.GameKit 3.0.1
AdamSzApple
commented
Jan 21, 2025
Reopened. Thanks for letting us know.
LovePiktiv
commented
Feb 3, 2025
I thought I would mention that this also occurs in the GameKit package as well. The DefaultHandlers.cs file has two classes, DefaultNSExceptionHandler and DefaultNSErrorHandler. They each have an Init() function that cause DllNotFoundExceptions on the Windows editor upon entering play mode.
Solution: Much the same as Pomdap's pull request, I think you can solve it by wrapping each of those functions with ifdefs to exclude it from non-MacOS editors like this:
#if UNITY_EDITOR_OSX || (!UNITY_EDITOR && (UNITY_IOS || UNITY_TVOS || UNITY_STANDALONE_OSX || UNITY_VISIONOS))
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
public static void Init()
{
Interop.DefaultNSErrorHandler_Set(ThrowNSError);
}
#endif
This is with Core 3.1.8 and GameKit 3.0.2.
I'm not super familiar with Git but I can try to make another pull request if that would be helpful.
TeorikDeli
commented
Oct 24, 2025
I think the issue still exits, this is the log from Windows Unity Editor:
Apple.GameKit.DefaultNSErrorHandler.Init () (at ./Library/PackageCache/com.apple.unityplugin.gamekit@1be1d3078587/Source/DefaultHandlers.cs:35)
DllNotFoundException: GameKitWrapper assembly:<unknown assembly> type:<unknown type> member:(null)
Apple.GameKit.DefaultNSExceptionHandler.Init () (at ./Library/PackageCache/com.apple.unityplugin.gamekit@1be1d3078587/Source/DefaultHandlers.cs:14)
DllNotFoundException: AppleCoreNativeMac assembly:<unknown assembly> type:<unknown type> member:(null)
Apple.Core.Availability.get_RuntimeEnvironment () (at ./Library/PackageCache/com.apple.unityplugin.core@006751853658/Runtime/Availability.cs:15)
Apple.Core.Availability.OnApplicationStart () (at ./Library/PackageCache/com.apple.unityplugin.core@006751853658/Runtime/Availability.cs:206)```
kuoliangkwong
commented
Dec 18, 2025
I'm getting the same error posted by @TeorikDeli
Apple.GameKit.DefaultNSErrorHandler.Init () (at ./Library/PackageCache/com.apple.unityplugin.gamekit@8b212a4da6ba/Source/DefaultHandlers.cs:35)
DllNotFoundException: GameKitWrapper assembly:<unknown assembly> type:<unknown type> member:(null)
Apple.GameKit.DefaultNSExceptionHandler.Init () (at ./Library/PackageCache/com.apple.unityplugin.gamekit@8b212a4da6ba/Source/DefaultHandlers.cs:14)
DllNotFoundException: AppleCoreNativeMac assembly:<unknown assembly> type:<unknown type> member:(null)
Apple.Core.Availability.get_RuntimeEnvironment () (at ./Library/PackageCache/com.apple.unityplugin.core@86ecff2f8683/Runtime/Availability.cs:15)
Apple.Core.Availability.OnApplicationStart () (at ./Library/PackageCache/com.apple.unityplugin.core@86ecff2f8683/Runtime/Availability.cs:206)
I also noticed the commit is about Availability.cs only. I think we need to cover DefaultHandlers.cs as well.
Running in Windows. Apple Gamekit 3.0.2 with Apple Core 3.1.8.
Issue
When starting the Unity Editor on Windows while using AppleUnityPlugins, we get the following error:
Expected behaviour
We should not get any Error in the Editor.
Fix
Add ifdef around the Dll imported methods.