Skip to content

Commit b0da650

Browse files
bitsandfoxesimatwawanabruno-garcia
authored
feat(unity): Added automation snippet to troubleshooting (#5039)
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
1 parent 82f87e4 commit b0da650

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/platforms/unity/troubleshooting.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ The `Sentry.Unity.Editor.iOS.dll` is responsible for adding native support to yo
3737

3838
## Build Issues
3939

40+
### Disabling the Sentry SDK for selected platforms
41+
42+
By adding the snippet below to an `Editor` directory inside your Unity project, you can set up the ability to automatically disable the Sentry SDK for any targeted platform.
43+
44+
```csharp
45+
using Sentry.Unity;
46+
using UnityEditor;
47+
using UnityEditor.Build;
48+
using UnityEditor.Build.Reporting;
49+
50+
public class PreBuildProcessor : IPreprocessBuildWithReport
51+
{
52+
public int callbackOrder => 0;
53+
54+
public void OnPreprocessBuild(BuildReport report)
55+
{
56+
if (report.summary.platform is BuildTarget.Android)
57+
{
58+
var sentryOptions =
59+
AssetDatabase.LoadAssetAtPath<ScriptableSentryUnityOptions>("Assets/Resources/Sentry/SentryOptions.asset");
60+
sentryOptions.Enabled = false;
61+
EditorUtility.SetDirty(sentryOptions);
62+
}
63+
}
64+
}
65+
```
66+
4067
### Build input file cannot be found: '**/Libraries/io.sentry.unity/Plugins/iOS/SentryNativeBridge.m'
4168

4269
You can resolve this issue by creating a clean build or chosing "Replace" when prompted. Alternatively, you can remove the unused `SentryNativeBridge.m`from the **UnityFramework Target > Compile Sources** in the project settings. Instead of relying on Unity to copy the `SentryNativeBridge.m` over to the generated Xcode project, starting with 0.12.0, the SDK copies it manually to `**/Libraries/io.sentry.unity/SentryNativeBridge.m`.

0 commit comments

Comments
 (0)