@@ -103,7 +103,8 @@ if (!(Test-Path '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/
103103}
104104
105105# Get iPhone SDK version
106- $iPhoneSdkVersion = sharpie xcode - sdks | grep - o - m 1 ' iphoneos\S*'
106+ $XcodePath = (xcode- select - p) -replace ' /Contents/Developer$' , ' '
107+ $iPhoneSdkVersion = sharpie xcode - xcode $XcodePath - sdks | grep - o - m 1 ' iphoneos\S*'
107108Write-Output " iPhoneSdkVersion: $iPhoneSdkVersion "
108109
109110# # Imports in the various header files are provided in the "new" style of:
@@ -141,12 +142,30 @@ else
141142{
142143 Write-Host " File not found: $privateHeaderFile "
143144}
145+ $swiftHeaderFile = " $HeadersPath /Sentry-Swift.h"
146+ if (Test-Path $swiftHeaderFile )
147+ {
148+ $content = Get-Content - Path $swiftHeaderFile - Raw
149+ # Replace module @imports with traditional #includes
150+ $content = $content -replace ' (?m)^#if\s+(__has_feature\(objc_modules\))' , ' #if 1 // $1'
151+ $content = $content -replace ' (?m)^@import\s+ObjectiveC;\s*\n' , ' '
152+ $content = $content -replace ' (?m)^@import\s+(\w+);' , ' #include <$1/$1.h>'
153+ $content = $content -replace ' (?m)^#import\s+"Sentry.h"\s*\n' , ' '
154+
155+ Set-Content - Path $swiftHeaderFile - Value $content
156+ Write-Host " Patched includes: $swiftHeaderFile "
157+ }
158+ else
159+ {
160+ Write-Host " File not found: $swiftHeaderFile "
161+ }
144162
145163# Generate bindings
146164Write-Output ' Generating bindings with Objective Sharpie.'
147165sharpie bind - sdk $iPhoneSdkVersion `
148166 - scope " $CocoaSdkPath " `
149167 " $HeadersPath /Sentry.h" `
168+ " $HeadersPath /Sentry-Swift.h" `
150169 " $PrivateHeadersPath /PrivateSentrySDKOnly.h" `
151170 - o $BindingsPath `
152171 - c - Wno- objc- property- no- attribute
@@ -214,8 +233,9 @@ $Text = $Text -replace 'using .+;\n\n', "$&namespace Sentry.CocoaSdk;`n`n"
214233# Set Internal attributes on interfaces and delegates
215234$Text = $Text -replace ' (?m)^(partial interface|interface|delegate)\b' , " [Internal]`n $&"
216235
217- # Fix ISentrySerializable usage
236+ # Fix interface usage
218237$Text = $Text -replace ' \bISentrySerializable\b' , ' SentrySerializable'
238+ $Text = $Text -replace ' \bISentryRedactOptions\b' , ' SentryRedactOptions'
219239
220240# Remove INSCopying due to https://github.com/xamarin/xamarin-macios/issues/17130
221241$Text = $Text -replace ' : INSCopying,' , ' :' -replace ' \s?[:,] INSCopying' , ' '
@@ -235,16 +255,21 @@ $Text = $Text -replace '(SentryBreadcrumb) arg\d', '$1 breadcrumb'
235255$Text = $Text -replace ' (SentrySpan) arg\d' , ' $1 span'
236256$Text = $Text -replace ' (SentryAppStartMeasurement) arg\d' , ' $1 appStartMeasurement'
237257$Text = $Text -replace ' (SentryLog) arg\d' , ' $1 log'
258+ $Text = $Text -replace ' (SentryProfileOptions) arg\d' , ' $1 options'
238259
239260# Adjust nullable return delegates (though broken until this is fixed: https://github.com/xamarin/xamarin-macios/issues/17109)
240261$Text = $Text -replace ' delegate \w+ Sentry(BeforeBreadcrumb|BeforeSendEvent|TracesSampler)Callback' , " [return: NullAllowed]`n $&"
241262
263+ # Rename SentryRRWebEvent protocol
264+ $Text = $Text -replace ' interface (SentryRRWebEvent) : SentrySerializable' , ' interface I$1 : SentrySerializable'
265+
242266# Adjust protocols (some are models)
243267$Text = $Text -replace ' (?ms)(@protocol.+?)/\*.+?\*/' , ' $1'
244268$Text = $Text -replace ' (?ms)@protocol (SentrySerializable|SentrySpan).+?\[Protocol\]' , " `$ &`n [Model]"
269+ $Text = $Text -replace ' (?ms)@protocol (SentryRedactOptions).+?\[Protocol \(Name = \"\w+\"\)\]' , " `$ &`n [Model]"
245270
246- # Adjust SentrySpan base type
247- $Text = $Text -replace ' interface SentrySpan\b' , " [BaseType (typeof(NSObject))]`n`$ &"
271+ # Adjust base types
272+ $Text = $Text -replace ' interface ( SentrySpan|SentryRedactOptions) \b' , " [BaseType (typeof(NSObject))]`n`$ &"
248273
249274# Fix string constants
250275$Text = $Text -replace ' (?m)(.*\n){2}^\s{4}NSString k.+?\n\n?' , ' '
@@ -279,9 +304,6 @@ $Text = $Text -replace '\s*\[Verify \(StronglyTypedNSArray\)\]\n', ''
279304$Text = $Text -replace ' (DEPRECATED_MSG_ATTRIBUTE\()\n\s*' , ' $1'
280305$Text = $Text -replace ' (DEPRECATED_MSG_ATTRIBUTE\([^)]*?)"\s*\r?\n\s*"' , ' $1 '
281306
282- # Remove default IsEqual implementation (already implemented by NSObject)
283- $Text = $Text -replace ' (?ms)\n?^ *// [^\n]*isEqual:.*?$.*?;\n' , ' '
284-
285307# Replace obsolete platform availability attributes
286308$Text = $Text -replace ' ([\[,] )MacCatalyst \(' , ' $1Introduced (PlatformName.MacCatalyst, '
287309$Text = $Text -replace ' ([\[,] )Mac \(' , ' $1Introduced (PlatformName.MacOSX, '
@@ -290,24 +312,15 @@ $Text = $Text -replace '([\[,] )iOS \(', '$1Introduced (PlatformName.iOS, '
290312# Make interface partial if we need to access private APIs. Other parts will be defined in PrivateApiDefinitions.cs
291313$Text = $Text -replace ' (?m)^interface SentryScope' , ' partial $&'
292314
293- $Text = $Text -replace ' .*SentryEnvelope .*?[\s\S]*?\n\n' , ' '
294315$Text = $Text -replace ' .*typedef.*SentryOnAppStartMeasurementAvailable.*?[\s\S]*?\n\n' , ' '
295-
296- $propertiesToRemove = @ (
297- ' SentryAppStartMeasurement' ,
298- ' SentryOnAppStartMeasurementAvailable' ,
299- ' SentryMetricsAPI' ,
300- ' SentryExperimentalOptions' ,
301- ' description' ,
302- ' enableMetricKitRawPayload'
303- )
304-
305- foreach ($property in $propertiesToRemove )
306- {
307- $Text = $Text -replace " \n.*property.*$property .*?[\s\S]*?\}\n" , ' '
308- }
309-
316+ $Text = $Text -replace ' NSDictionary<NSString, SentryStructuredLogAttribute>' , ' NSDictionary<NSString, NSObject>'
310317
311318# Add header and output file
312319$Text = " $Header `n`n $Text "
313320$Text | Out-File " $BindingsPath /$File "
321+
322+ # ###############################################################################
323+ # Post-process ApiDefinitions.cs
324+ # ###############################################################################
325+ Write-Output " Post-processing $BindingsPath /$File "
326+ & dotnet run -- project " $RootPath /tools/Sentry.Bindings.Cocoa.PostProcessor/Sentry.Bindings.Cocoa.PostProcessor.csproj" -- " $BindingsPath /$File " | ForEach-Object { Write-Host $_ }
0 commit comments