Skip to content

Commit 79491f6

Browse files
authored
fix: Added missing method to iOS noop-bridge (#1983)
1 parent 4d4e2dd commit 79491f6

File tree

7 files changed

+65
-18
lines changed

7 files changed

+65
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- When targeting iOS and disabling native support, the SDK no longer causes builds to fail with an `Undefined symbol: _SentryNativeBridgeIsEnabled` error. ([#1983](https://github.com/getsentry/sentry-unity/pull/1983))
8+
59
### Dependencies
610

711
- Bump Native SDK from v0.7.18 to v0.7.19 ([#1981](https://github.com/getsentry/sentry-unity/pull/1981))

package-dev/Plugins/iOS/SentryNativeBridgeNoOp.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// macOS only
44
int SentryNativeBridgeLoadLibrary() { return 0; }
5+
int SentryNativeBridgeIsEnabled() { return 0; }
56
void *_Nullable SentryNativeBridgeOptionsNew() { return nil; }
67
void SentryNativeBridgeOptionsSetString(void *options, const char *name, const char *value) { }
78
void SentryNativeBridgeOptionsSetInt(void *options, const char *name, int32_t value) { }

src/Sentry.Unity.iOS/NativeScopeObserver.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
1111
var level = GetBreadcrumbLevel(breadcrumb.Level);
1212
var timestamp = GetTimestamp(breadcrumb.Timestamp);
1313

14-
SentryCocoaBridgeProxy.SentryNativeBridgeAddBreadcrumb(timestamp, breadcrumb.Message, breadcrumb.Type, breadcrumb.Category, level);
14+
SentryCocoaBridgeProxy.AddBreadcrumb(timestamp, breadcrumb.Message, breadcrumb.Type, breadcrumb.Category, level);
1515
}
1616

1717
public override void SetExtraImpl(string key, string? value) =>
18-
SentryCocoaBridgeProxy.SentryNativeBridgeSetExtra(key, value);
18+
SentryCocoaBridgeProxy.SetExtra(key, value);
1919

20-
public override void SetTagImpl(string key, string value) => SentryCocoaBridgeProxy.SentryNativeBridgeSetTag(key, value);
20+
public override void SetTagImpl(string key, string value) => SentryCocoaBridgeProxy.SetTag(key, value);
2121

22-
public override void UnsetTagImpl(string key) => SentryCocoaBridgeProxy.SentryNativeBridgeUnsetTag(key);
22+
public override void UnsetTagImpl(string key) => SentryCocoaBridgeProxy.UnsetTag(key);
2323

2424
public override void SetUserImpl(SentryUser user) =>
25-
SentryCocoaBridgeProxy.SentryNativeBridgeSetUser(user.Email, user.Id, user.IpAddress, user.Username);
25+
SentryCocoaBridgeProxy.SetUser(user.Email, user.Id, user.IpAddress, user.Username);
2626

27-
public override void UnsetUserImpl() => SentryCocoaBridgeProxy.SentryNativeBridgeUnsetUser();
27+
public override void UnsetUserImpl() => SentryCocoaBridgeProxy.UnsetUser();
2828

2929
internal static string GetTimestamp(DateTimeOffset timestamp) =>
3030
// "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
using System.Runtime.CompilerServices;
22

33
[assembly: InternalsVisibleTo("Sentry.Unity.iOS.Tests")]
4+
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.iOS.Tests")]

src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ public static bool Init(SentryUnityOptions options)
8888
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeClose")]
8989
public static extern void Close();
9090

91-
[DllImport("__Internal")]
92-
public static extern void SentryNativeBridgeAddBreadcrumb(string timestamp, string? message, string? type, string? category, int level);
91+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeAddBreadcrumb")]
92+
public static extern void AddBreadcrumb(string timestamp, string? message, string? type, string? category, int level);
9393

94-
[DllImport("__Internal")]
95-
public static extern void SentryNativeBridgeSetExtra(string key, string? value);
94+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeSetExtra")]
95+
public static extern void SetExtra(string key, string? value);
9696

97-
[DllImport("__Internal")]
98-
public static extern void SentryNativeBridgeSetTag(string key, string value);
97+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeSetTag")]
98+
public static extern void SetTag(string key, string value);
9999

100-
[DllImport("__Internal")]
101-
public static extern void SentryNativeBridgeUnsetTag(string key);
100+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeUnsetTag")]
101+
public static extern void UnsetTag(string key);
102102

103-
[DllImport("__Internal")]
104-
public static extern void SentryNativeBridgeSetUser(string? email, string? userId, string? ipAddress, string? username);
103+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeSetUser")]
104+
public static extern void SetUser(string? email, string? userId, string? ipAddress, string? username);
105105

106-
[DllImport("__Internal")]
107-
public static extern void SentryNativeBridgeUnsetUser();
106+
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeUnsetUser")]
107+
public static extern void UnsetUser();
108108

109109
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeGetInstallationId")]
110110
public static extern string GetInstallationId();

test/Sentry.Unity.Editor.iOS.Tests/Sentry.Unity.Editor.iOS.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<ProjectReference Include="../../src/sentry-dotnet/src/Sentry/Sentry.csproj" Private="false" />
1414
<ProjectReference Include="../../src/Sentry.Unity/Sentry.Unity.csproj" Private="false" />
15+
<ProjectReference Include="../../src/Sentry.Unity.iOS/Sentry.Unity.iOS.csproj" Private="false" />
1516
<ProjectReference Include="../../src/Sentry.Unity.Editor/Sentry.Unity.Editor.csproj" Private="false" />
1617
<ProjectReference Include="../../src/Sentry.Unity.Editor.iOS/Sentry.Unity.Editor.iOS.csproj" Private="false" />
1718
</ItemGroup>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Linq;
2+
using System.Reflection;
3+
using System.Runtime.InteropServices;
4+
using System.Text.RegularExpressions;
5+
using NUnit.Framework;
6+
using Sentry.Unity.iOS;
7+
8+
namespace Sentry.Unity.Editor.iOS.Tests
9+
{
10+
public class SentryNativeBridgeTests
11+
{
12+
[Test]
13+
public void EntryPoints_ExistInNativeBridges()
14+
{
15+
var entryPoints = typeof(SentryCocoaBridgeProxy)
16+
.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)
17+
.Where(method => method.GetCustomAttribute<DllImportAttribute>() != null)
18+
.Select(method => method.GetCustomAttribute<DllImportAttribute>().EntryPoint)
19+
.ToList();
20+
21+
Assert.That(entryPoints, Is.Not.Empty); // Sanity check
22+
23+
const string? bridgePath = "../../package-dev/Plugins/iOS/SentryNativeBridge.m";
24+
const string? noOpBridgePath = "../../package-dev/Plugins/iOS/SentryNativeBridgeNoOp.m";
25+
26+
var bridgeContent = System.IO.File.ReadAllText(bridgePath);
27+
var noOpBridgeContent = System.IO.File.ReadAllText(noOpBridgePath);
28+
29+
foreach (var entryPoint in entryPoints)
30+
{
31+
var pattern = $@"{entryPoint}\s*\(";
32+
33+
Assert.That(Regex.IsMatch(bridgeContent, pattern),
34+
$"Entry point '{entryPoint}' not found in {bridgePath}");
35+
Assert.That(Regex.IsMatch(noOpBridgeContent, pattern),
36+
$"Entry point '{entryPoint}' not found in {noOpBridgePath}");
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)