### Quick Start Sentry and Pulse Integration Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentryPulse/README.md Initialize Sentry SDK with your DSN and enable logs, then start the Sentry Pulse integration. This setup allows for logging messages with context. ```swift import Sentry import Pulse import SentryPulse SentrySDK.start { options in options.dsn = "YOUR_DSN" options.enableLogs = true } SentryPulse.start() let logger = LoggerStore.shared.makeLogger(label: "com.example.app") logger.info("User logged in", metadata: ["userId": "12345"]) logger.error("Payment failed", metadata: ["errorCode": 500]) ``` -------------------------------- ### Quick Start: Initialize Sentry and SwiftLog Handler Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentrySwiftLog/README.md Initialize the Sentry SDK and configure a SentryLogHandler for SwiftLog. This setup captures logs with metadata and forwards them to Sentry. ```swift import Sentry import Logging SentrySDK.start { options in options.dsn = "YOUR_DSN" options.enableLogs = true } var handler = SentryLogHandler(logLevel: .info) handler.metadata["app_version"] = "1.0.0" handler.metadata["environment"] = "production" LoggingSystem.bootstrap { _ in handler } let logger = Logger(label: "com.example.app") logger.info("User logged in", metadata: ["userId": "12345"]) logger.error("Payment failed", metadata: ["errorCode": 500]) logger.warning("API rate limit approaching", metadata: ["remaining": 10]) logger.info("User action", metadata: [ "userId": "12345", "action": "purchase" ]) ``` -------------------------------- ### SentryCrash Integration Start Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Installs the SentryCrash handler at application startup. This is a crucial step for enabling crash reporting. ```objective-c SentryCrashIntegration.startCrashHandler() ``` -------------------------------- ### Install, Update, and List Sentry Agents Source: https://github.com/getsentry/sentry-cocoa/blob/main/CLAUDE.md Use these commands to manage Sentry agent skills. Run `install` after cloning and `update` to get the latest versions. ```bash npx @sentry/dotagents install # install skills after cloning ``` ```bash npx @sentry/dotagents update # update to latest versions ``` ```bash npx @sentry/dotagents list # show installed skills ``` -------------------------------- ### Quick Start Sentry and SwiftyBeaver Integration Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentrySwiftyBeaver/README.md Initialize Sentry SDK and add the SentryDestination to SwiftyBeaver to start sending logs. ```swift import Sentry import SwiftyBeaver SentrySDK.start { options in options.dsn = "YOUR_DSN" options.logsEnabled = true } let log = SwiftyBeaver.self let sentryDestination = SentryDestination() log.addDestination(sentryDestination) log.info("User logged in", context: ["userId": "12345", "sessionId": "abc"]) ``` -------------------------------- ### Install SentryCrash Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Call sentrycrash_install() to initialize SentryCrash, passing the cache directory for report storage. ```c // Assuming 'cacheDirectory' is a valid path string sentrycrash_install(cacheDirectory); ``` -------------------------------- ### Start Sentry SDK with SentryObjC Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/iOS-ObjectiveCpp-NoModules/README.md Import SentryObjC and use the provided configuration block to start the SDK. This approach ensures all Swift-bridged APIs are accessible even when Clang modules are disabled. ```objc #import [SentryObjCSDK startWithConfigureOptions:^(SentryOptions *options) { options.dsn = @"..."; options.tracesSampleRate = @1.0; options.sessionReplay.sessionSampleRate = 0; // All Swift APIs now available! }]; ``` -------------------------------- ### Setup Certificates and Provisioning Profiles Locally Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/README.md This command sets up certificates and provisioning profiles on your local machine. It's intended for Sentry employees who need to run samples on real devices. ```bash fastlane match_local ``` -------------------------------- ### Quick Start Sentry and CocoaLumberjack Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentryCocoaLumberjack/README.md Initialize Sentry SDK and add the SentryCocoaLumberjack logger to CocoaLumberjack. This setup enables automatic log forwarding to Sentry. ```swift import Sentry import SentryCocoaLumberjack import CocoaLumberjackSwift SentrySDK.start { options in options.dsn = "YOUR_DSN" options.enableLogs = true } DDLog.add(SentryCocoaLumberjackLogger(), with: .info) DDLogInfo("User logged in") DDLogError("Payment failed") DDLogWarn("API rate limit approaching") DDLogDebug("Processing request") DDLogVerbose("Detailed trace information") ``` -------------------------------- ### Access App Start API Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Provides access to the Sentry app start API. No platform guard is applied. ```swift SentrySDK.internal.appStart ``` -------------------------------- ### SentryInternalAppStartApi Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md APIs for configuring and retrieving app start measurements. ```APIDOC ## SentrySDK.internal.appStart — SentryInternalAppStartApi ### Description APIs for managing app start measurements, including hybrid SDK mode and measurement availability. ### Methods - `hybridSDKMode: Bool` - Replaces `appStartMeasurementHybridSDKMode`. - `measurementWithSpans: [String: Any]?` - Replaces `appStartMeasurementWithSpans`. - `measurement: SentryAppStartMeasurement?` - Replaces `appStartMeasurement`. - Platform guard: `SENTRY_UIKIT_AVAILABLE`. - `onMeasurementAvailable: ((SentryAppStartMeasurement?) -> Void)?` - Replaces `onAppStartMeasurementAvailable`. - Platform guard: `SENTRY_UIKIT_AVAILABLE`. ``` -------------------------------- ### Install and Uninstall C API for SentryCrash Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Use these C functions to install and uninstall the SentryCrash reporter. `sentrycrash_install` requires application name and path, while `sentrycrash_uninstall` performs cleanup. ```c SentryCrashMonitorType sentrycrash_install(const char *appName, const char *installPath); void sentrycrash_uninstall(void); ``` -------------------------------- ### Test SentryCrash iOS Installation Tests Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Run specific SentryCrash installation tests on iOS using the make test-ios command with the ONLY_TESTING argument. ```bash make test-ios ONLY_TESTING=SentryTests/SentryCrashInstallationTests,SentryTests/SentryCrashWrapperTests ``` -------------------------------- ### Example Directory Structure for Integrations Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/INTEGRATIONS.md Illustrates the proposed directory structure for self-contained third-party integrations within the sentry-cocoa repository. Each integration has its own subdirectory containing source code, tests, README, and Package.swift. ```bash 3rd-party-integration/ ├── SentryCocoaLumberjack/ │ ├── Sources/ │ ├── README.md │ └── Package.swift └── SentrySwiftLog/ ├── Sources/ ├── README.md └── Package.swift ``` -------------------------------- ### Test Server Management Source: https://github.com/getsentry/sentry-cocoa/blob/main/Tests/AGENTS.md Commands to start, stop, and run tests with the test server. The test server is primarily needed for `SentryNetworkTrackerIntegrationTestServerTests`. ```bash make run-test-server ``` ```bash ./scripts/sentry-xcodebuild.sh --platform iOS --command test --test-plan Sentry_TestServer ``` ```bash make stop-test-server ``` -------------------------------- ### Implement Codable for Sentry User in Swift Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/DECISIONS.md Provides an example of conforming a Swift class (representing SentryUser) to the Codable protocol. This includes defining CodingKeys and implementing encode(to:) and init(from:) methods for custom serialization and deserialization logic. ```swift @_implementationOnly import _SentryPrivate import Foundation // User is the Swift name of SentryUser extension User: Codable { private enum CodingKeys: String, CodingKey { case id case email case username case ipAddress } public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(userId, forKey: .id) try container.encode(email, forKey: .email) try container.encode(username, forKey: .username) try container.encode(ipAddress, forKey: .ipAddress) } public required convenience init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.init(userId: try container.decode(String.self, forKey: .id)) email = try container.decode(String.self, forKey: .email) username = try container.decode(String.self, forKey: .username) ipAddress = try container.decode(String.self, forKey: .ipAddress) } } ``` -------------------------------- ### Objective-C Serialization Implementation Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/DECISIONS.md An example implementation of the serialize method for an Objective-C object, returning a dictionary representation of its properties. ```objective-c - (NSDictionary *)serialize { return @{ @"city" : self.city, @"country_code" : self.countryCode, @"region" : self.region }; } ``` -------------------------------- ### Start Sentry Pulse with Custom LoggerStore Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentryPulse/README.md Initialize Sentry Pulse integration using a custom LoggerStore instance, allowing for specific configurations like in-memory storage. ```swift let customStore = try LoggerStore(storeURL: customURL, options: [.inMemory]) SentryPulse.start(loggerStore: customStore) ``` -------------------------------- ### Arrange-Act-Assert Test Structure Source: https://github.com/getsentry/sentry-cocoa/blob/main/Tests/AGENTS.md Demonstrates the Arrange-Act-Assert pattern for structuring tests. This pattern separates test setup, execution, and verification steps for clarity. ```swift func testExample() { // -- Arrange -- let input = "test" // -- Act -- let result = transform(input) // -- Assert -- XCTAssertEqual(result, "TEST") } ``` -------------------------------- ### Get Sentry Options from Dictionary Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Initializes and retrieves Sentry SDK options from a dictionary. This method supersedes `PrivateSentrySDKOnly.optionsWithDictionary:didFailWithError:`. ```swift SentrySDK.internal.options(fromDictionary:) throws -> Options ``` -------------------------------- ### Write Standard SentryCrash Report Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Use sentrycrashreport_writeStandardReport() to generate a report file at the specified installation path. Inspect the resulting JSON for verification. ```c // Assuming 'reportPath' is a valid path string sentrycrashreport_writeStandardReport(reportPath); ``` -------------------------------- ### Build Sample with Make Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/iOS-ObjectiveCpp-NoModules/README.md Alternatively, build the sample project using the provided make command from the repository root. ```bash make build-sample-iOS-ObjectiveCpp-NoModules ``` -------------------------------- ### Get Sentry SDK Installation ID Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Retrieve the unique installation ID for the Sentry SDK using `SentrySDK.internal.sdk.installationID`. This ID is used to identify a specific installation of the SDK. ```swift let installationID = SentrySDK.internal.sdk.installationID ``` -------------------------------- ### Makefile Commands for Sample Project Management Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/AGENTS.md Provides a comprehensive list of Makefile commands for generating, building, and testing sample applications. Use these commands for consistent sample management. ```bash # Regenerate all Xcode projects make xcode-ci ``` ```bash # Regenerate specific project (e.g., `xcode-ci-SPM`) make xcode-ci- ``` ```bash # Build all sample apps make build-samples ``` ```bash # Build specific sample (e.g., `build-sample-iOS-Swift`) make build-sample- ``` ```bash # Run all sample UI tests make test-samples-ui ``` ```bash # Run specific sample UI tests (e.g., `iOS-Swift-ui`) make test-sample--ui ``` ```bash # Run critical UI test suites for validation make test-ui-critical ``` -------------------------------- ### Get Installed Sentry Integration Names Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Use `SentrySDK.internal.sdk.installedIntegrationNames` to get a set of class names for integrations currently registered with `SentryHub`. This property returns an empty set before `SentrySDK.start()` or after `SentrySDK.close()`. ```swift let installedIntegrations = SentrySDK.internal.sdk.installedIntegrationNames ``` -------------------------------- ### Get Trimmed Installed Sentry Integration Names Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Use `SentrySDK.internal.sdk.trimmedInstalledIntegrationNames` to get an array of shortened integration names. This is useful for populating the `sdk.integrations` field in event payloads, matching the format used by `SentrySdkInfo`. ```swift let trimmedIntegrations = SentrySDK.internal.sdk.trimmedInstalledIntegrationNames ``` -------------------------------- ### Build and Test for Build System / Package.swift Changes Source: https://github.com/getsentry/sentry-cocoa/blob/main/AGENTS.md Execute for modifications to the build system or `Package.swift`. Tests across all platforms. ```bash make build-ios make build-macos make build-tvos make build-watchos make build-visionos make test ``` -------------------------------- ### Initialize Sentry SDK in Swift Source: https://github.com/getsentry/sentry-cocoa/blob/main/README.md Call this as early as possible in your application's lifecycle, ideally in `applicationDidFinishLaunching`. Ensure you replace `___PUBLIC_DSN___` with your actual DSN. ```swift import Sentry // .... SentrySDK.start { options in options.dsn = "___PUBLIC_DSN___" options.debug = true // Helpful to see what's going on } ``` -------------------------------- ### Initialize Sentry SDK in Objective-C Source: https://github.com/getsentry/sentry-cocoa/blob/main/README.md Call this as early as possible in your application's lifecycle, ideally in `applicationDidFinishLaunching`. Ensure you replace `___PUBLIC_DSN___` with your actual DSN. ```objc @import Sentry; // .... [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { options.dsn = @"___PUBLIC_DSN___"; options.debug = @YES; // Helpful to see what's going on }]; ``` -------------------------------- ### SentryCrash Objective-C API - Installation and Management Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Manage the SentryCrash reporter lifecycle and access crash reports using Objective-C methods. Includes installation, uninstallation, and report retrieval. ```objc - (BOOL)install; - (void)uninstall; - (NSArray *)reportIDs; - (NSDictionary *)reportWithID:(NSNumber *)reportID; - (void)deleteReportWithID:(NSNumber *)reportID; - (void)sendAllReportsWithCompletion:(SentryCrashReportFilterCompletion)onCompletion; ``` -------------------------------- ### SentryCrash Initialization Sequence Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md Illustrates the sequence of operations during SentrySDK initialization, focusing on the SentryCrash integration. ```text SentrySDK.start(options:) → SentryHub creation → SentryClient init → Install integrations → SentryCrashIntegration.init (if enableCrashHandler = true) ├── Create SentryCrashWrapper ├── Create SentryCrashScopeObserver ├── Create SentryCrashIntegrationSessionHandler ├── startCrashHandler(): │ ├── sentrycrashcm_setSigtermReporting() (if enabled) │ ├── SentryCrashInstallationReporter.install(cacheDirectory) │ │ └── C: sentrycrash_install(appName, installPath) │ ├── sentrycrashcm_cppexception_enable_swap_cxa_throw() (if enabled) │ ├── sessionHandler.endCurrentSessionIfRequired() │ └── installation.sendAllReports() ← sends pending crash reports ├── configureScope(): │ ├── Serialize scope → crashReporter.userInfo → sentrycrash_setUserInfoJSON() │ └── Register scope observer for live updates └── configureTracingWhenCrashing() (if enabled): └── sentrycrash_setSaveTransaction(callback) ``` -------------------------------- ### Directory Layout for Sample Projects Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/AGENTS.md Defines the standard directory structure for Sentry sample projects, including source files, resources, and configuration. ```text TargetName/ ├── Sources/ # Swift/ObjC source files ├── Resources/ # Assets, storyboards └── Configuration/ # Info.plist, entitlements, xcconfig ``` -------------------------------- ### Build Sentry-Dynamic XCFramework Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/BUILD.md Use this command to build the dynamic XCFramework for the Sentry SDK. This is part of the standard build process. ```bash make build-xcframework-dynamic ``` -------------------------------- ### Get Sentry Options Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Retrieves the current Sentry SDK options. This method supersedes `PrivateSentrySDKOnly.options`. ```swift SentrySDK.internal.options ``` -------------------------------- ### Run Linters Locally Source: https://github.com/getsentry/sentry-cocoa/blob/main/CONTRIBUTING.md Execute all configured linters, including SwiftLint and Clang-Format, by running the 'lint' make command. ```sh make lint ``` -------------------------------- ### C API Functions Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRYCRASH.md These C functions provide the core interface for installing, uninstalling, and configuring Sentry crash monitoring. ```APIDOC ## C API (`SentryCrashC.h`) ### Functions #### `sentrycrash_install` * **Description**: Installs the Sentry crash reporting mechanism. * **Parameters**: * `appName` (const char *) - Required - The name of the application. * `installPath` (const char *) - Required - The path for crash report installation. * **Return Value**: `SentryCrashMonitorType` - The type of monitors installed. #### `sentrycrash_uninstall` * **Description**: Uninstalls the Sentry crash reporting mechanism. #### `sentrycrash_setMonitoring` * **Description**: Sets the crash monitors to be active. * **Parameters**: * `monitors` (`SentryCrashMonitorType`) - Required - The monitors to enable. * **Return Value**: `SentryCrashMonitorType` - The previously set monitor types. #### `sentrycrash_setUserInfoJSON` * **Description**: Sets user information in JSON format to be included in crash reports. * **Parameters**: * `userInfoJSON` (const char *) - Required - A JSON string containing user information. #### `sentrycrash_setCrashNotifyCallback` * **Description**: Sets a callback function to be invoked when a crash report is written. * **Parameters**: * `onCrashNotify` (`SentryCrashReportWriteCallback`) - Required - The callback function. #### `sentrycrash_setSaveScreenshots` * **Description**: Sets a callback to save screenshots when a crash occurs. * **Parameters**: * `callback` (void (*)(const char *)) - Required - Callback function that takes a path to save the screenshot. #### `sentrycrash_setSaveViewHierarchy` * **Description**: Sets a callback to save the view hierarchy when a crash occurs. * **Parameters**: * `callback` (void (*)(const char *)) - Required - Callback function that takes a path to save the view hierarchy. #### `sentrycrash_setSaveTransaction` * **Description**: Sets a callback to save transaction information when a crash occurs. * **Parameters**: * `callback` (void (*)(void)) - Required - Callback function to save transaction data. ``` -------------------------------- ### Trace +load Method Execution with OBJC_PRINT_LOAD_METHODS Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/OBJC-LOAD-AND-LINKING.md Set the `OBJC_PRINT_LOAD_METHODS` environment variable to `YES` to trace which `+load` methods the Objective-C runtime invokes. This is useful for confirming that `+load` methods are executed as expected during application startup. ```bash $ OBJC_PRINT_LOAD_METHODS=YES .build/release/cli-with-spm 2>&1 | grep -i "sentry" objc[10982]: LOAD: class 'SentryCrashDefaultMachineContextWrapper' scheduled for +load objc[10982]: LOAD: class 'SentryProfiler' scheduled for +load objc[10982]: LOAD: class 'SentrySysctlObjC' scheduled for +load objc[10982]: LOAD: +[SentryCrashDefaultMachineContextWrapper load] objc[10982]: LOAD: +[SentryProfiler load] objc[10982]: LOAD: +[SentrySysctlObjC load] ``` -------------------------------- ### Dockerfile for MuPDF Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/VIEW_MASKING_STRATEGIES.md This Dockerfile sets up a Debian-based environment to download, build, and install MuPDF. It uses multi-stage builds for efficiency. ```Dockerfile # ================================================================================================================ # Downloader # ================================================================================================================ FROM debian:latest AS downloader WORKDIR /tmp RUN apt-get update \ && apt-get install -y wget \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* RUN wget -O mupdf-1.26.11-source.tar.gz https://casper.mupdf.com/downloads/archive/mupdf-1.26.11-source.tar.gz RUN tar -xzf mupdf-1.26.11-source.tar.gz && rm mupdf-1.26.11-source.tar.gz RUN mv mupdf-1.26.11-source mupdf # ================================================================================================================ # Builder # ================================================================================================================ FROM debian:latest AS builder RUN apt-get update && apt-get install -y gcc g++ make pkg-config && apt-get clean && rm -rf /var/lib/apt/lists/* COPY --from=downloader /tmp/mupdf /tmp/mupdf WORKDIR /tmp/mupdf RUN make # ================================================================================================================ # Release # ================================================================================================================ FROM debian:latest AS release RUN apt-get update && apt-get install -y make && apt-get clean && rm -rf /var/lib/apt/lists/* COPY --from=builder /tmp/mupdf /tmp/mupdf RUN cd /tmp/mupdf && make install && rm -rf /tmp/mupdf ``` -------------------------------- ### Regenerate Sample Projects with Makefile Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/AGENTS.md Use the Makefile to regenerate sample Xcode projects. This ensures correct build order and dependencies. Avoid running `xcodegen` directly. ```bash # Regenerate a specific project (without building) make xcode-ci-iOS-Swift ``` ```bash # Regenerate all Xcode projects make xcode-ci ``` ```bash # Regenerate AND build a specific sample make build-sample-iOS-Swift ``` -------------------------------- ### Local Build Flow for SentryObjC Static Library Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-OBJC-BUILD.md Illustrates the local build flow for creating a static SentryObjC library. It involves archiving via SPM to resolve dependencies, extracting object files, and using libtool to create the static library, followed by assembling the xcframework. ```bash for each SDK: scripts/build-static-library-sentryobjc.sh --sdk → xcodebuild archive (via SPM, resolves full dependency chain) → find .o files in xcarchive → libtool -static → libSentryObjC.a scripts/assemble-xcframework-sentryobjc.sh → xcodebuild -create-xcframework -library ... -headers ... → SentryObjC-Static.xcframework ``` -------------------------------- ### Build Dynamic XCFramework Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-OBJC-BUILD.md Builds the dynamic XCFramework by first creating static slices, then re-linking them as dynamic libraries, and finally assembling the XCFramework. Specify the SDKs to include in the build. ```makefile build-xcframework-sentryobjc-dynamic SDKS=... ``` -------------------------------- ### Get Sentry SDK Extra Context Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Access `SentrySDK.internal.sdk.extraContext` to retrieve any extra context information configured for the SDK. This property is read-only. ```swift let extraContext = SentrySDK.internal.sdk.extraContext ``` -------------------------------- ### Generate Project with Xcodegen Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/iOS-ObjectiveCpp-NoModules/README.md Use Xcodegen to generate the project files for the sample application. This command should be run from the sample's directory. ```bash cd Samples/iOS-ObjectiveCpp-NoModules xcodegen generate ``` -------------------------------- ### Platform-Conditional Compilation for Header Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-OBJC.md Use `#if` directives in Objective-C headers to conditionally expose APIs based on platform support. This example shows how to guard the `replay` property. ```objc #if SENTRY_OBJC_REPLAY_SUPPORTED @property (class, nonatomic, readonly) SentryObjCReplayApi *replay; #endif ``` -------------------------------- ### Build and Test Commands by Change Scope Source: https://github.com/getsentry/sentry-cocoa/blob/main/CLAUDE.md Use these commands to build and test specific platforms or components based on the scope of your changes. Ensure all relevant platforms are covered for cross-platform concerns. ```bash make build-ios ``` ```bash make test-ios ``` ```bash make build-macos ``` ```bash make test-macos ``` ```bash make build-tvos ``` ```bash make build-watchos ``` ```bash make build-visionos ``` ```bash make test ``` -------------------------------- ### SentrySDK.internal.sdk Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Provides access to internal SDK information, including its name, version, added packages, and installed integrations. This is useful for hybrid SDKs to enrich event payloads. ```APIDOC ## `SentrySDK.internal.sdk` — `SentryInternalSdkApi` Provides access to internal SDK information. ### Properties - **`name`** (String) - Read-write - Gets or sets the SDK name. - **`versionString`** (String) - Read-only - Gets the SDK version string. - **`installationID`** (String) - Read-only - Gets the installation ID. - **`installedIntegrationNames`** (Set) - Read-only - Gets the set of currently installed integration class names. Returns an empty set before `SentrySDK.start()` or after `SentrySDK.close()`. - **`trimmedInstalledIntegrationNames`** ([String]) - Read-only - Gets the trimmed names of currently installed integrations, matching `SentrySdkInfo` serialization. Prefer this for enriching Dart/JS events. ### Methods - **`setName(_:version:)`** - Description: Sets the SDK name and version. - Parameters: - `name` (String) - Required - The name of the SDK. - `version` (String) - Required - The version of the SDK. - **`addPackage(name:version:)`** - Description: Adds a package to the SDK information. - Parameters: - `name` (String) - Required - The name of the package. - `version` (String) - Required - The version of the package. ### Context - **`extraContext`** ([String: Any]) - Read-only - Gets the extra context information for the SDK. ``` -------------------------------- ### Platform-Conditional Compilation for Wrapper Implementation Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-OBJC.md Use `#if canImport` and platform macros in Swift wrappers to conditionally implement APIs. This example guards the `replay` property for iOS and tvOS. ```swift #if canImport(UIKit) && !SENTRY_NO_UI_FRAMEWORK && (os(iOS) || os(tvOS)) @objc public static var replay: SentryObjCReplayApi { SentryObjCReplayApi(SentrySDK.replay) } #endif ``` -------------------------------- ### Stop and Restart Sentry Pulse Integration Source: https://github.com/getsentry/sentry-cocoa/blob/main/3rd-party-integrations/SentryPulse/README.md Manually stop and restart the Sentry Pulse integration. Note that calling start() multiple times has no additional effect after the first call. ```swift SentryPulse.stop() SentryPulse.start() ``` -------------------------------- ### Create Provisioning Profile with Fastlane Source: https://github.com/getsentry/sentry-cocoa/blob/main/Samples/README.md Run this command to create a development provisioning profile for an existing app identifier. Ensure your personal ADP account email is configured in the Matchfile. ```bash rbenv exec bundle exec fastlane match development --app_identifier io.sentry.sample.iOS-Swift.FileProvider ``` -------------------------------- ### Set Sentry SDK Name and Version Source: https://github.com/getsentry/sentry-cocoa/blob/main/develop-docs/SENTRY-INTERNAL-API.md Use `SentrySDK.internal.sdk.name` and `SentrySDK.internal.sdk.versionString` to get or set the SDK's name and version. The `setName(_:version:)` method provides a combined way to set both properties. ```swift SentrySDK.internal.sdk.name = "MyHybridSDK" SentrySDK.internal.sdk.versionString = "1.2.3" ``` ```swift SentrySDK.internal.sdk.setName("MyHybridSDK", version: "1.2.3") ```