packages/core/ios — Objective-C & Swift
Task
Command
ObjC/C++ format (clang-format)
yarn fix:clang
Swift format (swiftlint)
yarn fix:swift
ObjC/C++ lint check
yarn lint:clang
Swift lint check
yarn lint:swift
Use clang-format (enforced by CI)
Prefix classes with RNSentry
Use nullability annotations (nullable, nonnull)
Use swiftlint (enforced by CI)
Follow Swift API design guidelines
NSError *error = nil ;
BOOL success = [self performOperation: &error];
if (!success) {
[SentryLog logWithMessage: [NSString stringWithFormat: @" Operation failed: %@ " , error]
andLevel: kSentryLevelError ];
return fallback;
}
Native Bridge Pattern (Objective-C)
RCT_EXPORT_METHOD (nativeOperation:(NSString *)param
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
@try {
BOOL result = [self performOperation: param];
resolve (@(result));
} @catch (NSException *exception) {
reject (@" OPERATION_FAILED" , exception.reason , nil );
}
}
Working with Local sentry-cocoa
Build sentry-cocoa: cd sentry-cocoa && make init
Edit RNSentry.podspec to remove version constraint
Add local pod to sample's Podfile:
pod 'Sentry/HybridSDK' , :path => '../../../../sentry-cocoa'