Skip to content

Commit cae4c90

Browse files
antonisclaude
andauthored
chore(ios): Upgrade clang-format from v20 to v22 (#5905)
* build(ios): Upgrade clang-format from v20 to v22 Homebrew now installs clang-format v22 which formats ObjC empty dictionary literals as `@{ }` instead of `@{}`. This caused a mismatch between local formatting and CI (which used v20), making it impossible to commit clang-format fixes that pass CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): Use pip to install clang-format v22 apt.llvm.org only has packages up to v20 (current stable). Use pip to install clang-format 22.1.2 which matches the Homebrew version developers have locally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): Add --break-system-packages for pip install Ubuntu 24.04 uses PEP 668 externally managed environments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): Keep LLVM apt setup for clang/lld/lldb, use pip for clang-format Restore the apt LLVM v20 installation for clang, lld, and lldb (needed for native builds) and install clang-format v22 separately via pip since apt.llvm.org doesn't have v22 packages yet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): Use apt.llvm.org for clang-format v22 The LLVM apt repo does have v22 packages (development branch). Use the standard llvm.sh + apt-get approach with update-alternatives, same as the original v20 setup but bumped to v22. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): Pass version arg correctly to llvm.sh `sudo bash -c "$(cmd)" 22` passes 22 to sudo, not to the script. Use `wget | sudo bash -s 22` to correctly pass the version argument. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0a60617 commit cae4c90

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

.github/workflows/buildandtest.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ jobs:
5353

5454
# Default of ubuntu and apt packages are too old compared to macos packages.
5555
# This is required for using a newer version of clang-format.
56-
- name: Setup clang-format V20
56+
- name: Setup clang-format V22
5757
run: |
58-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" 20
59-
sudo apt-get install -y clang-20 clang-format-20 lld-20 lldb-20
58+
wget -O - https://apt.llvm.org/llvm.sh | sudo bash -s 22
59+
sudo apt-get install -y clang-22 clang-format-22 lld-22 lldb-22
6060
61-
- name: Set clang-format V20 as default
61+
- name: Set clang-format V22 as default
6262
run: |
63-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200
64-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200
65-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200
63+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 200
64+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 200
65+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-22 200
6666
clang --version
6767
clang-format --version
6868

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ - (void)testCreateUserWithPartialGeoDataCreatesSentryGeoObject
10141014
NSDictionary *userKeys =
10151015
@{ @"id" : @"456", @"geo" : @ { @"city" : @"New York", @"country_code" : @"US" } };
10161016

1017-
NSDictionary *userDataKeys = @{};
1017+
NSDictionary *userDataKeys = @{ };
10181018

10191019
SentryUser *user = [RNSentry userFrom:userKeys otherUserKeys:userDataKeys];
10201020

@@ -1031,9 +1031,9 @@ - (void)testCreateUserWithPartialGeoDataCreatesSentryGeoObject
10311031

10321032
- (void)testCreateUserWithEmptyGeoDataCreatesSentryGeoObject
10331033
{
1034-
NSDictionary *userKeys = @{ @"id" : @"789", @"geo" : @ {} };
1034+
NSDictionary *userKeys = @{ @"id" : @"789", @"geo" : @ { } };
10351035

1036-
NSDictionary *userDataKeys = @{};
1036+
NSDictionary *userDataKeys = @{ };
10371037

10381038
SentryUser *user = [RNSentry userFrom:userKeys otherUserKeys:userDataKeys];
10391039

@@ -1052,7 +1052,7 @@ - (void)testCreateUserWithoutGeoDataDoesNotCreateGeoObject
10521052
{
10531053
NSDictionary *userKeys = @{ @"id" : @"999", @"email" : @"test@example.com" };
10541054

1055-
NSDictionary *userDataKeys = @{};
1055+
NSDictionary *userDataKeys = @{ };
10561056

10571057
SentryUser *user = [RNSentry userFrom:userKeys otherUserKeys:userDataKeys];
10581058

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUserTests.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ - (void)testNullUser
5151
- (void)testEmptyUser
5252
{
5353
SentryUser *expected = [[SentryUser alloc] init];
54-
[expected setData:@{}];
54+
[expected setData:@{ }];
5555

56-
SentryUser *actual = [RNSentry userFrom:@{} otherUserKeys:@{}];
56+
SentryUser *actual = [RNSentry userFrom:@{ } otherUserKeys:@{ }];
5757
XCTAssertTrue([actual isEqualToUser:expected]);
5858
}
5959

@@ -63,9 +63,9 @@ - (void)testInvalidUser
6363

6464
SentryUser *actual = [RNSentry userFrom:@{
6565
@"id" : @123,
66-
@"ip_address" : @ {},
67-
@"email" : @ {},
68-
@"username" : @ {},
66+
@"ip_address" : @ { },
67+
@"email" : @ { },
68+
@"username" : @ { },
6969
}
7070
otherUserKeys:nil];
7171

@@ -79,9 +79,9 @@ - (void)testPartiallyInvalidUser
7979

8080
SentryUser *actual = [RNSentry userFrom:@{
8181
@"id" : @"123",
82-
@"ip_address" : @ {},
83-
@"email" : @ {},
84-
@"username" : @ {},
82+
@"ip_address" : @ { },
83+
@"email" : @ { },
84+
@"username" : @ { },
8585
}
8686
otherUserKeys:nil];
8787

@@ -156,7 +156,7 @@ - (void)testUserWithEmptyGeo
156156
SentryGeo *expectedGeo = [SentryGeo alloc];
157157
[expected setGeo:expectedGeo];
158158

159-
SentryUser *actual = [RNSentry userFrom:@{ @"id" : @"123", @"geo" : @ {} } otherUserKeys:nil];
159+
SentryUser *actual = [RNSentry userFrom:@{ @"id" : @"123", @"geo" : @ { } } otherUserKeys:nil];
160160

161161
XCTAssertTrue([actual isEqualToUser:expected]);
162162
}

packages/core/ios/RNSentry.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ - (void)stopObserving
299299
- (void)handleShakeDetected
300300
{
301301
if (_shakeDetectionEnabled) {
302-
[self sendEventWithName:RNSentryOnShakeEvent body:@{}];
302+
[self sendEventWithName:RNSentryOnShakeEvent body:@{ }];
303303
}
304304
}
305305

packages/core/ios/RNSentryReplay.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ + (BOOL)updateOptions:(NSMutableDictionary *)options
2323
}
2424

2525
NSLog(@"Setting up session replay");
26-
NSDictionary *replayOptions = options[@"mobileReplayOptions"] ?: @{};
26+
NSDictionary *replayOptions = options[@"mobileReplayOptions"] ?: @{ };
2727

2828
NSString *qualityString = options[@"replaysSessionQuality"];
2929

packages/core/ios/RNSentrySDK.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ + (void)start:(NSString *)path configureOptions:(void (^)(SentryOptions *options
6060
if (options == nil) {
6161
// Fallback in case that options file could not be parsed.
6262
NSError *fallbackError = nil;
63-
options = [PrivateSentrySDKOnly optionsWithDictionary:@{} didFailWithError:&fallbackError];
63+
options = [PrivateSentrySDKOnly optionsWithDictionary:@{ } didFailWithError:&fallbackError];
6464
if (fallbackError != nil) {
6565
NSLog(@"[RNSentry] Failed to create fallback options with error: %@",
6666
fallbackError.localizedDescription);

samples/react-native-macos/macos/sentry-react-native-sample-macOS/AppDelegate.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
99
self.moduleName = @"sentry-react-native-sample";
1010
// You can add your custom initial props in the dictionary below.
1111
// They will be passed down to the ViewController used by React Native.
12-
self.initialProps = @{};
12+
self.initialProps = @{ };
1313

1414
return [super applicationDidFinishLaunching:notification];
1515
}

samples/react-native/ios/sentryreactnativesample/AppDelegate.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (BOOL)application:(UIApplication *)application
4747

4848
[self.reactNativeFactory startReactNativeWithModuleName:@"sentry-react-native-sample"
4949
inWindow:self.window
50-
initialProperties:@{}
50+
initialProperties:@{ }
5151
launchOptions:launchOptions];
5252

5353
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

scripts/clang-format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eo pipefail
44

55
echo "💡 If you get 'spawn Unknown system error -86', try running this script manually:"
66
echo " ./scripts/clang-format.sh $1"
7-
echo "💡 It is also recommended to use clang-version v20 or v21."
7+
echo "💡 It is also recommended to use clang-format v22 or newer."
88

99
# Prioritize finding clang-format executable from brew since the run-s may introduce X86/ARM64 mismatch.
1010
CLANG_FORMAT_PATH=""
@@ -34,7 +34,7 @@ if ! printf '%s' "$CLANG_MAJOR_VERSION" | grep -qE '^[0-9]+$'; then
3434
exit 1
3535
fi
3636

37-
REQUIRED_MAJOR=20
37+
REQUIRED_MAJOR=22
3838
if [ "$CLANG_MAJOR_VERSION" -lt "$REQUIRED_MAJOR" ]; then
3939
echo "❌ clang-format major version $CLANG_MAJOR_VERSION is lower than required $REQUIRED_MAJOR"
4040
exit 1

0 commit comments

Comments
 (0)