Skip to content

Commit c92e06f

Browse files
jpnurmiclaude
andauthored
build: switch to sentry-cocoa submodule for managed builds (#5131)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ff8e67f commit c92e06f

9 files changed

Lines changed: 51 additions & 17 deletions

File tree

.github/workflows/update-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
include:
1818
- name: Cocoa SDK
19-
path: modules/sentry-cocoa.properties
19+
path: modules/sentry-cocoa
2020
- name: Java SDK
2121
path: scripts/update-java.ps1
2222
- name: Native SDK

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ test/**/*.apk
2929
.sentry-native
3030
**/EnvironmentVariables.g.cs
3131

32-
# Download cache for Cocoa SDK
33-
modules/sentry-cocoa
34-
3532
# Local Claude Code settings that should not be committed
3633
.claude/settings.local.json
3734

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "modules/sentry-native"]
88
path = modules/sentry-native
99
url = https://github.com/getsentry/sentry-native.git
10+
[submodule "modules/sentry-cocoa"]
11+
path = modules/sentry-cocoa
12+
url = https://github.com/getsentry/sentry-cocoa.git

modules/sentry-cocoa

Submodule sentry-cocoa added at 3a22ecd

modules/sentry-cocoa.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.

scripts/build-sentry-cocoa.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@ set -euo pipefail
44
pushd "$(dirname "$0")" >/dev/null
55
cd ../modules/sentry-cocoa
66

7-
rm -rf Carthage
7+
mkdir -p Carthage
8+
PID_FILE="$PWD/Carthage/.build.pid"
9+
trap 'if [[ "$(cat "$PID_FILE" 2>/dev/null)" == "$$" ]]; then rm -f "$PID_FILE"; fi' EXIT
10+
11+
# Serialize concurrent invocations; parallel xcodebuilds race on DerivedData.
12+
TMP_FILE=$(mktemp "$PID_FILE.tmp.XXXXXX")
13+
echo $$ > "$TMP_FILE"
14+
while ! ln "$TMP_FILE" "$PID_FILE" 2>/dev/null; do
15+
build_pid=$(cat "$PID_FILE" 2>/dev/null || true)
16+
if [[ -n "$build_pid" ]] && ! kill -0 "$build_pid" 2>/dev/null; then
17+
echo "Previous build did not complete (pid $build_pid); cleaning up and retrying" >&2
18+
if mv "$PID_FILE" "$PID_FILE.stale.$$" 2>/dev/null; then
19+
rm -f "$PID_FILE.stale.$$"
20+
fi
21+
continue
22+
fi
23+
sleep 2
24+
done
25+
rm -f "$TMP_FILE"
26+
27+
current_sha=$(git rev-parse HEAD)
28+
if [[ -f Carthage/.built-from-sha ]] && [[ "$(cat Carthage/.built-from-sha)" == "$current_sha" ]]; then
29+
popd >/dev/null
30+
exit 0
31+
fi
32+
33+
rm -rf Carthage/output-*.xcarchive Carthage/Build-* Carthage/Headers Carthage/.built-from-sha
834

935
# Grabbing the first SDK versions
1036
sdks=$(xcodebuild -showsdks)
@@ -62,7 +88,7 @@ find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Car
6288
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
6389
rm -rf Carthage/output-*
6490

65-
cp .git/HEAD Carthage/.built-from-sha
91+
echo "$current_sha" > Carthage/.built-from-sha
6692
echo ""
6793

6894
popd >/dev/null

src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using CoreGraphics;
1212
using Foundation;
1313
using ObjCRuntime;
14-
using Sentry;
1514
using UIKit;
1615

1716
namespace Sentry.CocoaSdk;

src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,29 @@
88
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
99
<Description>.NET Bindings for the Sentry Cocoa SDK</Description>
1010
<SentryCocoaCache>..\..\modules\sentry-cocoa\</SentryCocoaCache>
11+
<SentryCocoaProperties>$(MSBuildThisFileDirectory)..\..\modules\sentry-cocoa.properties</SentryCocoaProperties>
1112
<SentryCocoaFrameworkHeaders>$(SentryCocoaCache)Sentry.framework\</SentryCocoaFrameworkHeaders>
12-
<SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties>
13-
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
14-
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
15-
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
1613
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
1714
<NoWarn>$(NoWarn);CS0108</NoWarn>
1815
</PropertyGroup>
1916

17+
<!-- Released Cocoa SDK builds -->
18+
<PropertyGroup Condition="Exists('$(SentryCocoaProperties)') And !Exists('$(SentryCocoaCache).git')">
19+
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(SentryCocoaProperties)')), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
20+
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
21+
<SentryCocoaBindingInputs>$(SentryCocoaProperties);../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
22+
</PropertyGroup>
23+
2024
<!-- Override values for local Cocoa SDK builds -->
2125
<PropertyGroup Condition="Exists('$(SentryCocoaCache).git')">
2226
<SentryCocoaFramework>$(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework</SentryCocoaFramework>
2327
<SentryCocoaBindingInputs>../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaCache)Carthage/.built-from-sha;$(SentryCocoaCache)Carthage/**/*.h</SentryCocoaBindingInputs>
28+
<!-- Resolve path to modules/sentry-cocoa/.git -->
29+
<SentryCocoaGitFile>$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory), $(SentryCocoaCache).git))</SentryCocoaGitFile>
30+
<!-- Standalone clone: .git is a directory -->
31+
<SentryCocoaGitDir Condition="Exists('$(SentryCocoaCache).git\HEAD')">.git</SentryCocoaGitDir>
32+
<!-- Submodule: .git is a file pointing at the real gitdir -->
33+
<SentryCocoaGitDir Condition="'$(SentryCocoaGitDir)' == ''">$([System.IO.File]::ReadAllText('$(SentryCocoaGitFile)').Trim().Replace('gitdir: ', ''))</SentryCocoaGitDir>
2434
</PropertyGroup>
2535

2636
<!-- Build empty assemblies when not on macOS, to pass the solution build. -->
@@ -58,7 +68,7 @@
5868

5969
<!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:setupCocoaSDK src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj -->
6070
<Target Name="_DownloadCocoaSDK"
61-
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaCache).git') And !Exists('$(SentryCocoaFramework)')">
71+
Condition="$([MSBuild]::IsOSPlatform('OSX')) And Exists('$(SentryCocoaProperties)') And !Exists('$(SentryCocoaCache).git') And !Exists('$(SentryCocoaFramework)')">
6272

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

@@ -97,7 +107,7 @@
97107
<!-- Build the Sentry Cocoa SDK from source -->
98108
<Target Name="_BuildCocoaSDK"
99109
Condition="$([MSBuild]::IsOSPlatform('OSX')) And Exists('$(SentryCocoaCache).git')"
100-
Inputs="..\..\modules\sentry-cocoa\.git\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">
110+
Inputs="$(SentryCocoaCache)$(SentryCocoaGitDir)\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">
101111

102112
<Message Importance="High" Text="Building the Cocoa SDK from source." />
103113
<Exec Command="bash ../../scripts/build-sentry-cocoa.sh" IgnoreStandardErrorWarningFormat="true" />
@@ -125,7 +135,8 @@
125135
Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
126136

127137
<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
128-
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
138+
<RemoveDir Directories="$(SentryCocoaCache)Carthage;$(SentryCocoaFramework);$(SentryCocoaFrameworkHeaders)" ContinueOnError="true" />
139+
<Delete Files="$(SentryCocoaFramework).zip;$(SentryCocoaFramework).sanitized.stamp" ContinueOnError="true" />
129140
</Target>
130141

131142
<!-- Generate bindings -->

src/Sentry.Bindings.Cocoa/StructsAndEnums.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Runtime.InteropServices;
1010
using Foundation;
1111
using ObjCRuntime;
12-
using Sentry;
1312

1413
namespace Sentry.CocoaSdk;
1514

0 commit comments

Comments
 (0)