-
-
Notifications
You must be signed in to change notification settings - Fork 57
chore: Create iOS-only
xcframework in CI
#2264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4743813
Create iOS-only xcframework and do that in CI
bitsandfoxes 9fc9a25
Updated CHANGELOG.md
bitsandfoxes a9f91b4
Updated snapshot
bitsandfoxes af6e291
Tweaked Cocoa SDK artifact handling
bitsandfoxes ad8c892
Log in debug
bitsandfoxes 574127a
Fixed upload paths
bitsandfoxes ec1501e
Updated snapshot
bitsandfoxes 3f8f2d7
Merge branch 'main' into chore/create-xcframework-in-ci
bitsandfoxes e09b838
Overwrite existing (old) xcframework if it exists
bitsandfoxes 14d3129
Merge branch 'chore/create-xcframework-in-ci' of https://github.com/g…
bitsandfoxes 139fe62
Update scripts/setup-cocoa-sdk.ps1
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.