Skip to content

Commit

Permalink
chore: Expose sentry private header to Swift (#3703)
Browse files Browse the repository at this point in the history
This change allows us to use Objc private classes in swift code
  • Loading branch information
brustolin authored Mar 4, 2024
1 parent e3adcd5 commit 7512778
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Sentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Pod::Spec.new do |s|
'GCC_ENABLE_CPP_EXCEPTIONS' => 'YES',
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
'CLANG_CXX_LIBRARY' => 'libc++',
'APPLICATION_EXTENSION_API_ONLY' => 'YES'
'APPLICATION_EXTENSION_API_ONLY' => 'YES',
'SWIFT_INCLUDE_PATHS' => '${PODS_TARGET_SRCROOT}/Sources/Sentry/include'
}
s.watchos.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -framework WatchKit'
Expand All @@ -31,7 +32,7 @@ Pod::Spec.new do |s|

s.subspec 'Core' do |sp|
sp.source_files = "Sources/Sentry/**/*.{h,hpp,m,mm,c,cpp}",
"Sources/SentryCrash/**/*.{h,hpp,m,mm,c,cpp}", "Sources/Swift/**/*.{swift,h,hpp,m,mm,c,cpp}"
"Sources/SentryCrash/**/*.{h,hpp,m,mm,c,cpp}", "Sources/Swift/**/*.{swift,h,hpp,m,mm,c,cpp}", "Sources/Sentry/include/module.modulemap"
sp.public_header_files =
"Sources/Sentry/Public/*.h"
sp.resource_bundles = { "Sentry" => "Sources/Resources/PrivacyInfo.xcprivacy" }
Expand Down
26 changes: 24 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@
D8B0542E2A7D2C720056BAF6 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D8B0542D2A7D2C720056BAF6 /* PrivacyInfo.xcprivacy */; };
D8B088B629C9E3FF00213258 /* SentryTracerConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B088B429C9E3FF00213258 /* SentryTracerConfiguration.h */; };
D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = D8B088B529C9E3FF00213258 /* SentryTracerConfiguration.m */; };
D8B665BC2B95F73200BD0E7B /* SentryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B665BA2B95F54200BD0E7B /* SentryInternal.h */; };
D8B76B062808066D000A58C4 /* SentryScreenshotIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B76B042808060E000A58C4 /* SentryScreenshotIntegrationTests.swift */; };
D8B76B0828081461000A58C4 /* TestSentryScreenShot.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B76B0728081461000A58C4 /* TestSentryScreenShot.swift */; };
D8BBD32728FD9FC00011F850 /* SentrySwift.h in Headers */ = {isa = PBXBuildFile; fileRef = D8BBD32628FD9FBF0011F850 /* SentrySwift.h */; };
Expand Down Expand Up @@ -1719,7 +1720,6 @@
D8199DCF29376FF40074249E /* SentrySwiftUI.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SentrySwiftUI.xcconfig; sourceTree = "<group>"; };
D8199DD029377C130074249E /* SentrySwiftUI.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = SentrySwiftUI.podspec; sourceTree = "<group>"; };
D81A346B291AECC7005A27A9 /* PrivateSentrySDKOnly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PrivateSentrySDKOnly.h; path = include/HybridPublic/PrivateSentrySDKOnly.h; sourceTree = "<group>"; };
D81A349B291D0C0B005A27A9 /* Sentry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sentry.swift; sourceTree = "<group>"; };
D81A349F291D5568005A27A9 /* SentryPrivate.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = SentryPrivate.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
D81FDF10280EA0080045E0E4 /* SentryScreenShotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenShotTests.swift; sourceTree = "<group>"; };
D8292D7A2A38AF04009872F7 /* HTTPHeaderSanitizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPHeaderSanitizer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1780,6 +1780,8 @@
D8B0542D2A7D2C720056BAF6 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
D8B088B429C9E3FF00213258 /* SentryTracerConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTracerConfiguration.h; path = include/SentryTracerConfiguration.h; sourceTree = "<group>"; };
D8B088B529C9E3FF00213258 /* SentryTracerConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryTracerConfiguration.m; sourceTree = "<group>"; };
D8B665BA2B95F54200BD0E7B /* SentryInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryInternal.h; path = include/SentryInternal.h; sourceTree = "<group>"; };
D8B665BB2B95F5A100BD0E7B /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = Sources/Sentry/include/module.modulemap; sourceTree = SOURCE_ROOT; };
D8B76B042808060E000A58C4 /* SentryScreenshotIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotIntegrationTests.swift; sourceTree = "<group>"; };
D8B76B0728081461000A58C4 /* TestSentryScreenShot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryScreenShot.swift; sourceTree = "<group>"; };
D8BBD32628FD9FBF0011F850 /* SentrySwift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentrySwift.h; path = include/SentrySwift.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2330,6 +2332,7 @@
8ECC673625C23936000E2BF6 /* Transaction */,
8E25C94F25F836AB00DC215B /* Tools */,
63AA76931EB9C1C200D153DE /* Sentry.h */,
D8B665BA2B95F54200BD0E7B /* SentryInternal.h */,
D8BBD32628FD9FBF0011F850 /* SentrySwift.h */,
D81A346B291AECC7005A27A9 /* PrivateSentrySDKOnly.h */,
7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.mm */,
Expand Down Expand Up @@ -3326,8 +3329,8 @@
children = (
D856272A2A374A6800FB8062 /* Tools */,
7BF65060292B8EFE00BBA5A8 /* MetricKit */,
D81A349B291D0C0B005A27A9 /* Sentry.swift */,
D800942628F82F3A005D3943 /* SwiftDescriptor.swift */,
D8B665BB2B95F5A100BD0E7B /* module.modulemap */,
);
path = Swift;
sourceTree = "<group>";
Expand Down Expand Up @@ -3771,6 +3774,7 @@
63FE715320DA4C1100CDBAE8 /* SentryCrashObjCApple.h in Headers */,
63FE710120DA4C1000CDBAE8 /* SentryCrashDate.h in Headers */,
7B4E24FC251C97B500060D68 /* SentrySession.h in Headers */,
D8B665BC2B95F73200BD0E7B /* SentryInternal.h in Headers */,
7B7D872C2486480B00D2ECFF /* SentryStacktraceBuilder.h in Headers */,
7B42C48027E08F33009B58C2 /* SentryDependencyContainer.h in Headers */,
6334314120AD9AE40077E581 /* SentryMechanism.h in Headers */,
Expand Down Expand Up @@ -4773,6 +4777,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
Expand Down Expand Up @@ -4813,6 +4818,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
};
Expand All @@ -4838,11 +4844,13 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
OTHER_SWIFT_FLAGS = "-DSENTRY_USE_UIKIT";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down Expand Up @@ -4871,11 +4879,13 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
OTHER_SWIFT_FLAGS = "-DSENTRY_USE_UIKIT";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -4983,6 +4993,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
Expand All @@ -5009,11 +5020,13 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
OTHER_SWIFT_FLAGS = "-DSENTRY_USE_UIKIT";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down Expand Up @@ -5119,6 +5132,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
Expand All @@ -5145,10 +5159,12 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down Expand Up @@ -5603,6 +5619,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
};
Expand All @@ -5628,11 +5645,13 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
OTHER_SWIFT_FLAGS = "-DSENTRY_USE_UIKIT";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -5838,6 +5857,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry;
PRODUCT_NAME = Sentry;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Sources/Sentry/include/";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
USE_HEADERMAP = YES;
Expand All @@ -5864,11 +5884,13 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_PRIVATE_FILE = "";
OTHER_SWIFT_FLAGS = "-DSENTRY_USE_UIKIT";
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "Tests/SentryTests/SentryTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/include/SentryBaseIntegration.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#import "SentryOptions.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -25,6 +24,8 @@ typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) {
kIntegrationOptionEnableMetricKit = 1 << 17,
};

@class SentryOptions;

@interface SentryBaseIntegration : NSObject

- (NSString *)integrationName;
Expand Down
3 changes: 3 additions & 0 deletions Sources/Sentry/include/SentryInternal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Sentry internal headers that are needed for swift code

#import "SentryBaseIntegration.h"
3 changes: 3 additions & 0 deletions Sources/Sentry/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module _SentryPrivate {
header "SentryInternal.h"
}
3 changes: 0 additions & 3 deletions Sources/Swift/Sentry.swift

This file was deleted.

3 changes: 1 addition & 2 deletions Sources/Swift/SwiftDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import Foundation
class SwiftDescriptor: NSObject {

@objc
static func getObjectClassName(_ object: AnyObject) -> String {
static func getObjectClassName(_ object: AnyObject) -> String {
return String(describing: type(of: object))
}

@objc
static func getSwiftErrorDescription(_ error: Error) -> String? {
return String(describing: error)
}

}

0 comments on commit 7512778

Please sign in to comment.