Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
include:
- name: Cocoa SDK
path: modules/sentry-cocoa.properties
path: modules/sentry-cocoa
- name: Java SDK
path: scripts/update-java.ps1
- name: Native SDK
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ test/**/*.apk
.sentry-native
**/EnvironmentVariables.g.cs

# Download cache for Cocoa SDK
modules/sentry-cocoa

# Local Claude Code settings that should not be committed
.claude/settings.local.json

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "modules/sentry-native"]
path = modules/sentry-native
url = https://github.com/getsentry/sentry-native.git
[submodule "modules/sentry-cocoa"]
path = modules/sentry-cocoa
url = https://github.com/getsentry/sentry-cocoa.git
16 changes: 5 additions & 11 deletions integration-test/ios.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(

$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.ApplicationException`""
# TODO: fix redundant SIGABRT (#3954)
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGABRT`"" } | Should -Throw
{ $result.Envelopes() | Should -HaveCount 1 } | Should -Throw
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`""
$result.Envelopes() | Should -HaveCount 1
}

It 'captures native crash (<configuration>)' {
Expand All @@ -112,7 +111,7 @@ Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(
}

$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"EXC_[A-Z_]+`""
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`""
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
$result.Envelopes() | Should -HaveCount 1
}
Expand All @@ -126,12 +125,7 @@ Describe 'iOS app (<tfm>, <configuration>)' -ForEach @(

$result.HasErrors() | Should -BeFalse
$result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`""
# TODO: fix redundant EXC_BAD_ACCESS in Release (#3954)
if ($configuration -eq 'Release') {
{ $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`"" } | Should -Throw
} else {
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"EXC_BAD_ACCESS`""
$result.Envelopes() | Should -HaveCount 1
}
$result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"(EXC_[A-Z_]+|SIG[A-Z]+)`""
$result.Envelopes() | Should -HaveCount 1
}
}
1 change: 1 addition & 0 deletions modules/sentry-cocoa
Submodule sentry-cocoa added at 3a22ec
2 changes: 1 addition & 1 deletion modules/sentry-cocoa.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 9.8.0
version = 9.10.0
repo = https://github.com/getsentry/sentry-cocoa
29 changes: 24 additions & 5 deletions scripts/build-sentry-cocoa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ set -euo pipefail
pushd "$(dirname "$0")" >/dev/null
cd ../modules/sentry-cocoa

rm -rf Carthage
mkdir -p Carthage
LOCK_DIR="$PWD/Carthage/.lock.d"

# Serialize concurrent invocations; parallel xcodebuilds race on DerivedData.
LOCK_HELD=0
trap 'if [[ $LOCK_HELD -eq 1 ]]; then rmdir "$LOCK_DIR" 2>/dev/null || true; fi' EXIT
while ! mkdir "$LOCK_DIR" 2>/dev/null; do
sleep 0.2
done
LOCK_HELD=1

if [[ -f Carthage/.built-from-sha ]] && [[ "$(cat Carthage/.built-from-sha)" == "$(git rev-parse HEAD)" ]]; then
popd >/dev/null
exit 0
fi

rm -rf Carthage/output-*.xcarchive Carthage/Build-* Carthage/Headers Carthage/.built-from-sha

# Grabbing the first SDK versions
sdks=$(xcodebuild -showsdks)
Expand All @@ -24,15 +40,17 @@ xcodebuild archive -project Sentry.xcodeproj \
-sdk "$ios_sdk" \
-archivePath ./Carthage/output-ios.xcarchive \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1'
./scripts/remove-architectures.sh ./Carthage/output-ios.xcarchive arm64e
xcodebuild archive -project Sentry.xcodeproj \
-scheme Sentry \
-configuration Release \
-sdk "$ios_simulator_sdk" \
-archivePath ./Carthage/output-iossimulator.xcarchive \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1'
xcodebuild -create-xcframework \
-framework ./Carthage/output-ios.xcarchive/Products/Library/Frameworks/Sentry.framework \
-framework ./Carthage/output-iossimulator.xcarchive/Products/Library/Frameworks/Sentry.framework \
Expand All @@ -47,7 +65,8 @@ xcodebuild archive -project Sentry.xcodeproj \
-destination 'generic/platform=macOS,variant=Mac Catalyst' \
-archivePath ./Carthage/output-maccatalyst.xcarchive \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SENTRY_CRASH_MANAGED_RUNTIME=1'
./scripts/remove-architectures.sh ./Carthage/output-maccatalyst.xcarchive arm64e
xcodebuild -create-xcframework \
-framework ./Carthage/output-maccatalyst.xcarchive/Products/Library/Frameworks/Sentry.framework \
Expand All @@ -62,7 +81,7 @@ find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Car
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
rm -rf Carthage/output-*

cp .git/HEAD Carthage/.built-from-sha
git rev-parse HEAD > Carthage/.built-from-sha
echo ""

popd >/dev/null
58 changes: 57 additions & 1 deletion src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using CoreGraphics;
using Foundation;
using ObjCRuntime;
using Sentry;
using UIKit;

namespace Sentry.CocoaSdk;
Expand Down Expand Up @@ -157,6 +156,10 @@
[NullAllowed, Export("replayId", ArgumentSemantic.Strong)]
string ReplayId { get; set; }

// @property (readonly, nonatomic) NSString * _Nullable orgId;
[NullAllowed, Export("orgId")]
string OrgId { get; }

// -(instancetype _Nonnull)initWithTraceId:(SentryId * _Nonnull)traceId publicKey:(NSString * _Nonnull)publicKey releaseName:(NSString * _Nullable)releaseName environment:(NSString * _Nullable)environment transaction:(NSString * _Nullable)transaction sampleRate:(NSString * _Nullable)sampleRate sampled:(NSString * _Nullable)sampled replayId:(NSString * _Nullable)replayId;
[Export("initWithTraceId:publicKey:releaseName:environment:transaction:sampleRate:sampled:replayId:")]
NativeHandle Constructor(SentryId traceId, string publicKey, [NullAllowed] string releaseName, [NullAllowed] string environment, [NullAllowed] string transaction, [NullAllowed] string sampleRate, [NullAllowed] string sampled, [NullAllowed] string replayId);
Expand All @@ -165,6 +168,10 @@
[Export("initWithTraceId:publicKey:releaseName:environment:transaction:sampleRate:sampleRand:sampled:replayId:")]
NativeHandle Constructor(SentryId traceId, string publicKey, [NullAllowed] string releaseName, [NullAllowed] string environment, [NullAllowed] string transaction, [NullAllowed] string sampleRate, [NullAllowed] string sampleRand, [NullAllowed] string sampled, [NullAllowed] string replayId);

// -(instancetype _Nonnull)initWithTraceId:(SentryId * _Nonnull)traceId publicKey:(NSString * _Nonnull)publicKey releaseName:(NSString * _Nullable)releaseName environment:(NSString * _Nullable)environment transaction:(NSString * _Nullable)transaction sampleRate:(NSString * _Nullable)sampleRate sampleRand:(NSString * _Nullable)sampleRand sampled:(NSString * _Nullable)sampled replayId:(NSString * _Nullable)replayId orgId:(NSString * _Nullable)orgId;
[Export("initWithTraceId:publicKey:releaseName:environment:transaction:sampleRate:sampleRand:sampled:replayId:orgId:")]
NativeHandle Constructor(SentryId traceId, string publicKey, [NullAllowed] string releaseName, [NullAllowed] string environment, [NullAllowed] string transaction, [NullAllowed] string sampleRate, [NullAllowed] string sampleRand, [NullAllowed] string sampled, [NullAllowed] string replayId, [NullAllowed] string orgId);

// -(NSString * _Nonnull)toHTTPHeaderWithOriginalBaggage:(NSDictionary * _Nullable)originalBaggage;
[Export("toHTTPHeaderWithOriginalBaggage:")]
string ToHTTPHeaderWithOriginalBaggage([NullAllowed] NSDictionary originalBaggage);
Expand Down Expand Up @@ -1367,6 +1374,10 @@
[NullAllowed, Export("replayId")]
string ReplayId { get; }

// @property (readonly, nonatomic) NSString * _Nullable orgId;
[NullAllowed, Export("orgId")]
string OrgId { get; }

// -(SentryBaggage * _Nonnull)toBaggage;
[Export("toBaggage")]
SentryBaggage ToBaggage();
Expand Down Expand Up @@ -1655,6 +1666,11 @@
[Static]
[Export("setLogOutput:")]
void SetLogOutput(Action<NSString> output);

// +(void)ignoreNextSignal:(int)signum;
[Static]
[Export("ignoreNextSignal:")]
void IgnoreNextSignal(int signum);
}

// @interface SentryOptions : NSObject
Expand Down Expand Up @@ -1752,7 +1768,7 @@

// @property (copy, nonatomic) void (^ _Nullable)(enum SentryLastRunStatus, SentryEvent * _Nullable) onLastRunStatusDetermined;
[NullAllowed, Export("onLastRunStatusDetermined", ArgumentSemantic.Copy)]
Action<SentryLastRunStatus, SentryEvent?> OnLastRunStatusDetermined { get; set; }

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1771 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// @property (nonatomic, strong) NSNumber * _Nullable sampleRate;
[NullAllowed, Export("sampleRate", ArgumentSemantic.Strong)]
Expand All @@ -1778,6 +1794,10 @@
[Export("attachStacktrace")]
bool AttachStacktrace { get; set; }

// @property (nonatomic) BOOL attachAllThreads;
[Export("attachAllThreads")]
bool AttachAllThreads { get; set; }

// @property (nonatomic) NSUInteger maxAttachmentSize;
[Export("maxAttachmentSize")]
nuint MaxAttachmentSize { get; set; }
Expand Down Expand Up @@ -1982,6 +2002,18 @@
[Export("spotlightUrl")]
string SpotlightUrl { get; set; }

// @property (nonatomic) BOOL strictTraceContinuation;
[Export("strictTraceContinuation")]
bool StrictTraceContinuation { get; set; }

// @property (copy, nonatomic) NSString * _Nullable orgId;
[NullAllowed, Export("orgId")]
string OrgId { get; set; }

// @property (readonly, copy, nonatomic) NSString * _Nullable effectiveOrgId;
[NullAllowed, Export("effectiveOrgId")]
string EffectiveOrgId { get; }

// @property (nonatomic, strong) SentryExperimentalOptions * _Nonnull experimental;
[Export("experimental", ArgumentSemantic.Strong)]
SentryExperimentalOptions Experimental { get; set; }
Expand Down Expand Up @@ -2124,6 +2156,10 @@
// -(NSURL * _Nonnull)getEnvelopeEndpoint __attribute__((warn_unused_result("")));
[Export("getEnvelopeEndpoint")]
NSUrl EnvelopeEndpoint { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable orgId;
[NullAllowed, Export("orgId")]
string OrgId { get; }
}

// @interface SentryExperimentalOptions : NSObject
Expand Down Expand Up @@ -2645,6 +2681,11 @@
[Export("captureEvent:withScopeBlock:")]
SentryId CaptureEvent(SentryEvent @event, Action<SentryScope> block);

// +(SentryId * _Nonnull)captureEvent:(SentryEvent * _Nonnull)event attachAllThreads:(BOOL)attachAllThreads;
[Static]
[Export("captureEvent:attachAllThreads:")]
SentryId CaptureEvent(SentryEvent @event, bool attachAllThreads);

// +(id<SentrySpan> _Nonnull)startTransactionWithName:(NSString * _Nonnull)name operation:(NSString * _Nonnull)operation;
[Static]
[Export("startTransactionWithName:operation:")]
Expand Down Expand Up @@ -2690,6 +2731,11 @@
[Export("captureError:withScopeBlock:")]
SentryId CaptureError(NSError error, Action<SentryScope> block);

// +(SentryId * _Nonnull)captureError:(NSError * _Nonnull)error attachAllThreads:(BOOL)attachAllThreads;
[Static]
[Export("captureError:attachAllThreads:")]
SentryId CaptureError(NSError error, bool attachAllThreads);

// +(SentryId * _Nonnull)captureException:(NSException * _Nonnull)exception;
[Static]
[Export("captureException:")]
Expand All @@ -2705,6 +2751,11 @@
[Export("captureException:withScopeBlock:")]
SentryId CaptureException(NSException exception, Action<SentryScope> block);

// +(SentryId * _Nonnull)captureException:(NSException * _Nonnull)exception attachAllThreads:(BOOL)attachAllThreads;
[Static]
[Export("captureException:attachAllThreads:")]
SentryId CaptureException(NSException exception, bool attachAllThreads);

// +(SentryId * _Nonnull)captureMessage:(NSString * _Nonnull)message;
[Static]
[Export("captureMessage:")]
Expand All @@ -2720,6 +2771,11 @@
[Export("captureMessage:withScopeBlock:")]
SentryId CaptureMessage(string message, Action<SentryScope> block);

// +(SentryId * _Nonnull)captureMessage:(NSString * _Nonnull)message attachAllThreads:(BOOL)attachAllThreads;
[Static]
[Export("captureMessage:attachAllThreads:")]
SentryId CaptureMessage(string message, bool attachAllThreads);

// +(void)captureFeedback:(SentryFeedback * _Nonnull)feedback;
[Static]
[Export("captureFeedback:")]
Expand Down
7 changes: 5 additions & 2 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<PropertyGroup Condition="Exists('$(SentryCocoaCache).git')">
<SentryCocoaFramework>$(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaCache)Carthage/.built-from-sha;$(SentryCocoaCache)Carthage/**/*.h</SentryCocoaBindingInputs>
<SentryCocoaGitFile>$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory), $(SentryCocoaCache).git))</SentryCocoaGitFile>
<SentryCocoaGitDir>$([System.IO.File]::ReadAllText('$(SentryCocoaGitFile)').Trim().Replace('gitdir: ', ''))</SentryCocoaGitDir>

Check warning on line 25 in src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj

View check run for this annotation

@sentry/warden / warden: find-bugs

Build fails when .git is a directory instead of a submodule file

Line 25 uses `System.IO.File::ReadAllText` to read `$(SentryCocoaCache).git`, but the condition on line 21 (`Exists('$(SentryCocoaCache).git')`) is true for both files and directories. If a developer has cloned sentry-cocoa directly into `modules/sentry-cocoa/` (not as a submodule), the `.git` path is a directory, and `File::ReadAllText` will throw an `UnauthorizedAccessException`, causing the MSBuild property evaluation to fail.
</PropertyGroup>

<!-- Build empty assemblies when not on macOS, to pass the solution build. -->
Expand Down Expand Up @@ -97,7 +99,7 @@
<!-- Build the Sentry Cocoa SDK from source -->
<Target Name="_BuildCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And Exists('$(SentryCocoaCache).git')"
Inputs="..\..\modules\sentry-cocoa\.git\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">
Inputs="$(SentryCocoaCache)$(SentryCocoaGitDir)\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">

<Message Importance="High" Text="Building the Cocoa SDK from source." />
<Exec Command="bash ../../scripts/build-sentry-cocoa.sh" IgnoreStandardErrorWarningFormat="true" />
Expand Down Expand Up @@ -125,7 +127,8 @@
Condition="$([MSBuild]::IsOSPlatform('OSX'))" />

<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
<RemoveDir Directories="$(SentryCocoaCache)Carthage;$(SentryCocoaFramework);$(SentryCocoaFrameworkHeaders)" ContinueOnError="true" />
<Delete Files="$(SentryCocoaFramework).zip;$(SentryCocoaFramework).sanitized.stamp" ContinueOnError="true" />
</Target>

<!-- Generate bindings -->
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Bindings.Cocoa/StructsAndEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;
using Sentry;

namespace Sentry.CocoaSdk;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ internal void Handle(object sender, MarshalManagedExceptionEventArgs e)

// This is likely a terminal exception so try to send the crash report before shutting down
_hub?.Flush();

// The Xamarin runtime will call abort() after this handler returns, which raises
// SIGABRT. Tell SentryCrash to ignore it on this thread so we don't get a duplicate
// native crash event for a managed exception we've already captured.
const int SIGABRT = 6;
SentryCocoaHybridSdk.IgnoreNextSignal(SIGABRT);
}
}
}
Loading