Skip to content
Merged
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
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ jobs:
path: package-dev/Plugins/Android
wait-timeout: 3600

- name: Download Cocoa SDK
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
with:
name: Cocoa-sdk
path: package-dev/Plugins
wait-timeout: 3600

- name: Download Linux SDK
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
with:
Expand All @@ -88,7 +95,7 @@ jobs:
wait-timeout: 3600

- name: Build Sentry.Unity Solution
run: docker exec unity dotnet build -c Release
run: docker exec unity dotnet build -c Release -v:d

- name: Install assemblyalias
run: docker exec unity dotnet tool install --global Alias --version 0.4.3 --allow-roll-forward
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
host: ubuntu-latest
- target: Windows
host: windows-latest
- target: Cocoa
host: macos-latest
uses: ./.github/workflows/sdk.yml
with:
target: ${{ matrix.target }}
Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,27 @@ jobs:
run: |
if [[ "${TARGET}" == "Android" ]]; then
submodules="modules/sentry-java"
elif [[ "${TARGET}" == "Cocoa" ]]; then
submodules=""
else
submodules="modules/sentry-native"
fi

echo "submodulesPath=$submodules" >> $GITHUB_OUTPUT
echo "submodules=src/sentry-dotnet $submodules" >> $GITHUB_OUTPUT

if [[ "$submodules" == "" ]]; then
echo "submodules=src/sentry-dotnet" >> $GITHUB_OUTPUT
else
echo "submodules=src/sentry-dotnet $submodules" >> $GITHUB_OUTPUT
fi
- name: Get submodule status
run: git submodule status --cached ${{ steps.env.outputs.submodules }} | tee submodules-status

- run: cp -r package-dev/Plugins/${{ env.TARGET }} sdk-static || echo "never mind, no files checked in..."
- run: |
if [[ "${{ env.TARGET }}" == "Cocoa" ]]; then
cp -r package-dev/Plugins/iOS sdk-static/ || echo "never mind, no iOS files checked in..."
cp -r package-dev/Plugins/macOS sdk-static/ || echo "never mind, no macOS files checked in..."
else
cp -r package-dev/Plugins/${{ env.TARGET }} sdk-static || echo "never mind, no files checked in..."
fi
shell: bash

- name: Restore from cache
Expand Down Expand Up @@ -92,14 +102,26 @@ jobs:
dotnet msbuild /t:Build${{ env.TARGET }}SDK /p:Configuration=Release /p:OutDir=other src/Sentry.Unity

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

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ env.TARGET == 'Cocoa' }}
with:
name: ${{ env.TARGET }}-sdk
path: |
package-dev/Plugins/iOS
package-dev/Plugins/macOS
# Lower retention period - we only need this to retry CI.
retention-days: 14

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ env.TARGET != 'Cocoa' }}
with:
name: ${{ env.TARGET }}-sdk
path: package-dev/Plugins/${{ env.TARGET }}
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## Unreleased

### Fixes

- For targeting iOS, the Unity SDK now brings an iOS-only `.xcframework`, reducing package size. ([#2264](https://github.com/getsentry/sentry-unity/pull/2264))

### Dependencies

- Bump Java SDK from v8.17.0 to v8.18.0 ([#2261](https://github.com/getsentry/sentry-unity/pull/2261))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8180)
- [diff](https://github.com/getsentry/sentry-java/compare/8.17.0...8.18.0)
- Bump .NET SDK from v5.12.0-14-g25a894dd to v5.13.0 ([#2259](https://github.com/getsentry/sentry-unity/pull/2259))
- Bump .NET SDK from v5.12.0 to v5.13.0 ([#2259](https://github.com/getsentry/sentry-unity/pull/2259))
- [changelog](https://github.com/getsentry/sentry-dotnet/blob/main/CHANGELOG.md#5130)
- [diff](https://github.com/getsentry/sentry-dotnet/compare/5.12.0-14-g25a894dd...5.13.0)

Expand Down
33 changes: 5 additions & 28 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ Expected to exist:
</Target>

<!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:SetupCocoaSDK src/Sentry.Unity -->
<Target Name="SetupCocoaSDK"
<!-- Note: This target is now handled by CI for official builds, but kept for local development -->
<Target Name="BuildCocoaSDK"
Condition="!$([MSBuild]::IsOSPlatform('Windows')) AND '$(MSBuildProjectName)' == 'Sentry.Unity'
And (!Exists('$(SentryiOSArtifactsDestination)') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib'))"
BeforeTargets="BeforeBuild">
Expand All @@ -197,34 +198,9 @@ Expected to exist:

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

<!-- Clean cache if version does not exist to get rid of old versions -->
<RemoveDir
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Directories="$(SentryCocoaCache)" />

<!-- Create cache directory -->
<MakeDir Condition="!Exists('$(SentryCocoaCache)')" Directories="$(SentryCocoaCache)" />

<!-- Download the Cocoa SDK as pre-built .xcframework -->
<Exec
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Command="curl -L https://github.com/getsentry/sentry-cocoa/releases/download/$(CocoaVersion)/Sentry-Dynamic.xcframework.zip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip" />
<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
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')"
Command="unzip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip -d $(SentryCocoaCache)" />

<!-- Set up the iOS support -->
<ItemGroup>
<!-- Itemgroup for the output Sentry.framework so we have access to '%(RecursiveDir)' when copying -->
<xcframeworkdPath Include="$(SentryCocoaCache)/Sentry-Dynamic.xcframework/**/*" />
</ItemGroup>
<Copy SourceFiles="@(xcframeworkdPath)" DestinationFiles="@(xcframeworkdPath->'$(SentryiOSArtifactsDestination)%(RecursiveDir)%(Filename)%(Extension)')" />
<Error Condition="(!Exists('$(SentryiOSArtifactsDestination)'))" Text="Failed to set up the iOS SDK." />

<!-- Set up the macOS support -->
<Copy SourceFiles="$(SentryCocoaCache)Sentry-Dynamic.xcframework/macos-arm64_arm64e_x86_64/Sentry.framework/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib" />
<Copy SourceFiles="$(SentryCocoaCache)Sentry-Dynamic.xcframework/macos-arm64_arm64e_x86_64/dSYMs/Sentry.framework.dSYM/Contents/Resources/DWARF/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" />
<Error Condition="(!Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM'))" Text="Failed to set up the macOS SDK." />
</Target>

Expand Down Expand Up @@ -601,6 +577,7 @@ void PrintFailedTests(XElement element)
<SDK Include="Windows"/>
<SDK Include="Android"/>
<SDK Include="Linux"/>
<SDK Include="Cocoa"/>
</ItemGroup>
<Message Importance="High" Text="Replacing $(SentryArtifactsDestination)%(SDK.Identity)" />
<RemoveDir Directories="$(SentryArtifactsDestination)%(SDK.Identity)" />
Expand All @@ -610,4 +587,4 @@ void PrintFailedTests(XElement element)
<Message Importance="High" Text="Restoring package-dev/Plugins to the latest git commit" />
<Exec WorkingDirectory="$(RepoRoot)" Command="git restore package-dev/Plugins" />
</Target>
</Project>
</Project>
147 changes: 147 additions & 0 deletions scripts/setup-cocoa-sdk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env pwsh

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

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

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

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

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

[switch]$iOSOnly
)

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

# Clean cache if version does not exist to get rid of old versions
$zipFile = Join-Path $CocoaCache "Sentry-Dynamic-$CocoaVersion.xcframework.zip"
if (-not (Test-Path $zipFile)) {
Write-Host "Cleaning cache directory for new version..." -ForegroundColor Yellow
if (Test-Path $CocoaCache) {
Remove-Item -Path $CocoaCache -Recurse -Force
}
}

if (-not (Test-Path $CocoaCache)) {
New-Item -ItemType Directory -Path $CocoaCache -Force | Out-Null
}

if (-not (Test-Path $zipFile)) {
Write-Host "Downloading Cocoa SDK version '$CocoaVersion'..." -ForegroundColor Yellow
$downloadUrl = "https://github.com/getsentry/sentry-cocoa/releases/download/$CocoaVersion/Sentry-Dynamic.xcframework.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipFile
}

$xcframeworkPath = Join-Path $CocoaCache "Sentry-Dynamic.xcframework"
if (-not (Test-Path $xcframeworkPath)) {
Write-Host "Extracting xcframework..." -ForegroundColor Yellow
Expand-Archive -Path $zipFile -DestinationPath $CocoaCache -Force
}

################ Set up iOS support ################
# We strip out the iOS frameworks and create a new xcframework out of those.

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

$iOSFrameworks = Get-ChildItem -Path $xcframeworkPath -Directory | Where-Object { $_.Name -like "ios-*" -and $_.Name -notlike "*maccatalyst*" }
if ($iOSFrameworks.Count -eq 0) {
Write-Error "No iOS frameworks found in xcframework at: $xcframeworkPath"
exit 1
}

Write-Host "Found $($iOSFrameworks.Count) iOS frameworks:" -ForegroundColor Green
foreach ($framework in $iOSFrameworks) {
Write-Host " - $($framework.Name)" -ForegroundColor Cyan
}

$xcodebuildArgs = @("-create-xcframework")

foreach ($framework in $iOSFrameworks) {
$frameworkPath = Join-Path $framework.FullName "Sentry.framework"
if (Test-Path $frameworkPath) {
$xcodebuildArgs += "-framework"
$xcodebuildArgs += $frameworkPath
Write-Host "Adding framework: $frameworkPath" -ForegroundColor Cyan
} else {
Write-Warning "Framework not found at: $frameworkPath"
}
}

# Remove the ~ suffix from destination. xcodebuild requires the output path to end with `.xcframework`
$xcframeworkDestination = $iOSDestination.TrimEnd('~', '/')

$xcodebuildArgs += "-output"
$xcodebuildArgs += $xcframeworkDestination

Write-Host "Creating iOS-only xcframework..." -ForegroundColor Yellow
Write-Host "Command: xcodebuild $($xcodebuildArgs -join ' ')" -ForegroundColor Gray

try {
& xcodebuild @xcodebuildArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "xcodebuild failed with exit code: $LASTEXITCODE"
exit 1
}
Write-Host "Successfully created iOS-only xcframework at: $xcframeworkDestination" -ForegroundColor Green
} catch {
Write-Error "Failed to run xcodebuild: $($_.Exception.Message)"
exit 1
}

Write-Host "Appending '~' for Unity to ignore the framework"
Move-Item -Path $xcframeworkDestination -Destination $iOSDestination -Force

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

################ Set up macOS support ################
# We copy the .dylib and the .dSYM directly into the plugins folder

if (-not $iOSOnly) {
Write-Host "Setting up macOS support..." -ForegroundColor Yellow

$macOSFrameworkPath = Join-Path $xcframeworkPath "macos-arm64_arm64e_x86_64/Sentry.framework/Sentry"
$macOSdSYMPath = Join-Path $xcframeworkPath "macos-arm64_arm64e_x86_64/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 (Test-Path $macOSFrameworkPath) {
Copy-Item -Path $macOSFrameworkPath -Destination $macOSDestination -Force
Write-Host "Copied macOS dylib to: $macOSDestination" -ForegroundColor Green
} else {
Write-Error "macOS framework not found at: $macOSFrameworkPath"
exit 1
}

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

if (-not (Test-Path $macOSDestination) -or -not (Test-Path $macOSdSYMDestination)) {
Write-Error "Failed to set up the macOS SDK."
exit 1
}
}

Write-Host "Cocoa SDK setup completed successfully!" -ForegroundColor Green
Loading
Loading