Skip to content

Commit 5c69a43

Browse files
committed
build: switch to sentry-cocoa submodule for managed builds
Allows building sentry-cocoa with `SENTRY_CRASH_MANAGED_RUNTIME` for eliminating duplicate native exceptions on iOS. See also: - getsentry/sentry-cocoa#6193 - #5126
1 parent 39ea4d8 commit 5c69a43

File tree

9 files changed

+43
-14
lines changed

9 files changed

+43
-14
lines changed

.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 05d3ce8

modules/sentry-cocoa.properties

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

scripts/build-sentry-cocoa.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,28 @@ 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+
while ! (set -C; echo $$ > "$PID_FILE") 2>/dev/null; do
13+
build_pid=$(cat "$PID_FILE" 2>/dev/null || true)
14+
if [[ -n "$build_pid" ]] && ! kill -0 "$build_pid" 2>/dev/null; then
15+
echo "Previous build did not complete (pid $build_pid); cleaning up and retrying" >&2
16+
rm -f "$PID_FILE"
17+
continue
18+
fi
19+
sleep 2
20+
done
21+
22+
current_sha=$(git rev-parse HEAD)
23+
if [[ -f Carthage/.built-from-sha ]] && [[ "$(cat Carthage/.built-from-sha)" == "$current_sha" ]]; then
24+
popd >/dev/null
25+
exit 0
26+
fi
27+
28+
rm -rf Carthage/output-*.xcarchive Carthage/Build-* Carthage/Headers Carthage/.built-from-sha
829

930
# Grabbing the first SDK versions
1031
sdks=$(xcodebuild -showsdks)
@@ -62,7 +83,7 @@ find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Car
6283
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
6384
rm -rf Carthage/output-*
6485

65-
cp .git/HEAD Carthage/.built-from-sha
86+
echo "$current_sha" > Carthage/.built-from-sha
6687
echo ""
6788

6889
popd >/dev/null

src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

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

1514
namespace Sentry.CocoaSdk;

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,28 @@
99
<Description>.NET Bindings for the Sentry Cocoa SDK</Description>
1010
<SentryCocoaCache>..\..\modules\sentry-cocoa\</SentryCocoaCache>
1111
<SentryCocoaFrameworkHeaders>$(SentryCocoaCache)Sentry.framework\</SentryCocoaFrameworkHeaders>
12+
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
13+
<NoWarn>$(NoWarn);CS0108</NoWarn>
14+
</PropertyGroup>
15+
16+
<!-- Released Cocoa SDK builds -->
17+
<PropertyGroup Condition="!Exists('$(SentryCocoaCache).git')">
1218
<SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties>
1319
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
1420
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
1521
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
16-
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
17-
<NoWarn>$(NoWarn);CS0108</NoWarn>
1822
</PropertyGroup>
1923

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. -->
@@ -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
@@ -7,7 +7,6 @@
77
using System.Runtime.InteropServices;
88
using Foundation;
99
using ObjCRuntime;
10-
using Sentry;
1110

1211
namespace Sentry.CocoaSdk;
1312

0 commit comments

Comments
 (0)