Skip to content

Commit ff6ac2a

Browse files
github-actions[bot]web-flowjamescrosswell
authored
chore(deps): update Cocoa SDK to v9.8.0 (#5044)
* chore: update modules/sentry-cocoa.properties to 9.8.0 * Update API definitions * Fixed nullability * Fixed script to avoid dirty check failure --------- Co-authored-by: GitHub <noreply@github.com> Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
1 parent bcc6476 commit ff6ac2a

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ scripts/ # Build and maintenance scripts
8787
- **macOS only**. Requires Xcode.
8888
- `Sentry.Bindings.Cocoa` wraps the native Cocoa SDK.
8989
- Device tests run in CI only.
90+
- `src/Sentry.Bindings.Cocoa/ApiDefinitions.cs` and `StructsAndEnums.cs` are **auto-generated** — do not edit them directly. All changes must go in `scripts/patch-cocoa-bindings.cs` and be applied by running `scripts/generate-cocoa-bindings.ps1`.
9091

9192
### MAUI
9293
- Requires MAUI workloads: `sudo dotnet workload restore` (macOS/Linux) or `dotnet workload restore` (Windows).

modules/sentry-cocoa.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = 9.7.0
1+
version = 9.8.0
22
repo = https://github.com/getsentry/sentry-cocoa

scripts/patch-cocoa-bindings.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
.RemoveAttribute("PrivateSentrySDKOnly", "CaptureViewHierarchy", "NullAllowed")
7878
.WithAttribute("PrivateSentrySDKOnly", "CaptureScreenshots", "return: NullAllowed")
7979
.WithAttribute("PrivateSentrySDKOnly", "CaptureViewHierarchy", "return: NullAllowed")
80+
// Fix nullable property attributes
81+
.WithPropertyAttribute("SentryOptions", "OnCrashedLastRun", "NullAllowed")
82+
// Fix nullable generic type arguments
83+
.ChangePropertyType("SentryOptions", "OnLastRunStatusDetermined", "Action<SentryLastRunStatus, SentryEvent?>")
8084
// For PrivateApiDefinitions.cs
8185
.WithModifier("SentryScope", "partial")
8286
// error CS0246: The type or namespace name 'iOS' could not be found
@@ -309,6 +313,30 @@ public static CompilationUnitSyntax WithAttribute(
309313
return root.ReplaceNodes(nodes, (node, _) => node.WithAttribute(attribute));
310314
}
311315

316+
public static CompilationUnitSyntax WithPropertyAttribute(
317+
this CompilationUnitSyntax root,
318+
string type,
319+
string name,
320+
string attribute)
321+
{
322+
var nodes = root.DescendantNodes()
323+
.OfType<PropertyDeclarationSyntax>()
324+
.Where(node => node.Identifier.Matches(name) && node.HasParent(type) && !node.HasAttribute(attribute));
325+
return root.ReplaceNodes(nodes, (node, _) =>
326+
{
327+
var newAttr = SyntaxFactory.Attribute(SyntaxFactory.IdentifierName(attribute));
328+
if (node.AttributeLists.Count > 0)
329+
{
330+
// Prepend into the first existing attribute list (e.g. [NullAllowed, Export(...)])
331+
var first = node.AttributeLists[0];
332+
var prepended = first.WithAttributes(
333+
SyntaxFactory.SeparatedList(new[] { newAttr }.Concat(first.Attributes)));
334+
return node.WithAttributeLists(node.AttributeLists.Replace(first, prepended));
335+
}
336+
return (PropertyDeclarationSyntax)node.WithAttribute(attribute);
337+
});
338+
}
339+
312340
public static CompilationUnitSyntax AsInternal(
313341
this CompilationUnitSyntax root,
314342
string name,

src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ interface SentryBreadcrumb : SentrySerializable
213213
[NullAllowed, Export("origin")]
214214
string Origin { get; set; }
215215

216-
// @property (nonatomic, strong) NSDictionary<NSString *,id> * _Nullable data;
217-
[NullAllowed, Export("data", ArgumentSemantic.Strong)]
216+
// @property (copy, nonatomic) NSDictionary<NSString *,id> * _Nullable data;
217+
[NullAllowed, Export("data", ArgumentSemantic.Copy)]
218218
NSDictionary<NSString, NSObject> Data { get; set; }
219219

220220
// -(instancetype _Nonnull)initWithLevel:(SentryLevel)level category:(NSString * _Nonnull)category;
@@ -1746,10 +1746,14 @@ interface SentryOptions
17461746
[NullAllowed, Export("beforeCaptureViewHierarchy", ArgumentSemantic.Copy)]
17471747
SentryBeforeCaptureScreenshotCallback BeforeCaptureViewHierarchy { get; set; }
17481748

1749-
// @property (copy, nonatomic) SentryOnCrashedLastRunCallback _Nullable onCrashedLastRun;
1749+
// @property (copy, nonatomic) SWIFT_DEPRECATED_MSG("Use onLastRunStatusDetermined instead, which is called regardless of whether the app crashed.") SentryOnCrashedLastRunCallback onCrashedLastRun __attribute__((deprecated("Use onLastRunStatusDetermined instead, which is called regardless of whether the app crashed.")));
17501750
[NullAllowed, Export("onCrashedLastRun", ArgumentSemantic.Copy)]
17511751
SentryOnCrashedLastRunCallback OnCrashedLastRun { get; set; }
17521752

1753+
// @property (copy, nonatomic) void (^ _Nullable)(enum SentryLastRunStatus, SentryEvent * _Nullable) onLastRunStatusDetermined;
1754+
[NullAllowed, Export("onLastRunStatusDetermined", ArgumentSemantic.Copy)]
1755+
Action<SentryLastRunStatus, SentryEvent?> OnLastRunStatusDetermined { get; set; }
1756+
17531757
// @property (nonatomic, strong) NSNumber * _Nullable sampleRate;
17541758
[NullAllowed, Export("sampleRate", ArgumentSemantic.Strong)]
17551759
NSNumber SampleRate { get; set; }
@@ -2736,11 +2740,16 @@ interface SentrySDK
27362740
[Export("configureScope:")]
27372741
void ConfigureScope(Action<SentryScope> callback);
27382742

2739-
// @property (readonly, nonatomic, class) BOOL crashedLastRun;
2743+
// @property (readonly, nonatomic, class) BOOL crashedLastRun __attribute__((deprecated("Use lastRunStatus instead, which distinguishes between 'did not crash' and 'unknown'.")));
27402744
[Static]
27412745
[Export("crashedLastRun")]
27422746
bool CrashedLastRun { get; }
27432747

2748+
// @property (readonly, nonatomic, class) enum SentryLastRunStatus lastRunStatus;
2749+
[Static]
2750+
[Export("lastRunStatus")]
2751+
SentryLastRunStatus LastRunStatus { get; }
2752+
27442753
// @property (readonly, nonatomic, class) BOOL detectedStartUpCrash;
27452754
[Static]
27462755
[Export("detectedStartUpCrash")]

src/Sentry.Bindings.Cocoa/StructsAndEnums.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ internal enum SentryHttpStatusCode : long
122122
InternalServerError = 500
123123
}
124124

125+
[Native]
126+
internal enum SentryLastRunStatus : long
127+
{
128+
Unknown = 0,
129+
DidNotCrash = 1,
130+
DidCrash = 2
131+
}
132+
125133
[Native]
126134
internal enum SentryLogLevel : long
127135
{

0 commit comments

Comments
 (0)