Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 7 additions & 10 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ jobs:
if [[ "${TARGET}" == "Android" ]]; then
submodules="modules/sentry-java"
elif [[ "${TARGET}" == "Cocoa" ]]; then
submodules=""
submodules="modules/sentry-cocoa"
else
submodules="modules/sentry-native"
fi
echo "submodulesPath=$submodules" >> $GITHUB_OUTPUT
if [[ "$submodules" == "" ]]; then
echo "submodules=src/sentry-dotnet" >> $GITHUB_OUTPUT
else
echo "submodules=src/sentry-dotnet $submodules" >> $GITHUB_OUTPUT
fi
echo "submodules=src/sentry-dotnet $submodules" >> $GITHUB_OUTPUT

- name: Get submodule status
run: git submodule status --cached $SUBMODULES | tee submodules-status
Expand Down Expand Up @@ -66,7 +62,7 @@ jobs:
# hash of package/package.json for cache busting on release builds (version bump)
path: |
package-dev/Plugins
key: sdk=${{ env.TARGET }}-${{ hashFiles('submodules-status', 'package/package.json', 'Directory.Build.targets', 'sdk-static/**') }}${{ env.TARGET == 'Cocoa' && hashFiles('modules/sentry-cocoa.properties') || '' }}
key: sdk=${{ env.TARGET }}-${{ hashFiles('submodules-status', 'package/package.json', 'Directory.Build.targets', 'sdk-static/**', 'scripts/build-cocoa-sdk.ps1') }}

- name: Installing Linux Dependencies
if: ${{ env.TARGET == 'Linux' && steps.cache.outputs.cache-hit != 'true' }}
Expand Down Expand Up @@ -95,11 +91,12 @@ jobs:
run: dotnet msbuild /t:Build${{ env.TARGET }}SDK /p:Configuration=Release /p:OutDir=other src/Sentry.Unity

- name: Upload build logs on failure
# No build logs for Cocoa SDK as we assemble the xcframework from a downloaded release artifact
if: ${{ failure() && env.TARGET != 'Cocoa' }}
if: ${{ failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
path: ${{ steps.env.outputs.submodulesPath }}/build.log
path: |
${{ steps.env.outputs.submodulesPath }}/build.log
modules/sentry-cocoa/*.log
# Lower retention period - we only need this to retry CI.
retention-days: 14

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
include:
- name: Cocoa SDK
path: modules/sentry-cocoa.properties
path: modules/sentry-cocoa
- name: Java SDK
path: modules/sentry-java
- name: Native SDK
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ package-dev/Tests/Editor/TestFiles/
package-dev/Plugins/*/Sentry/crashpad_handler*

# Download cache for native SDKs
modules/sentry-cocoa
modules/sentry-native-ndk

# Adding .meta to control target platforms for all of our DLLs
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "modules/app-runner"]
path = modules/app-runner
url = https://github.com/getsentry/app-runner.git
[submodule "modules/sentry-cocoa"]
path = modules/sentry-cocoa
url = https://github.com/getsentry/sentry-cocoa.git
15 changes: 6 additions & 9 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<UnityTestEditModeResultFilePath>../../artifacts/test/editmode/results.xml</UnityTestEditModeResultFilePath>
<SentryArtifactsDestination>$(RepoRoot)package-dev/Plugins/</SentryArtifactsDestination>
<!-- Cocoa -->
<SentryCocoaCache>$(RepoRoot)modules/sentry-cocoa/</SentryCocoaCache>
<SentryCocoaRoot>$(RepoRoot)modules/sentry-cocoa/</SentryCocoaRoot>
<SentryiOSArtifactsDestination>$(SentryArtifactsDestination)iOS/Sentry.xcframework~/</SentryiOSArtifactsDestination>
<SentrymacOSArtifactsDestination>$(SentryArtifactsDestination)macOS/Sentry/</SentrymacOSArtifactsDestination>
<!-- Android -->
Expand Down Expand Up @@ -160,7 +160,7 @@ Expected to exist:
</Target>

<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
<RemoveDir Directories="$(SentryCocoaRoot)XCFrameworkBuildPath" ContinueOnError="true" />
<RemoveDir Directories="$(SentryiOSArtifactsDestination)" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" ContinueOnError="true" />
Expand Down Expand Up @@ -190,20 +190,17 @@ Expected to exist:
</Target>

<!-- Build the Cocoa SDK: dotnet msbuild /t:BuildCocoaSDK src/Sentry.Unity -->
<!-- Note: Not actually building the Cocoa SDK - yet. We're downloading the release artifact and extract for iOS and macOS -->
<!-- Builds the sentry-cocoa submodule from source and extracts iOS and macOS artifacts -->
<Target Name="BuildCocoaSDK"
Condition="!$([MSBuild]::IsOSPlatform('Windows')) AND '$(MSBuildProjectName)' == 'Sentry.Unity'
And (!Exists('$(SentryiOSArtifactsDestination)') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib'))"
BeforeTargets="BeforeBuild">

<PropertyGroup>
<PropertiesContent>$([System.IO.File]::ReadAllText("$(RepoRoot)modules/sentry-cocoa.properties"))</PropertiesContent>
<CocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'version\s*=\s*([^\s]+)').Groups[1].Value)</CocoaVersion>
</PropertyGroup>
<Error Condition="!Exists('$(SentryCocoaRoot)Sentry.xcodeproj')" Text="sentry-cocoa submodule not checked out at $(SentryCocoaRoot). Run: git submodule update --init modules/sentry-cocoa" />

<Message Importance="High" Text="Setting up the Cocoa SDK version '$(CocoaVersion)'." />
<Message Importance="High" Text="Building Cocoa SDK from submodule." />

<Exec Command="pwsh &quot;$(RepoRoot)scripts/setup-cocoa-sdk.ps1&quot; -RepoRoot &quot;$(RepoRoot)&quot; -CocoaVersion &quot;$(CocoaVersion)&quot; -CocoaCache &quot;$(SentryCocoaCache)&quot; -iOSDestination &quot;$(SentryiOSArtifactsDestination)&quot; -macOSDestination &quot;$(SentrymacOSArtifactsDestination)Sentry.dylib&quot;" />
<Exec Command="pwsh &quot;$(RepoRoot)scripts/build-cocoa-sdk.ps1&quot; -CocoaRoot &quot;$(SentryCocoaRoot)&quot; -iOSDestination &quot;$(SentryiOSArtifactsDestination)&quot; -macOSDestination &quot;$(SentrymacOSArtifactsDestination)Sentry.dylib&quot;" />

<Error Condition="(!Exists('$(SentryiOSArtifactsDestination)'))" Text="Failed to set up the iOS SDK." />
<Error Condition="(!Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM'))" Text="Failed to set up the macOS SDK." />
Expand Down
1 change: 1 addition & 0 deletions modules/sentry-cocoa
Submodule sentry-cocoa added at 05d3ce
2 changes: 0 additions & 2 deletions modules/sentry-cocoa.properties

This file was deleted.

117 changes: 117 additions & 0 deletions scripts/build-cocoa-sdk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env pwsh

param(
[Parameter(Mandatory = $true)]
[string]$CocoaRoot,

[Parameter(Mandatory = $true)]
[string]$iOSDestination,

[Parameter(Mandatory = $true)]
[string]$macOSDestination
)

Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true

if (-not (Test-Path (Join-Path $CocoaRoot "Sentry.xcodeproj"))) {
Write-Error "sentry-cocoa submodule not checked out at: $CocoaRoot`nRun: git submodule update --init modules/sentry-cocoa"
exit 1
}

# All build artifacts go under XCFrameworkBuildPath/ which is already in sentry-cocoa's .gitignore.
$buildPath = Join-Path $CocoaRoot "XCFrameworkBuildPath"
$iOSXcframeworkPath = Join-Path $buildPath "Sentry-Dynamic-iOS.xcframework"
$macOSXcframeworkPath = Join-Path $buildPath "Sentry-Dynamic-macOS.xcframework"

Write-Host "Building Cocoa SDK from source..." -ForegroundColor Yellow

Push-Location $CocoaRoot
try {
################ Build and set up iOS support ################

if (-not (Test-Path $iOSXcframeworkPath)) {
Write-Host "Building iOS xcframework..." -ForegroundColor Yellow
# Exclude arm64e from the binary. Since Xcode 26, apps without arm64e in the main binary
# can't include frameworks with arm64e slices (App Store rejection). The sentry-cocoa SDK
# ships separate "-WithARM64e" variants for apps that need it; Unity games don't.
& ./scripts/build-xcframework-variant.sh "Sentry" "-Dynamic" "mh_dylib" "" "iOSOnly" "arm64e"
& ./scripts/validate-xcframework-format.sh "Sentry-Dynamic.xcframework"
# build-xcframework-variant.sh outputs to the working directory — move into our build cache
Move-Item -Path "Sentry-Dynamic.xcframework" -Destination $iOSXcframeworkPath -Force
# Clean up intermediate archives, keep the final xcframework
$archivePath = Join-Path $buildPath "archive"
if (Test-Path $archivePath) {
Remove-Item -Path $archivePath -Recurse -Force
}
}

Write-Host "Setting up iOS frameworks..." -ForegroundColor Yellow

if (Test-Path $iOSDestination) {
Remove-Item -Path $iOSDestination -Recurse -Force
}

# Copy the xcframework as-is, including dSYMs. Since we build from source, the debug symbols
# won't be on Sentry's symbol server — they need to ship in the package so the Xcode build phase
# can upload them via sentry-cli, consistent with how all other native SDKs ship their debug symbols.
Copy-Item -Path $iOSXcframeworkPath -Destination $iOSDestination -Recurse -Force

$iOSInfoPlist = Join-Path $iOSDestination "Info.plist"
if (-not (Test-Path $iOSInfoPlist)) {
Write-Error "Failed to set up the iOS SDK."
exit 1
}
Write-Host "iOS SDK set up at: $iOSDestination" -ForegroundColor Green

################ Build and set up macOS support ################

if (-not (Test-Path $macOSXcframeworkPath)) {
Write-Host "Building macOS xcframework..." -ForegroundColor Yellow
& ./scripts/build-xcframework-variant.sh "Sentry" "-Dynamic" "mh_dylib" "" "macOSOnly" ""
& ./scripts/validate-xcframework-format.sh "Sentry-Dynamic.xcframework"
Move-Item -Path "Sentry-Dynamic.xcframework" -Destination $macOSXcframeworkPath -Force
# Clean up all remaining build intermediates
foreach ($dir in @("archive", "DerivedData")) {
$dirPath = Join-Path $buildPath $dir
if (Test-Path $dirPath) {
Remove-Item -Path $dirPath -Recurse -Force
}
}
}

Write-Host "Setting up macOS support..." -ForegroundColor Yellow

$macOSSlice = Get-ChildItem -Path $macOSXcframeworkPath -Directory | Where-Object { $_.Name -like "macos-*" } | Select-Object -First 1
if (-not $macOSSlice) {
Write-Error "No macOS slice found in xcframework at: $macOSXcframeworkPath"
exit 1
}
$macOSFrameworkPath = Join-Path $macOSSlice.FullName "Sentry.framework/Versions/A/Sentry"
$macOSdSYMPath = Join-Path $macOSSlice.FullName "dSYMs/Sentry.framework.dSYM/Contents/Resources/DWARF/Sentry"

$macOSDestDir = Split-Path $macOSDestination -Parent
if (-not (Test-Path $macOSDestDir)) {
New-Item -ItemType Directory -Path $macOSDestDir -Force | Out-Null
}

if (-not (Test-Path $macOSFrameworkPath)) {
Write-Error "macOS framework not found at: $macOSFrameworkPath"
exit 1
}
Copy-Item -Path $macOSFrameworkPath -Destination $macOSDestination -Force
Write-Host "Copied macOS dylib to: $macOSDestination" -ForegroundColor Green

$macOSdSYMDestination = "$macOSDestination.dSYM"
if (-not (Test-Path $macOSdSYMPath)) {
Write-Error "macOS dSYM not found at: $macOSdSYMPath"
exit 1
}
Copy-Item -Path $macOSdSYMPath -Destination $macOSdSYMDestination -Force
Write-Host "Copied macOS dSYM to: $macOSdSYMDestination" -ForegroundColor Green
} finally {
Pop-Location
}

Write-Host "Cocoa SDK build completed successfully!" -ForegroundColor Green
39 changes: 32 additions & 7 deletions scripts/download-native-sdks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,30 @@ $SDKs = @(
Destination = Join-Path $ArtifactsDestination "Android"
CheckDir = "Sentry~"
ExpectedFileCount = 4
},
@{
Name = "Cocoa"
Destination = $ArtifactsDestination
CheckFiles = @(
"iOS/Sentry.xcframework~/Info.plist",
"macOS/Sentry/Sentry.dylib"
)
}
)

function Test-SDKPresent {
param($SDK)

if ($SDK.ContainsKey('CheckFile')) {
if ($SDK.ContainsKey('CheckFiles')) {
foreach ($file in $SDK.CheckFiles) {
$checkPath = Join-Path $SDK.Destination $file
if (-not (Test-Path $checkPath)) {
return $false
}
}
return $true
}
elseif ($SDK.ContainsKey('CheckFile')) {
$checkPath = Join-Path $SDK.Destination $SDK.CheckFile
return Test-Path $checkPath
}
Expand Down Expand Up @@ -75,20 +92,28 @@ function Download-SDK {

Write-Host "Downloading $Name SDK..." -ForegroundColor Yellow

# Remove existing directory if present (partial download)
if (Test-Path $Destination) {
Write-Host " Removing existing directory..." -ForegroundColor Gray
Remove-Item -Path $Destination -Recurse -Force
$artifactName = "$Name-sdk"

# Download to a temp directory, then move contents into destination
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) "sentry-$Name-sdk-download"
if (Test-Path $tempDir) {
Remove-Item -Path $tempDir -Recurse -Force
}

$artifactName = "$Name-sdk"
gh run download $RunId -n $artifactName -D $Destination
gh run download $RunId -n $artifactName -D $tempDir

if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to download $Name SDK"
exit 1
}

# Move downloaded contents into the destination
if (-not (Test-Path $Destination)) {
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
}
Copy-Item -Path (Join-Path $tempDir "*") -Destination $Destination -Recurse -Force
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue

Write-Host " Downloaded $Name SDK successfully" -ForegroundColor Green
}

Expand Down
Loading
Loading