From 0d4e77f50b499ad16dfba9c646220f628d0a7470 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 22 Sep 2025 13:40:11 +0200 Subject: [PATCH 1/5] build: allow local `modules/sentry-cocoa` clone for development --- scripts/build-sentry-cocoa.sh | 4 +-- scripts/generate-cocoa-bindings.ps1 | 22 ++++++++++++---- .../Sentry.Bindings.Cocoa.csproj | 25 +++++++++++++++---- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/scripts/build-sentry-cocoa.sh b/scripts/build-sentry-cocoa.sh index 95247e281f..ebc16d35b0 100755 --- a/scripts/build-sentry-cocoa.sh +++ b/scripts/build-sentry-cocoa.sh @@ -54,13 +54,13 @@ echo "::endgroup::" # Copy headers - used for generating bindings mkdir Carthage/Headers -find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Carthage/Headers \; +find Carthage/Build-ios/Sentry.xcframework/ios-arm64_arm64e -name '*.h' -exec cp {} Carthage/Headers \; # Remove anything we don't want to bundle in the nuget package. find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} + rm -rf Carthage/output-* -cp ../../.git/modules/modules/sentry-cocoa/HEAD Carthage/.built-from-sha +cp .git/HEAD Carthage/.built-from-sha echo "" popd >/dev/null diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index eb1295808e..f91b32f4c7 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -4,7 +4,19 @@ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $RootPath = (Get-Item $PSScriptRoot).Parent.FullName -$CocoaSdkPath = "$RootPath/modules/sentry-cocoa/Sentry.framework" +$CocoaSdkPath = "$RootPath/modules/sentry-cocoa" +if (Test-Path "$CocoaSdkPath/.git") +{ + # Cocoa SDK cloned to modules/sentry-cocoa for local development + $HeadersPath = "$CocoaSdkPath/Carthage/Headers" + $PrivateHeadersPath = "$CocoaSdkPath/Carthage/Headers" +} +else +{ + # Cocoa SDK downloaded from GitHub releases and extracted into modules/sentry-cocoa + $HeadersPath = "$CocoaSdkPath/Sentry.framework/Headers" + $PrivateHeadersPath = "$CocoaSdkPath/Sentry.framework/PrivateHeaders" +} $BindingsPath = "$RootPath/src/Sentry.Bindings.Cocoa" $BackupPath = "$BindingsPath/obj/_unpatched" @@ -101,7 +113,7 @@ Write-Output "iPhoneSdkVersion: $iPhoneSdkVersion" # ...instead of: # `#import "SomeHeader.h"` # This causes sharpie to fail resolve those headers -$filesToPatch = Get-ChildItem -Path "$CocoaSdkPath/Headers" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName +$filesToPatch = Get-ChildItem -Path "$HeadersPath" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName foreach ($file in $filesToPatch) { if (Test-Path $file) @@ -116,7 +128,7 @@ foreach ($file in $filesToPatch) Write-Host "File not found: $file" } } -$privateHeaderFile = "$CocoaSdkPath/PrivateHeaders/PrivatesHeader.h" +$privateHeaderFile = "$PrivateHeadersPath/PrivatesHeader.h" if (Test-Path $privateHeaderFile) { $content = Get-Content -Path $privateHeaderFile -Raw @@ -134,8 +146,8 @@ else Write-Output 'Generating bindings with Objective Sharpie.' sharpie bind -sdk $iPhoneSdkVersion ` -scope "$CocoaSdkPath" ` - "$CocoaSdkPath/Headers/Sentry.h" ` - "$CocoaSdkPath/PrivateHeaders/PrivateSentrySDKOnly.h" ` + "$HeadersPath/Sentry.h" ` + "$PrivateHeadersPath/PrivateSentrySDKOnly.h" ` -o $BindingsPath ` -c -Wno-objc-property-no-attribute diff --git a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj index 98e6fde2d2..244c61f305 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -11,7 +11,8 @@ $(SentryCocoaCache)Sentry.framework\ $([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties")) $([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value) - $(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework + $(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework + $(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework $(NoWarn);CS0108 @@ -52,8 +53,8 @@ - + @@ -84,6 +85,20 @@ SkipUnchangedFiles="true" /> + + + + + + + + + + From ae1e60660276166d56db40273a0d195ea185ac40 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 22 Sep 2025 16:09:44 +0200 Subject: [PATCH 2/5] Drop redundant !Exists('$(SentryCocoaFramework)') checks To allow rebuilding sentry-cocoa in local development mode when a locally built .xcframework already exists. --- src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj index 244c61f305..7fd3108c60 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -54,7 +54,7 @@ + Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaCache).git') And !Exists('$(SentryCocoaFramework)')"> @@ -87,7 +87,7 @@ @@ -97,16 +97,16 @@ + Condition="$([MSBuild]::IsOSPlatform('OSX'))" /> + Condition="$([MSBuild]::IsOSPlatform('OSX'))"> From 03e08fb7bfc544b04e00201287ee212f27e37687 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 23 Sep 2025 09:47:08 +0200 Subject: [PATCH 3/5] Update modules/README.md --- modules/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/README.md b/modules/README.md index 3a5d31fdf2..176b23f553 100644 --- a/modules/README.md +++ b/modules/README.md @@ -15,3 +15,13 @@ To make sure we're not exposing any API from that library externally. Fork [getsentry/perfview](https://github.com/getsentry/perfview/). Tool from the .NET team which includes several utilities used for profiling .NET code. We use that in our `Sentry.Profiling` package. + +### sentry-cocoa + +By default, `Sentry.Bindings.Cocoa` downloads a pre-built Sentry Cocoa SDK from +GitHub Releases. The version is specified in `sentry-cocoa.properties`. + +If you want to build an unreleased Sentry Cocoa SDK version from source instead, +replace the pre-built SDK with [getsentry/sentry-cocoa](https://github.com/getsentry/sentry-cocoa/) +by cloning it into the `modules/sentry-cocoa` directory. To switch back to the +pre-built SDK, delete the `modules/sentry-cocoa` directory. From 0bc185016867126e627703f45ed75e77253db2fd Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 23 Sep 2025 14:12:32 +0200 Subject: [PATCH 4/5] Fix path to .git\HEAD --- src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj index 7fd3108c60..3b434575de 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -88,7 +88,7 @@ + Inputs="..\..\modules\sentry-cocoa\.git\HEAD" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha"> From 05bd4cf6af938ff78c54368aad0651db8a1efa94 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 24 Sep 2025 13:40:21 +0200 Subject: [PATCH 5/5] Fix _BuildCocoaSDK and _GenerateSentryCocoaBindings inputs --- .../Sentry.Bindings.Cocoa.csproj | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj index 3b434575de..860b0f2db4 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -11,12 +11,18 @@ $(SentryCocoaCache)Sentry.framework\ $([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties")) $([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value) - $(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework - $(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework + $(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework + ../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1 $(NoWarn);CS0108 + + + $(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework + ../../scripts/generate-cocoa-bindings.ps1;../../modules/sentry-cocoa/Carthage/.built-from-sha + + @@ -88,7 +94,7 @@ + Inputs="..\..\modules\sentry-cocoa\.git\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha"> @@ -118,7 +124,7 @@