Skip to content

Commit de422d3

Browse files
chore: xamarin-ios is being deprecated (#4406)
Resolves #4379: - #4379 Replace `brew install --cask xamarin-ios` with manual download and install steps to avoid CI breaking when this package is removed later this month. #skip-changelog
1 parent 48a549f commit de422d3

File tree

1 file changed

+68
-9
lines changed

1 file changed

+68
-9
lines changed

scripts/generate-cocoa-bindings.ps1

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,63 @@ if (!(Get-Command sharpie -ErrorAction SilentlyContinue))
2828
# Ensure Xamarin is installed (or sharpie won't produce expected output).
2929
if (!(Test-Path '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/64bits/iOS/Xamarin.iOS.dll'))
3030
{
31-
Write-Output 'Xamarin.iOS not found. Attempting to install via Homebrew.'
32-
brew install --cask xamarin-ios
31+
Write-Output 'Xamarin.iOS not found. Attempting to install manually.'
32+
33+
# Download Xamarin.iOS package
34+
$packageName = 'xamarin.ios-16.4.0.23.pkg'
35+
$directDownloadUrl = 'https://github.com/getsentry/sentry-dotnet/releases/download/1.0.0.0-xamarin-ios/Xamarin.iOS.16.4.0.23.pkg'
36+
$downloadPath = "/tmp/$packageName"
37+
$expectedSha256 = '3c3a2e3c5adebf7955934862b89c82e4771b0fd44dfcfebad0d160033a6e0a1a'
38+
39+
Write-Output "Downloading Xamarin.iOS package..."
40+
curl -L -o $downloadPath $directDownloadUrl
41+
42+
if ($LASTEXITCODE -ne 0)
43+
{
44+
Write-Error "Failed to download Xamarin.iOS package. Exit code: $LASTEXITCODE"
45+
}
46+
47+
# Verify checksum
48+
Write-Output "Verifying package checksum..."
49+
$actualSha256 = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash.ToLower()
50+
51+
if ($actualSha256 -ne $expectedSha256)
52+
{
53+
Write-Error "Checksum verification failed. Expected: $expectedSha256, Actual: $actualSha256"
54+
Remove-Item $downloadPath -Force -ErrorAction SilentlyContinue
55+
exit 1
56+
}
57+
58+
Write-Output "Checksum verification passed."
59+
60+
if (Test-Path $downloadPath)
61+
{
62+
Write-Output "Downloaded package to $downloadPath"
63+
Write-Output "Installing Xamarin.iOS package..."
64+
65+
# Install the package using installer command (requires sudo)
66+
sudo installer -pkg $downloadPath -target /
67+
68+
if ($LASTEXITCODE -ne 0)
69+
{
70+
Write-Error "Failed to install Xamarin.iOS package. Exit code: $LASTEXITCODE"
71+
}
72+
else
73+
{
74+
Write-Output "Xamarin.iOS package installed successfully"
75+
}
76+
77+
# Clean up downloaded file
78+
Remove-Item $downloadPath -Force -ErrorAction SilentlyContinue
79+
}
80+
else
81+
{
82+
Write-Error "Downloaded package not found at $downloadPath"
83+
}
3384

3485
if (!(Test-Path '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/64bits/iOS/Xamarin.iOS.dll'))
3586
{
36-
Write-Error 'Xamarin.iOS not found. Try installing manually from: https://learn.microsoft.com/en-us/xamarin/ios/get-started/installation/.'
87+
Write-Error 'Xamarin.iOS not found after installation.'
3788
}
3889
}
3990

@@ -47,23 +98,30 @@ Write-Output "iPhoneSdkVersion: $iPhoneSdkVersion"
4798
# `#import "SomeHeader.h"`
4899
# This causes sharpie to fail resolve those headers
49100
$filesToPatch = Get-ChildItem -Path "$CocoaSdkPath/Headers" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName
50-
foreach ($file in $filesToPatch) {
51-
if (Test-Path $file) {
101+
foreach ($file in $filesToPatch)
102+
{
103+
if (Test-Path $file)
104+
{
52105
$content = Get-Content -Path $file -Raw
53106
$content = $content -replace '<Sentry/([^>]+)>', '"$1"'
54107
Set-Content -Path $file -Value $content
55-
} else {
108+
}
109+
else
110+
{
56111
Write-Host "File not found: $file"
57112
}
58113
}
59114
$privateHeaderFile = "$CocoaSdkPath/PrivateHeaders/PrivatesHeader.h"
60-
if (Test-Path $privateHeaderFile) {
115+
if (Test-Path $privateHeaderFile)
116+
{
61117
$content = Get-Content -Path $privateHeaderFile -Raw
62118
$content = $content -replace '"SentryDefines.h"', '"../Headers/SentryDefines.h"'
63119
$content = $content -replace '"SentryProfilingConditionals.h"', '"../Headers/SentryProfilingConditionals.h"'
64120
Set-Content -Path $privateHeaderFile -Value $content
65121
Write-Host "Patched includes: $privateHeaderFile"
66-
} else {
122+
}
123+
else
124+
{
67125
Write-Host "File not found: $privateHeaderFile"
68126
}
69127

@@ -258,7 +316,8 @@ $propertiesToRemove = @(
258316
'enableMetricKitRawPayload'
259317
)
260318

261-
foreach ($property in $propertiesToRemove) {
319+
foreach ($property in $propertiesToRemove)
320+
{
262321
$Text = $Text -replace "\n.*property.*$property.*?[\s\S]*?\}\n", ''
263322
}
264323

0 commit comments

Comments
 (0)