Skip to content
Merged
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
17 changes: 0 additions & 17 deletions .github/actions/buildcocoasdk/action.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ jobs:
- name: Build Native Dependencies
uses: ./.github/actions/buildnative

- name: Build Cocoa SDK
if: runner.os == 'macOS'
uses: ./.github/actions/buildcocoasdk

- name: Restore .NET Dependencies
run: dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/device-tests-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ jobs:
with:
submodules: recursive

- name: Build Cocoa SDK
uses: ./.github/actions/buildcocoasdk

- name: Setup Environment
uses: ./.github/actions/environment

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
include:
- name: Cocoa SDK
path: modules/sentry-cocoa
path: modules/sentry-cocoa.properties
- name: Java SDK
path: scripts/update-java.ps1
- name: Native SDK
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ test/**/*.apk
/tools/
*.log
.sentry-native

# Download cache for Cocoa SDK
modules/sentry-cocoa
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "modules/Ben.Demystifier"]
path = modules/Ben.Demystifier
url = https://github.com/getsentry/Ben.Demystifier
[submodule "modules/sentry-cocoa"]
path = modules/sentry-cocoa
url = https://github.com/getsentry/sentry-cocoa.git
[submodule "modules/perfview"]
path = modules/perfview
url = https://github.com/getsentry/perfview.git
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

### Dependencies

- Bump Cocoa SDK from v8.36.0 to v8.39.0 ([#3727](https://github.com/getsentry/sentry-dotnet/pull/3727))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8390)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.36.0...8.39.0)
- Bump CLI from v2.38.1 to v2.38.2 ([#3728](https://github.com/getsentry/sentry-dotnet/pull/3728))
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2382)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.38.1...2.38.2)
Expand Down
3 changes: 3 additions & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleFileTestApp", "test\SingleFileTestApp\SingleFileTestApp.csproj", "{162A1CAE-ACEE-45CA-A6D0-7702ADE4D3DE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{A3CCA27E-4DF8-479D-833C-CAA0950715AA}"
ProjectSection(SolutionItems) = preProject
modules\sentry-cocoa.properties = modules\sentry-cocoa.properties
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TraceEvent", "modules\perfview\src\TraceEvent\TraceEvent.csproj", "{67269916-C417-4CEE-BD7D-CA66C3830AEE}"
EndProject
Expand Down
1 change: 0 additions & 1 deletion modules/sentry-cocoa
Submodule sentry-cocoa deleted from 5575af
2 changes: 2 additions & 0 deletions modules/sentry-cocoa.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = 8.39.0
repo = https://github.com/getsentry/sentry-cocoa
36 changes: 29 additions & 7 deletions scripts/generate-cocoa-bindings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$RootPath = (Get-Item $PSScriptRoot).Parent.FullName
$CocoaSdkPath = "$RootPath/modules/sentry-cocoa"
$CocoaSdkPath = "$RootPath/modules/sentry-cocoa/Sentry.framework"
$BindingsPath = "$RootPath/src/Sentry.Bindings.Cocoa"
$BackupPath = "$BindingsPath/obj/_unpatched"

Expand Down Expand Up @@ -41,16 +41,38 @@ if (!(Test-Path '/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/
$iPhoneSdkVersion = sharpie xcode -sdks | grep -o -m 1 'iphoneos\S*'
Write-Output "iPhoneSdkVersion: $iPhoneSdkVersion"

# The umbrella header is provided in the "new" style of `#import <Sentry/SomeHeader.h>` instead of `#import "SomeHeader.h"` which causes sharpie to fail resolve those headers
$umbrellaHeader = "$CocoaSdkPath/Carthage/Headers/Sentry.h"
Set-Content -Path $umbrellaHeader -Value ((Get-Content -Path $umbrellaHeader -Raw) -replace '<Sentry/([^>]+)>', '"$1"')
## Imports in the various header files are provided in the "new" style of:
# `#import <Sentry/SomeHeader.h>`
# ...instead of:
# `#import "SomeHeader.h"`
# This causes sharpie to fail resolve those headers
$filesToPatch = Get-ChildItem -Path "$CocoaSdkPath/Headers" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName
foreach ($file in $filesToPatch) {
if (Test-Path $file) {
$content = Get-Content -Path $file -Raw
$content = $content -replace '<Sentry/([^>]+)>', '"$1"'
Set-Content -Path $file -Value $content
} else {
Write-Host "File not found: $file"
}
}
$privateHeaderFile = "$CocoaSdkPath/PrivateHeaders/PrivatesHeader.h"
if (Test-Path $privateHeaderFile) {
$content = Get-Content -Path $privateHeaderFile -Raw
$content = $content -replace '"SentryDefines.h"', '"../Headers/SentryDefines.h"'
$content = $content -replace '"SentryProfilingConditionals.h"', '"../Headers/SentryProfilingConditionals.h"'
Set-Content -Path $privateHeaderFile -Value $content
Write-Host "Patched includes: $privateHeaderFile"
} else {
Write-Host "File not found: $privateHeaderFile"
}

# Generate bindings
Write-Output 'Generating bindings with Objective Sharpie.'
sharpie bind -sdk $iPhoneSdkVersion `
-scope "$CocoaSdkPath/Carthage/Headers" `
"$CocoaSdkPath/Carthage/Headers/Sentry.h" `
"$CocoaSdkPath/Carthage/Headers/PrivateSentrySDKOnly.h" `
-scope "$CocoaSdkPath" `
"$CocoaSdkPath/Headers/Sentry.h" `
"$CocoaSdkPath/PrivateHeaders/PrivateSentrySDKOnly.h" `
-o $BindingsPath `
-c -Wno-objc-property-no-attribute

Expand Down
67 changes: 45 additions & 22 deletions src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using Foundation;
using ObjCRuntime;
using Sentry;
using UIKit;

namespace Sentry.CocoaSdk;
Expand Down Expand Up @@ -1521,6 +1522,14 @@ interface SentryOptions
[Export ("enableAppHangTracking")]
bool EnableAppHangTracking { get; set; }

// @property (assign, nonatomic) BOOL enableAppHangTrackingV2;
[Export ("enableAppHangTrackingV2")]
bool EnableAppHangTrackingV2 { get; set; }

// @property (assign, nonatomic) BOOL enableReportNonFullyBlockingAppHangs;
[Export ("enableReportNonFullyBlockingAppHangs")]
bool EnableReportNonFullyBlockingAppHangs { get; set; }

// @property (assign, nonatomic) NSTimeInterval appHangTimeoutInterval;
[Export ("appHangTimeoutInterval")]
double AppHangTimeoutInterval { get; set; }
Expand Down Expand Up @@ -1567,22 +1576,36 @@ interface SentryOptions
// @property (copy, nonatomic) NSString * _Nonnull spotlightUrl;
[Export ("spotlightUrl")]
string SpotlightUrl { get; set; }
}

// @interface SentryReplayApi : NSObject
[BaseType (typeof(NSObject))]
[Internal]
interface SentryReplayApi
{
// -(void)maskView:(UIView * _Nonnull)view __attribute__((swift_name("maskView(_:)")));
[Export ("maskView:")]
void MaskView (UIView view);

// -(void)unmaskView:(UIView * _Nonnull)view __attribute__((swift_name("unmaskView(_:)")));
[Export ("unmaskView:")]
void UnmaskView (UIView view);

// @property (assign, nonatomic) BOOL enableMetrics;
[Export ("enableMetrics")]
bool EnableMetrics { get; set; }
// -(void)pause;
[Export ("pause")]
void Pause ();

// @property (assign, nonatomic) BOOL enableDefaultTagsForMetrics;
[Export ("enableDefaultTagsForMetrics")]
bool EnableDefaultTagsForMetrics { get; set; }
// -(void)resume;
[Export ("resume")]
void Resume ();

// @property (assign, nonatomic) BOOL enableSpanLocalMetricAggregation;
[Export ("enableSpanLocalMetricAggregation")]
bool EnableSpanLocalMetricAggregation { get; set; }
// -(void)start;
[Export ("start")]
void Start ();

// @property (copy, nonatomic) SentryBeforeEmitMetricCallback _Nullable beforeEmitMetric;
[NullAllowed, Export ("beforeEmitMetric", ArgumentSemantic.Copy)]
SentryBeforeEmitMetricCallback BeforeEmitMetric { get; set; }
// -(void)stop;
[Export ("stop")]
void Stop ();
}

// @interface SentryRequest : NSObject <SentrySerializable>
Expand Down Expand Up @@ -1635,6 +1658,11 @@ interface SentrySDK
[Export ("isEnabled")]
bool IsEnabled { get; }

// @property (readonly, nonatomic, class) SentryReplayApi * _Nonnull replay;
[Static]
[Export ("replay")]
SentryReplayApi Replay { get; }

// +(void)startWithOptions:(SentryOptions * _Nonnull)options __attribute__((swift_name("start(options:)")));
[Static]
[Export ("startWithOptions:")]
Expand Down Expand Up @@ -1740,6 +1768,11 @@ interface SentrySDK
[Export ("captureUserFeedback:")]
void CaptureUserFeedback (SentryUserFeedback userFeedback);

// +(void)showUserFeedbackForm;
[Static]
[Export ("showUserFeedbackForm")]
void ShowUserFeedbackForm ();

// +(void)addBreadcrumb:(SentryBreadcrumb * _Nonnull)crumb __attribute__((swift_name("addBreadcrumb(_:)")));
[Static]
[Export ("addBreadcrumb:")]
Expand Down Expand Up @@ -1805,16 +1838,6 @@ interface SentrySDK
[Export ("close")]
void Close ();

// +(void)replayRedactView:(UIView * _Nonnull)view;
[Static]
[Export ("replayRedactView:")]
void ReplayRedactView (UIView view);

// +(void)replayIgnoreView:(UIView * _Nonnull)view;
[Static]
[Export ("replayIgnoreView:")]
void ReplayIgnoreView (UIView view);

// +(void)startProfiler;
[Static]
[Export ("startProfiler")]
Expand Down
56 changes: 46 additions & 10 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<IsBindingProject>true</IsBindingProject>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<Description>.NET Bindings for the Sentry Cocoa SDK</Description>
<SentryCocoaSdkDirectory>..\..\modules\sentry-cocoa\</SentryCocoaSdkDirectory>
<SentryCocoaFramework>$(SentryCocoaSdkDirectory)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework</SentryCocoaFramework>
<SentryCocoaCache>..\..\modules\sentry-cocoa\</SentryCocoaCache>
<SentryCocoaFrameworkHeaders>$(SentryCocoaCache)Sentry.framework\</SentryCocoaFrameworkHeaders>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-Dynamic.xcframework</SentryCocoaFramework>
</PropertyGroup>

<!-- Build empty assemblies when not on macOS, to pass the solution build. -->
Expand Down Expand Up @@ -44,18 +45,53 @@
<None Include="buildTransitive\Sentry.Bindings.Cocoa.targets" Pack="true" PackagePath="buildTransitive\Sentry.Bindings.Cocoa.targets" />
</ItemGroup>

<!-- Build the Sentry Cocoa SDK -->
<Target Name="_BuildSentryCocoaSDK" BeforeTargets="DispatchToInnerBuilds;BeforeBuild" Condition="'$(CI)' != 'true' and $([MSBuild]::IsOSPlatform('OSX'))"
Inputs="..\..\.git\modules\modules\sentry-cocoa\HEAD" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildSentryCocoaSDK" Properties="TargetFramework=once" />
<!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:setupCocoaSDK src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj -->
<Target Name="SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')"
BeforeTargets="BeforeBuild">

<PropertyGroup>
<PropertiesContent>$([System.IO.File]::ReadAllText("../../modules/sentry-cocoa.properties"))</PropertiesContent>
<CocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'version\s*=\s*([^\s]+)').Groups[1].Value)</CocoaVersion>
</PropertyGroup>

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

<!-- Clean cache if version does not exist to get rid of old versions -->
<RemoveDir
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Directories="$(SentryCocoaCache)" />

<!-- Create cache directory -->
<MakeDir Condition="!Exists('$(SentryCocoaCache)')" Directories="$(SentryCocoaCache)" />

<!-- Download the Cocoa SDK as pre-built .xcframework -->
<Exec
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Command="curl -L https://github.com/getsentry/sentry-cocoa/releases/download/$(CocoaVersion)/Sentry-Dynamic.xcframework.zip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip" />

<Exec
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')"
Command="unzip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip -d $(SentryCocoaCache)" />

<!-- Make a copy of the header files before we butcher these to suite objective sharpie -->
<MakeDir Directories="$(SentryCocoaFrameworkHeaders)" />
<ItemGroup>
<FilesToCopy Include="$(SentryCocoaCache)Sentry-Dynamic.xcframework\ios-arm64_arm64e\Sentry.framework\**\*" />
</ItemGroup>
<Copy SourceFiles="@(FilesToCopy)"
DestinationFolder="$(SentryCocoaFrameworkHeaders)%(RecursiveDir)"
SkipUnchangedFiles="true" />
</Target>
<Target Name="_InnerBuildSentryCocoaSDK">
<Exec Command="../../scripts/build-sentry-cocoa.sh" />

<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
</Target>

<!-- Generate bindings -->
<Target Name="_GenerateSentryCocoaBindings" AfterTargets="_BuildSentryCocoaSDK" Condition="$([MSBuild]::IsOSPlatform('OSX'))"
Inputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha" Outputs="ApiDefinitions.cs;StructsAndEnums.cs">
<Target Name="_GenerateSentryCocoaBindings" AfterTargets="SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) and Exists('$(SentryCocoaFrameworkHeaders)')"
Outputs="ApiDefinitions.cs;StructsAndEnums.cs">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerGenerateSentryCocoaBindings" Properties="TargetFramework=once" />
</Target>
<Target Name="_InnerGenerateSentryCocoaBindings">
Expand Down
1 change: 1 addition & 0 deletions src/Sentry.Bindings.Cocoa/StructsAndEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;
using Sentry;

namespace Sentry.CocoaSdk;

Expand Down
Loading