Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
include:
- name: Cocoa SDK
path: modules/sentry-cocoa.properties
path: modules/sentry-cocoa
- name: Java SDK
path: scripts/update-java.ps1
- name: Native SDK
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ test/**/*.apk
.sentry-native
**/EnvironmentVariables.g.cs

# Download cache for Cocoa SDK
modules/sentry-cocoa

# Local Claude Code settings that should not be committed
.claude/settings.local.json

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "modules/sentry-native"]
path = modules/sentry-native
url = https://github.com/getsentry/sentry-native.git
[submodule "modules/sentry-cocoa"]
path = modules/sentry-cocoa
url = https://github.com/getsentry/sentry-cocoa.git
1 change: 1 addition & 0 deletions modules/sentry-cocoa
Submodule sentry-cocoa added at 05d3ce
2 changes: 0 additions & 2 deletions modules/sentry-cocoa.properties

This file was deleted.

30 changes: 28 additions & 2 deletions scripts/build-sentry-cocoa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,33 @@
pushd "$(dirname "$0")" >/dev/null
cd ../modules/sentry-cocoa

rm -rf Carthage
mkdir -p Carthage
PID_FILE="$PWD/Carthage/.build.pid"
trap 'if [[ "$(cat "$PID_FILE" 2>/dev/null)" == "$$" ]]; then rm -f "$PID_FILE"; fi' EXIT

# Serialize concurrent invocations; parallel xcodebuilds race on DerivedData.
TMP_FILE=$(mktemp "$PID_FILE.tmp.XXXXXX")
echo $$ > "$TMP_FILE"
while ! ln "$TMP_FILE" "$PID_FILE" 2>/dev/null; do
build_pid=$(cat "$PID_FILE" 2>/dev/null || true)
if [[ -n "$build_pid" ]] && ! kill -0 "$build_pid" 2>/dev/null; then
echo "Previous build did not complete (pid $build_pid); cleaning up and retrying" >&2
if mv "$PID_FILE" "$PID_FILE.stale.$$" 2>/dev/null; then
rm -f "$PID_FILE.stale.$$"
fi
continue

Check warning on line 21 in scripts/build-sentry-cocoa.sh

View check run for this annotation

@sentry/warden / warden: find-bugs

TOCTOU race condition in lock acquisition allows concurrent builds

The lock cleanup logic at lines 16-21 has a time-of-check-to-time-of-use race condition. Between checking if the lock holder is dead (line 16) and moving the stale lock (line 18), another process could have already cleaned the stale lock and created a new valid lock. The `mv` at line 18 would then move this valid lock, allowing both processes to acquire the lock and run concurrent builds, defeating the purpose of serialization.
fi
sleep 2
done
rm -f "$TMP_FILE"

current_sha=$(git rev-parse HEAD)
if [[ -f Carthage/.built-from-sha ]] && [[ "$(cat Carthage/.built-from-sha)" == "$current_sha" ]]; then
popd >/dev/null
exit 0
fi

rm -rf Carthage/output-*.xcarchive Carthage/Build-* Carthage/Headers Carthage/.built-from-sha

# Grabbing the first SDK versions
sdks=$(xcodebuild -showsdks)
Expand Down Expand Up @@ -62,7 +88,7 @@
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
rm -rf Carthage/output-*

cp .git/HEAD Carthage/.built-from-sha
echo "$current_sha" > Carthage/.built-from-sha
echo ""

popd >/dev/null
1 change: 0 additions & 1 deletion src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using CoreGraphics;
using Foundation;
using ObjCRuntime;
using Sentry;
using UIKit;

namespace Sentry.CocoaSdk;
Expand Down Expand Up @@ -1752,7 +1751,7 @@

// @property (copy, nonatomic) void (^ _Nullable)(enum SentryLastRunStatus, SentryEvent * _Nullable) onLastRunStatusDetermined;
[NullAllowed, Export("onLastRunStatusDetermined", ArgumentSemantic.Copy)]
Action<SentryLastRunStatus, SentryEvent?> OnLastRunStatusDetermined { get; set; }

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1754 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// @property (nonatomic, strong) NSNumber * _Nullable sampleRate;
[NullAllowed, Export("sampleRate", ArgumentSemantic.Strong)]
Expand Down
25 changes: 18 additions & 7 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,29 @@
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<Description>.NET Bindings for the Sentry Cocoa SDK</Description>
<SentryCocoaCache>..\..\modules\sentry-cocoa\</SentryCocoaCache>
<SentryCocoaProperties>$(MSBuildThisFileDirectory)..\..\modules\sentry-cocoa.properties</SentryCocoaProperties>
<SentryCocoaFrameworkHeaders>$(SentryCocoaCache)Sentry.framework\</SentryCocoaFrameworkHeaders>
<SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties>
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
<NoWarn>$(NoWarn);CS0108</NoWarn>
</PropertyGroup>

<!-- Released Cocoa SDK builds -->
<PropertyGroup Condition="Exists('$(SentryCocoaProperties)') And !Exists('$(SentryCocoaCache).git')">
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(SentryCocoaProperties)')), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>$(SentryCocoaProperties);../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
</PropertyGroup>

<!-- Override values for local Cocoa SDK builds -->
<PropertyGroup Condition="Exists('$(SentryCocoaCache).git')">
<SentryCocoaFramework>$(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaCache)Carthage/.built-from-sha;$(SentryCocoaCache)Carthage/**/*.h</SentryCocoaBindingInputs>
<!-- Resolve path to modules/sentry-cocoa/.git -->
<SentryCocoaGitFile>$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory), $(SentryCocoaCache).git))</SentryCocoaGitFile>
<!-- Standalone clone: .git is a directory -->
<SentryCocoaGitDir Condition="Exists('$(SentryCocoaCache).git\HEAD')">.git</SentryCocoaGitDir>
<!-- Submodule: .git is a file pointing at the real gitdir -->
<SentryCocoaGitDir Condition="'$(SentryCocoaGitDir)' == ''">$([System.IO.File]::ReadAllText('$(SentryCocoaGitFile)').Trim().Replace('gitdir: ', ''))</SentryCocoaGitDir>
</PropertyGroup>

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

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

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

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

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

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

<!-- Generate bindings -->
Expand Down
1 change: 0 additions & 1 deletion src/Sentry.Bindings.Cocoa/StructsAndEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;
using Sentry;

namespace Sentry.CocoaSdk;

Expand Down
Loading