Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
with:
name: ${{ env.TARGET }}-sdk
path: |
package-dev/Plugins/iOS/Sentry.xcframework~
package-dev/Plugins/iOS/SentryObjC.xcframework~
package-dev/Plugins/macOS/Sentry~
# Lower retention period - we only need this to retry CI.
retention-days: 14
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

## Unreleased

### Fixes

- Migrated the native support for iOS and macOS to use the Obj-C flavour of `sentry-cocoa` ([#2767](https://github.com/getsentry/sentry-unity/pull/2767))

### Dependencies

- Bump Cocoa SDK from v9.21.0 to v9.22.0 ([#2767](https://github.com/getsentry/sentry-unity/pull/2767))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#9220)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/9.21.0...9.22.0)
- Bump .NET SDK from v6.5.0-33-g0140be0a to v6.7.0 ([#2761](https://github.com/getsentry/sentry-unity/pull/2761), [#2762](https://github.com/getsentry/sentry-unity/pull/2762))
- [changelog](https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md#670)
- [diff](https://github.com/getsentry/sentry-dotnet/compare/6.5.0-33-g0140be0a...6.7.0)
Expand Down
2 changes: 1 addition & 1 deletion build/native-sdks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- Cocoa -->
<SentryCocoaRoot>$(RepoRoot)modules/sentry-cocoa/</SentryCocoaRoot>
<SentryiOSArtifactsDestination>$(SentryArtifactsDestination)iOS/Sentry.xcframework~/</SentryiOSArtifactsDestination>
<SentryiOSArtifactsDestination>$(SentryArtifactsDestination)iOS/SentryObjC.xcframework~/</SentryiOSArtifactsDestination>
<SentrymacOSArtifactsDestination>$(SentryArtifactsDestination)macOS/Sentry~/</SentrymacOSArtifactsDestination>
<SentryMacOSNativeArtifactsDestination>$(SentryArtifactsDestination)macOS/SentryNative~/</SentryMacOSNativeArtifactsDestination>

Expand Down
2 changes: 1 addition & 1 deletion modules/sentry-cocoa
Submodule sentry-cocoa updated 174 files
59 changes: 24 additions & 35 deletions package-dev/Plugins/iOS/SentryNativeBridge.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#import <Sentry/Sentry.h>
#import <MetricKit/MetricKit.h>
#import <Sentry/Sentry-Swift.h>
#import <Sentry/PrivateSentrySDKOnly.h>
#import <Sentry/SentryOptionsInternal.h>
#import <SentryObjC/SentryObjC.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -43,7 +40,7 @@
// On iOS, the SDK is linked statically so we don't need to dlopen() it.
int SentryNativeBridgeLoadLibrary() { return 1; }

int SentryNativeBridgeIsEnabled() { return [SentrySDK isEnabled] ? 1 : 0; }
int SentryNativeBridgeIsEnabled() { return [SentryObjCSDK isEnabled] ? 1 : 0; }

const void *SentryNativeBridgeOptionsNew()
{
Expand Down Expand Up @@ -80,32 +77,32 @@ void SentryNativeBridgeOptionsAddFailedRequestStatusCodeRange(const void *option
ranges = [[NSMutableArray alloc] init];
dictOptions[@"failedRequestStatusCodes"] = ranges;
}
[ranges addObject:[[SentryHttpStatusCodeRange alloc] initWithMin:min max:max]];
[ranges addObject:[[SentryObjCHttpStatusCodeRange alloc] initWithMin:min max:max]];
}

int SentryNativeBridgeStartWithOptions(const void *options)
{
NSMutableDictionary *dictOptions = (__bridge_transfer NSMutableDictionary *)options;
NSError *error = nil;

SentryOptions *sentryOptions = [SentryOptionsInternal initWithDict:dictOptions didFailWithError:&error];
SentryObjCOptions *sentryOptions = [[SentryObjCSDK internal] optionsFromDictionary:dictOptions error:&error];
if (error != nil)
{
return 0;
}

[SentrySDK startWithOptions:sentryOptions];
[SentryObjCSDK startWithOptions:sentryOptions];
return 1;
}

void SentryNativeBridgeSetSdkName()
{
[PrivateSentrySDKOnly performSelector:@selector(setSdkName:) withObject:@"sentry.cocoa.unity"];
[SentryObjCSDK internal].sdk.name = @"sentry.cocoa.unity";
}

int SentryNativeBridgeCrashedLastRun() { return [SentrySDK crashedLastRun] ? 1 : 0; }
int SentryNativeBridgeCrashedLastRun() { return [SentryObjCSDK crashedLastRun] ? 1 : 0; }

void SentryNativeBridgeClose() { [SentrySDK close]; }
void SentryNativeBridgeClose() { [SentryObjCSDK close]; }

void SentryNativeBridgeAddBreadcrumb(const char *timestamp, const char *message, const char *type,
const char *category, int level, const char **dataKeys, const char **dataValues, int dataCount)
Expand All @@ -119,8 +116,8 @@ void SentryNativeBridgeAddBreadcrumb(const char *timestamp, const char *message,
NSString *typeString = _NSStringOrNil(type);
NSString *categoryString = _NSStringOrNil(category) ?: @"default"; // Category cannot be nil

[SentrySDK configureScope:^(SentryScope *scope) {
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc]
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
SentryObjCBreadcrumb *breadcrumb = [[SentryObjCBreadcrumb alloc]
initWithLevel:level
category:categoryString];

Expand Down Expand Up @@ -164,7 +161,7 @@ void SentryNativeBridgeSetExtra(const char *key, const char *value)
NSString *keyString = [NSString stringWithUTF8String:key];
NSString *valueString = _NSStringOrNil(value);

[SentrySDK configureScope:^(SentryScope *scope) {
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
[scope setExtraValue:valueString forKey:keyString];
}];
}
Expand All @@ -178,7 +175,7 @@ void SentryNativeBridgeSetTag(const char *key, const char *value)
NSString *keyString = [NSString stringWithUTF8String:key];
NSString *valueString = _NSStringOrNil(value);

[SentrySDK configureScope:^(SentryScope *scope) {
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
[scope setTagValue:valueString forKey:keyString];
}];
}
Expand All @@ -191,7 +188,7 @@ void SentryNativeBridgeUnsetTag(const char *key)

NSString *keyString = [NSString stringWithUTF8String:key];

[SentrySDK configureScope:^(SentryScope *scope) {
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
[scope removeTagForKey:keyString];
}];
}
Expand All @@ -204,8 +201,8 @@ void SentryNativeBridgeSetUser(
NSString *ipAddressString = _NSStringOrNil(ipAddress);
NSString *usernameString = _NSStringOrNil(username);

[SentrySDK configureScope:^(SentryScope *scope) {
SentryUser *user = [[SentryUser alloc] init];
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
SentryObjCUser *user = [[SentryObjCUser alloc] init];

user.email = emailString;
user.userId = userIdString;
Expand All @@ -218,14 +215,14 @@ void SentryNativeBridgeSetUser(

void SentryNativeBridgeUnsetUser()
{
[SentrySDK configureScope:^(SentryScope *scope) { [scope setUser:nil]; }];
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) { [scope setUser:nil]; }];
}

char *SentryNativeBridgeGetInstallationId()
{
// Create a null terminated C string on the heap as expected by marshalling.
// See Tips for iOS in https://docs.unity3d.com/Manual/PluginsForIOS.html
const char *nsStringUtf8 = [[PrivateSentrySDKOnly installationID] UTF8String];
const char *nsStringUtf8 = [[SentryObjCSDK internal].sdk.installationID UTF8String];
size_t len = strlen(nsStringUtf8) + 1;
char *cString = (char *)malloc(len);
memcpy(cString, nsStringUtf8, len);
Expand All @@ -241,17 +238,11 @@ void SentryNativeBridgeSetTrace(const char *traceId, const char *spanId)
NSString *traceIdStr = [NSString stringWithUTF8String:traceId];
NSString *spanIdStr = [NSString stringWithUTF8String:spanId];

// This is a workaround to deal with SentryId living inside the Swift header
Class sentryIdClass = NSClassFromString(@"SentryId");
Class sentrySpanIdClass = NSClassFromString(@"SentrySpanId");
SentryObjCId *sentryTraceId = [[SentryObjCId alloc] initWithUUIDString:traceIdStr];
SentryObjCSpanId *sentrySpanId = [[SentryObjCSpanId alloc] initWithValue:spanIdStr];

if (sentryIdClass && sentrySpanIdClass) {
id sentryTraceId = [[sentryIdClass alloc] initWithUUIDString:traceIdStr];
id sentrySpanId = [[sentrySpanIdClass alloc] initWithValue:spanIdStr];

if (sentryTraceId && sentrySpanId) {
[PrivateSentrySDKOnly setTrace:sentryTraceId spanId:sentrySpanId];
}
if (sentryTraceId && sentrySpanId) {
[[SentryObjCSDK internal] setTrace:sentryTraceId spanId:sentrySpanId];
}
}

Expand Down Expand Up @@ -292,7 +283,7 @@ void SentryNativeBridgeWriteScope( // clang-format off
) // clang-format on
{
// Note: we're using a NSMutableDictionary because it will skip fields with nil values.
[SentrySDK configureScope:^(SentryScope *scope) {
[SentryObjCSDK configureScope:^(SentryObjCScope *scope) {
NSMutableDictionary *gpu = [[NSMutableDictionary alloc] init];
gpu[@"id"] = _NSNumberOrNil(GpuId);
gpu[@"name"] = _NSStringOrNil(GpuName);
Expand All @@ -309,17 +300,15 @@ void SentryNativeBridgeWriteScope( // clang-format off
gpu[@"vendor_id"] = _NSStringOrNil(GpuVendorId);
gpu[@"multi_threaded_rendering"] = _NSBoolOrNil(GpuMultiThreadedRendering);
gpu[@"graphics_shader_level"] = _NSStringOrNil(GpuGraphicsShaderLevel);
[scope performSelector:@selector(setContextValue:forKey:) withObject:gpu withObject:@"gpu"];
[scope setContextValue:gpu forKey:@"gpu"];

NSMutableDictionary *unity = [[NSMutableDictionary alloc] init];
unity[@"editor_version"] = _NSStringOrNil(EditorVersion);
unity[@"install_mode"] = _NSStringOrNil(UnityInstallMode);
unity[@"target_frame_rate"] = _NSStringOrNil(UnityTargetFrameRate);
unity[@"copy_texture_support"] = _NSStringOrNil(UnityCopyTextureSupport);
unity[@"rendering_threading_mode"] = _NSStringOrNil(UnityRenderingThreadingMode);
[scope performSelector:@selector(setContextValue:forKey:)
withObject:unity
withObject:@"unity"];
[scope setContextValue:unity forKey:@"unity"];
}];
}

Expand Down
Loading
Loading