diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 78d0b1ab7a..cf6582a782 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,3 +171,26 @@ Once changes to Ben.Demystifier have been merged into the main branch then, the should be updated from the main branch and the `modules/make-internal.sh` script run again (if necessary). This repo should reference the most recent commit on the `internal` branch of Ben.Demystifier then (functionally identical to the main branch - the only difference being the changes to member visibility). + +## Local Sentry Cocoa SDK checkout + +By default, `Sentry.Bindings.Cocoa` downloads a pre-built Sentry Cocoa SDK from +GitHub Releases. The version is specified in `modules/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: + +```sh +$ rm -rf modules/sentry-cocoa +$ gh repo clone getsentry/sentry-cocoa modules/sentry-cocoa +$ dotnet build ... # uses modules/sentry-cocoa as is +``` + +To switch back to the pre-built SDK, delete the `modules/sentry-cocoa` directory +and let the next build download the pre-built SDK again: + +```sh +$ rm -rf modules/sentry-cocoa +$ dotnet build ... # downloads pre-built Cocoa SDK into modules/sentry-cocoa +``` diff --git a/scripts/build-sentry-cocoa.sh b/scripts/build-sentry-cocoa.sh index 95247e281f..55dbdbde6e 100755 --- a/scripts/build-sentry-cocoa.sh +++ b/scripts/build-sentry-cocoa.sh @@ -25,6 +25,7 @@ xcodebuild archive -project Sentry.xcodeproj \ -archivePath ./Carthage/output-ios.xcarchive \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES +./scripts/remove-architectures.sh ./Carthage/output-ios.xcarchive arm64e xcodebuild archive -project Sentry.xcodeproj \ -scheme Sentry \ -configuration Release \ @@ -47,6 +48,7 @@ xcodebuild archive -project Sentry.xcodeproj \ -archivePath ./Carthage/output-maccatalyst.xcarchive \ SKIP_INSTALL=NO \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES +./scripts/remove-architectures.sh ./Carthage/output-maccatalyst.xcarchive arm64e xcodebuild -create-xcframework \ -framework ./Carthage/output-maccatalyst.xcarchive/Products/Library/Frameworks/Sentry.framework \ -output ./Carthage/Build-maccatalyst/Sentry.xcframework @@ -60,7 +62,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/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..860b0f2db4 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -12,10 +12,17 @@ $([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 + ../../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 + + @@ -52,8 +59,8 @@ - + @@ -84,14 +91,28 @@ SkipUnchangedFiles="true" /> + + + + + + + + + + + Condition="$([MSBuild]::IsOSPlatform('OSX'))"> @@ -102,8 +123,8 @@