Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NullReferenceException on OnPreprocessBuild for iOS #2698

Closed
Zen12 opened this issue Oct 28, 2021 · 3 comments · Fixed by #2703
Closed

[Bug]: NullReferenceException on OnPreprocessBuild for iOS #2698

Zen12 opened this issue Oct 28, 2021 · 3 comments · Fixed by #2703
Assignees

Comments

@Zen12
Copy link

Zen12 commented Oct 28, 2021

What happened?

Export From Unity to XCode in order to build iOS

Repro steps

Import plugin -> Export to iOS

Version

10.6.0

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

What type of application is this?

Unity

Client OS and version

macOS

Code snippets

No response

Stacktrace of the exception/crash you're getting

NullReferenceException: Object reference not set to an instance of an object
RealmWeaver.UnityWeaver.UpdateiOSFrameworks (System.Boolean enableForDevice, System.Boolean enableForSimulator) (at <c7abea30eb38497497cc5dcbe1a89412>:0)
RealmWeaver.UnityWeaver.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at <c7abea30eb38497497cc5dcbe1a89412>:0)
UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass17_0.<OnBuildPostProcess>b__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:448)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:406)

NullReferenceException: Object reference not set to an instance of an object
RealmWeaver.UnityWeaver.UpdateiOSFrameworks (System.Boolean enableForDevice, System.Boolean enableForSimulator) (at <c7abea30eb38497497cc5dcbe1a89412>:0)
RealmWeaver.UnityWeaver.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at <c7abea30eb38497497cc5dcbe1a89412>:0)
UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass15_0.<OnBuildPreProcess>b__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:426)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:406)

Relevant log output

NullReferenceException: Object reference not set to an instance of an object
RealmWeaver.UnityWeaver.UpdateiOSFrameworks (System.Boolean enableForDevice, System.Boolean enableForSimulator) (at <c7abea30eb38497497cc5dcbe1a89412>:0)
@nirinchev
Copy link
Member

Hey, thanks for the report. Looking at the stacktrace, it appears we're failing to find one of our native frameworks:

var simulatorPath = "Packages/io.realm.unity/Runtime/iOS/realm-wrappers.xcframework/ios-arm64_i386_x86_64-simulator/realm-wrappers.framework";
var simulatorFrameworkImporter = (PluginImporter)PluginImporter.GetAtPath(simulatorPath);
simulatorFrameworkImporter.SetCompatibleWithPlatform(BuildTarget.iOS, enableForSimulator);
simulatorFrameworkImporter.SetPlatformData(BuildTarget.iOS, "AddToEmbeddedBinaries", enableForSimulator.ToString().ToLower());
var devicePath = "Packages/io.realm.unity/Runtime/iOS/realm-wrappers.xcframework/ios-arm64_armv7/realm-wrappers.framework";
var deviceFrameworkImporter = (PluginImporter)PluginImporter.GetAtPath(devicePath);
deviceFrameworkImporter.SetCompatibleWithPlatform(BuildTarget.iOS, enableForDevice);
deviceFrameworkImporter.SetPlatformData(BuildTarget.iOS, "AddToEmbeddedBinaries", enableForDevice.ToString().ToLower());

My guess is that the plugin importer is unable to find either the simulator or the device framework. Both paths are relative to your Unity root folder - can you double check that they exist in your project?

@nirinchev nirinchev self-assigned this Oct 28, 2021
@Zen12
Copy link
Author

Zen12 commented Oct 28, 2021

You are right, I installed it NOT from the package manager but the 'old' way. This is why the path was wrong. Thanks!

@Zen12 Zen12 closed this as completed Oct 28, 2021
@nirinchev
Copy link
Member

Thanks for confirming! I'll reopen this ticket though as we want to improve the DX here - either by being more lenient at figuring out the plugin location or by emitting a more meaningful error message.

@nirinchev nirinchev reopened this Oct 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants