Skip to content
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

Update bundled Cocoa SDK to version 7.31.1 #2053

Merged
merged 15 commits into from
Nov 17, 2022
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
45 changes: 45 additions & 0 deletions .github/actions/buildcocoasdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Native Dependencies
runs:
using: composite

steps:

- name: Get Carthage SHA
shell: bash
run: echo "CARTHAGE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
working-directory: modules/Carthage

- name: Cache Carthage
id: cache-carthage
uses: actions/cache@v3
with:
path: modules/Carthage/.build/debug/carthage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we go without this cache since we're caching below at Cache Sentry Cocoa SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split them into separate caches because Carthage takes a very long time to build, and it's not likely we'll need to update it as often as we do the Cocoa SDK. I also restore it every time to keep it active, otherwise GHA will prune it from the cache over time.

key: carthage-${{ env.CARTHAGE_SHA }}

- name: Build Carthage
if: ${{ steps.cache-carthage.outputs.cache-hit != 'true' }}
shell: bash
run: make all
working-directory: modules/Carthage
Comment on lines +7 to +23
Copy link
Collaborator

@vaind vaind Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to build Carthage? It's available on macOS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a custom build so we can create xcframeworks for Mac Catalyst properly. See comments in the build-sentry-cocoa.sh script. https://github.com/getsentry/sentry-dotnet/pull/2053/files#diff-6be5d334c8d46a713f0d9a5b40af751ffc613d6e52405e4a0f72fa06c2d91ed6R6-R9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The Carthage submodule is tracking their xcframework-catalyst branch.)

Copy link
Contributor Author

@mattjohnsonpint mattjohnsonpint Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to kill it if you can find any other solution. I figure there must be a way to skip Carthage and just use xcodebuild, but I lack expertise in this area and couldn't figure it out.

I already looked into using either Swift SPM or CocoaPods, but the matching tooling on the Xamarin side just isn't up to par (docs talk about sharpie pod, but that is very broken and MS doesn't seem to be in a hurry to fix it).

However it is done, ultimately we need the build output to look like the following to bind correctly in .NET:

.
└── Sentry.xcframework
    ├── Info.plist
    ├── ios-arm64
    │   ├── Sentry.framework
    │   └── dSYMs
    ├── ios-arm64_x86_64-maccatalyst
    │   ├── Sentry.framework
    │   └── dSYMs
    └── ios-arm64_x86_64-simulator
        ├── Sentry.framework
        └── dSYMs

We get that by using carthage build --use-xcframeworks --no-skip-current --platform ios,macCatalyst but only when using the custom Carthage build can we ask for macCatalyst.

Only reason this matters is because .NET MAUI uses Mac Catalyst to build macOS apps.


- name: Fetch version tags for Sentry Cocoa SDK
shell: bash
run: git fetch --tags --quiet
working-directory: modules/sentry-cocoa

- name: Get Sentry Cocoa SHA
shell: bash
run: echo "SENTRY_COCOA_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
working-directory: modules/sentry-cocoa

- name: Cache Sentry Cocoa SDK
id: cache-sentry-cocoa
uses: actions/cache@v3
with:
path: modules/sentry-cocoa/Carthage/Build
key: sentry-cocoa-${{ env.SENTRY_COCOA_SHA }}

- name: Build Sentry Cocoa SDK
if: ${{ steps.cache-sentry-cocoa.outputs.cache-hit != 'true' }}
shell: bash
run: scripts/build-sentry-cocoa.sh
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ 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
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[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/Carthage"]
path = modules/Carthage
url = https://github.com/Carthage/Carthage
branch = xcframework-catalyst
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- Simplify API for flushing events ([#2030](https://github.com/getsentry/sentry-dotnet/pull/2030))
- Update bundled Cocoa SDK to version 7.31.1 ([#2053](https://github.com/getsentry/sentry-dotnet/pull/2053))

### Fixes

Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Deterministic>true</Deterministic>
<Features>strict</Features>
<ImplicitUsings>true</ImplicitUsings>
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
</PropertyGroup>

<!--
Expand Down
Binary file removed lib/Sentry.xcframework.7.28.0.custombuild.zip
Binary file not shown.
1 change: 1 addition & 0 deletions modules/Carthage
Submodule Carthage added at 89cb8c
1 change: 1 addition & 0 deletions modules/sentry-cocoa
Submodule sentry-cocoa added at 1748a0
44 changes: 44 additions & 0 deletions scripts/build-sentry-cocoa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

pushd "$(dirname "$0")" > /dev/null
cd ../modules

# We need a custom build of Carthage that supports building XCFrameworks for Mac Catalyst,
# so we'll bring it in as a submodule and build it here.
# See https://github.com/getsentry/sentry-cocoa/issues/2031
# and https://github.com/Carthage/Carthage/pull/3235

CARTHAGE=Carthage/.build/debug/carthage

if [ ! -f $CARTHAGE ]; then
cd Carthage
echo "---------- Building Carthage ---------- "
make all
echo ""
cd ..
fi

if [ $? -eq 0 ]
then
cd sentry-cocoa

# Keep track of the submodule's SHA so we only build when we need to
SHA=$(git rev-parse HEAD)
SHAFILE=Carthage/Build/.built-from-sha
[ -f $SHAFILE ] && SHAFROMFILE=$(<$SHAFILE)
VERSION="$(git describe --tags) ($(git rev-parse --short HEAD))"

if [ "$SHA" == "$SHAFROMFILE" ]; then
echo "Sentry Cocoa SDK $VERSION was already built"
else
echo "---------- Building Sentry Cocoa SDK $VERSION ---------- "
rm -rf Carthage
../$CARTHAGE build --use-xcframeworks --no-skip-current --platform ios,macCatalyst
echo $SHA > $SHAFILE
echo ""
fi

cd ..
fi

popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,18 @@ interface SentryAppStartMeasurement
[Export ("initWithType:appStartTimestamp:duration:runtimeInitTimestamp:didFinishLaunchingTimestamp:")]
NativeHandle Constructor (SentryAppStartType type, NSDate appStartTimestamp, double duration, NSDate runtimeInitTimestamp, NSDate didFinishLaunchingTimestamp);

// -(instancetype _Nonnull)initWithType:(SentryAppStartType)type appStartTimestamp:(NSDate * _Nonnull)appStartTimestamp duration:(NSTimeInterval)duration runtimeInitTimestamp:(NSDate * _Nonnull)runtimeInitTimestamp moduleInitializationTimestamp:(NSDate * _Nonnull)moduleInitializationTimestamp didFinishLaunchingTimestamp:(NSDate * _Nonnull)didFinishLaunchingTimestamp;
[Export ("initWithType:appStartTimestamp:duration:runtimeInitTimestamp:moduleInitializationTimestamp:didFinishLaunchingTimestamp:")]
NativeHandle Constructor (SentryAppStartType type, NSDate appStartTimestamp, double duration, NSDate runtimeInitTimestamp, NSDate moduleInitializationTimestamp, NSDate didFinishLaunchingTimestamp);
// -(instancetype _Nonnull)initWithType:(SentryAppStartType)type isPreWarmed:(BOOL)isPreWarmed appStartTimestamp:(NSDate * _Nonnull)appStartTimestamp duration:(NSTimeInterval)duration runtimeInitTimestamp:(NSDate * _Nonnull)runtimeInitTimestamp moduleInitializationTimestamp:(NSDate * _Nonnull)moduleInitializationTimestamp didFinishLaunchingTimestamp:(NSDate * _Nonnull)didFinishLaunchingTimestamp;
[Export ("initWithType:isPreWarmed:appStartTimestamp:duration:runtimeInitTimestamp:moduleInitializationTimestamp:didFinishLaunchingTimestamp:")]
NativeHandle Constructor (SentryAppStartType type, bool isPreWarmed, NSDate appStartTimestamp, double duration, NSDate runtimeInitTimestamp, NSDate moduleInitializationTimestamp, NSDate didFinishLaunchingTimestamp);

// @property (readonly, assign, nonatomic) SentryAppStartType type;
[Export ("type", ArgumentSemantic.Assign)]
SentryAppStartType Type { get; }

// @property (readonly, assign, nonatomic) BOOL isPreWarmed;
[Export ("isPreWarmed")]
bool IsPreWarmed { get; }

// @property (readonly, assign, nonatomic) NSTimeInterval duration;
[Export ("duration")]
double Duration { get; }
Expand Down Expand Up @@ -692,6 +696,10 @@ interface SentryEvent : SentrySerializable
[NullAllowed, Export ("breadcrumbs", ArgumentSemantic.Strong)]
SentryBreadcrumb[] Breadcrumbs { get; set; }

// @property (nonatomic, strong) SentryRequest * _Nullable request;
[NullAllowed, Export ("request", ArgumentSemantic.Strong)]
SentryRequest Request { get; set; }

// -(instancetype _Nonnull)initWithLevel:(enum SentryLevel)level __attribute__((objc_designated_initializer));
[Export ("initWithLevel:")]
[DesignatedInitializer]
Expand Down Expand Up @@ -791,6 +799,29 @@ interface SentryFrame : SentrySerializable
NSNumber StackStart { get; set; }
}

// @interface SentryHttpStatusCodeRange : NSObject
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
[Internal]
interface SentryHttpStatusCodeRange
{
// @property (readonly, nonatomic) NSInteger min;
[Export ("min")]
nint Min { get; }

// @property (readonly, nonatomic) NSInteger max;
[Export ("max")]
nint Max { get; }

// -(instancetype _Nonnull)initWithMin:(NSInteger)min max:(NSInteger)max;
[Export ("initWithMin:max:")]
NativeHandle Constructor (nint min, nint max);

// -(instancetype _Nonnull)initWithStatusCode:(NSInteger)statusCode;
[Export ("initWithStatusCode:")]
NativeHandle Constructor (nint statusCode);
}

// @interface SentryOptions : NSObject
[BaseType (typeof(NSObject))]
[Internal]
Expand Down Expand Up @@ -832,9 +863,9 @@ interface SentryOptions
[Export ("enabled")]
bool Enabled { get; set; }

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

// @property (assign, nonatomic) NSUInteger maxBreadcrumbs;
[Export ("maxBreadcrumbs")]
Expand Down Expand Up @@ -917,9 +948,9 @@ interface SentryOptions
[Export ("attachScreenshot")]
bool AttachScreenshot { get; set; }

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

// @property (assign, nonatomic) BOOL enableUserInteractionTracing;
[Export ("enableUserInteractionTracing")]
Expand All @@ -929,6 +960,10 @@ interface SentryOptions
[Export ("idleTimeout")]
double IdleTimeout { get; set; }

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

// @property (assign, nonatomic) BOOL enableNetworkTracking;
[Export ("enableNetworkTracking")]
bool EnableNetworkTracking { get; set; }
Expand Down Expand Up @@ -981,19 +1016,19 @@ interface SentryOptions
[Export ("enableCoreDataTracking")]
bool EnableCoreDataTracking { get; set; }

// @property (nonatomic, strong) NSNumber * _Nullable profilesSampleRate;
[NullAllowed, Export ("profilesSampleRate", ArgumentSemantic.Strong)]
NSNumber ProfilesSampleRate { get; set; }
// @property (nonatomic, strong) NSNumber * _Nullable profilesSampleRate;
[NullAllowed, Export ("profilesSampleRate", ArgumentSemantic.Strong)]
NSNumber ProfilesSampleRate { get; set; }

// @property (nonatomic) SentryTracesSamplerCallback _Nullable profilesSampler;
[NullAllowed, Export ("profilesSampler", ArgumentSemantic.Assign)]
Func<SentrySamplingContext, NSNumber?> ProfilesSampler { get; set; }
// @property (nonatomic) SentryTracesSamplerCallback _Nullable profilesSampler;
[NullAllowed, Export ("profilesSampler", ArgumentSemantic.Assign)]
Func<SentrySamplingContext, NSNumber?> ProfilesSampler { get; set; }

// @property (readonly, assign, nonatomic) BOOL isProfilingEnabled;
[Export ("isProfilingEnabled")]
bool IsProfilingEnabled { get; }
// @property (readonly, assign, nonatomic) BOOL isProfilingEnabled;
[Export ("isProfilingEnabled")]
bool IsProfilingEnabled { get; }

// @property (assign, nonatomic) BOOL enableProfiling __attribute__((deprecated("Use profilesSampleRate or profilesSampler instead. This property will be removed in a future version of the SDK")));
// @property (assign, nonatomic) BOOL enableProfiling __attribute__((deprecated("Use profilesSampleRate or profilesSampler instead. This property will be removed in a future version of the SDK")));
[Export ("enableProfiling")]
bool EnableProfiling { get; set; }

Expand All @@ -1016,6 +1051,18 @@ interface SentryOptions
// @property (retain, nonatomic) NSArray * _Nonnull tracePropagationTargets;
[Export ("tracePropagationTargets", ArgumentSemantic.Retain)]
NSObject[] TracePropagationTargets { get; set; }

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

// @property (nonatomic, strong) NSArray<SentryHttpStatusCodeRange *> * _Nonnull failedRequestStatusCodes;
[Export ("failedRequestStatusCodes", ArgumentSemantic.Strong)]
SentryHttpStatusCodeRange[] FailedRequestStatusCodes { get; set; }

// @property (nonatomic, strong) NSArray * _Nonnull failedRequestTargets;
[Export ("failedRequestTargets", ArgumentSemantic.Strong)]
NSObject[] FailedRequestTargets { get; set; }
}

// @protocol SentryIntegrationProtocol <NSObject>
Expand All @@ -1024,10 +1071,10 @@ interface SentryOptions
[Internal]
interface SentryIntegrationProtocol
{
// @required -(BOOL)installWithOptions:(SentryOptions * _Nonnull)options;
// @required -(BOOL)installWithOptions:(SentryOptions * _Nonnull)options;
[Abstract]
[Export ("installWithOptions:")]
bool InstallWithOptions (SentryOptions options);
bool InstallWithOptions (SentryOptions options);

// @optional -(void)uninstall;
[Export ("uninstall")]
Expand Down Expand Up @@ -1301,9 +1348,9 @@ interface SentryHub
[Export ("bindClient:")]
void BindClient ([NullAllowed] SentryClient client);

// -(BOOL)hasIntegration:(NSString * _Nonnull)integrationName;
[Export ("hasIntegration:")]
bool HasIntegration (string integrationName);
// -(BOOL)hasIntegration:(NSString * _Nonnull)integrationName;
[Export ("hasIntegration:")]
bool HasIntegration (string integrationName);

// -(BOOL)isIntegrationInstalled:(Class _Nonnull)integrationClass;
[Export ("isIntegrationInstalled:")]
Expand Down Expand Up @@ -1601,6 +1648,40 @@ interface SentryNSError : SentrySerializable
NativeHandle Constructor (string domain, nint code);
}

// @interface SentryRequest : NSObject <SentrySerializable>
[BaseType (typeof(NSObject))]
[Internal]
interface SentryRequest : SentrySerializable
{
// @property (copy, nonatomic) NSNumber * _Nullable bodySize;
[NullAllowed, Export ("bodySize", ArgumentSemantic.Copy)]
NSNumber BodySize { get; set; }

// @property (copy, nonatomic) NSString * _Nullable cookies;
[NullAllowed, Export ("cookies")]
string Cookies { get; set; }

// @property (nonatomic, strong) NSDictionary<NSString *,NSString *> * _Nullable headers;
[NullAllowed, Export ("headers", ArgumentSemantic.Strong)]
NSDictionary<NSString, NSString> Headers { get; set; }

// @property (copy, nonatomic) NSString * _Nullable fragment;
[NullAllowed, Export ("fragment")]
string Fragment { get; set; }

// @property (copy, nonatomic) NSString * _Nullable method;
[NullAllowed, Export ("method")]
string Method { get; set; }

// @property (copy, nonatomic) NSString * _Nullable queryString;
[NullAllowed, Export ("queryString")]
string QueryString { get; set; }

// @property (copy, nonatomic) NSString * _Nullable url;
[NullAllowed, Export ("url")]
string Url { get; set; }
}

// @interface SentrySDK : NSObject
[BaseType (typeof(NSObject), Name="SentrySDK")]
[DisableDefaultCtor]
Expand Down Expand Up @@ -2086,6 +2167,10 @@ interface SentryStacktrace : SentrySerializable
[Export ("registers", ArgumentSemantic.Strong)]
NSDictionary<NSString, NSString> Registers { get; set; }

// @property (copy, nonatomic) NSNumber * _Nullable snapshot;
[NullAllowed, Export ("snapshot", ArgumentSemantic.Copy)]
NSNumber Snapshot { get; set; }

// -(instancetype _Nonnull)initWithFrames:(NSArray<SentryFrame *> * _Nonnull)frames registers:(NSDictionary<NSString *,NSString *> * _Nonnull)registers;
[Export ("initWithFrames:registers:")]
NativeHandle Constructor (SentryFrame[] frames, NSDictionary<NSString, NSString> registers);
Expand Down Expand Up @@ -2163,9 +2248,9 @@ interface SentryTransactionContext
[Export ("name")]
string Name { get; }

// @property (readonly, nonatomic) SentryTransactionNameSource nameSource;
[Export ("nameSource")]
SentryTransactionNameSource NameSource { get; }
// @property (readonly, nonatomic) SentryTransactionNameSource nameSource;
[Export ("nameSource")]
SentryTransactionNameSource NameSource { get; }

// @property (nonatomic) SentrySampleDecision parentSampled;
[Export ("parentSampled", ArgumentSemantic.Assign)]
Expand Down Expand Up @@ -2193,8 +2278,8 @@ interface SentryTransactionContext
[Internal]
interface SentryUser : SentrySerializable //, INSCopying
{
// @property (copy, atomic) NSString * _Nullable userId;
[NullAllowed, Export ("userId")]
// @property (copy, atomic) NSString * _Nullable userId;
[NullAllowed, Export ("userId")]
string UserId { get; set; }

// @property (copy, atomic) NSString * _Nullable email;
Expand Down
Loading