Skip to content

Commit 90619ef

Browse files
authored
Enable ccache for faster builds (#335)
1 parent 6a7d0db commit 90619ef

File tree

6 files changed

+61
-14
lines changed

6 files changed

+61
-14
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ yarn sample start
4444
This command will start the Metro server. Follow the steps given by Metro to
4545
open both the iOS and Android simulators/emulators respectively.
4646

47+
## Optional: Speed up builds with ccache
48+
49+
For faster native compilation (especially on incremental builds), you can install [ccache](https://ccache.dev/), a compiler cache:
50+
51+
```sh
52+
# macOS (using Homebrew)
53+
brew install ccache
54+
55+
# Ubuntu/Debian
56+
sudo apt-get install ccache
57+
58+
# Other systems: see https://ccache.dev/download.html
59+
```
60+
61+
The build scripts will automatically detect and use ccache if available. If you encounter any build issues, you can temporarily disable it:
62+
63+
```sh
64+
# Disable ccache for a single build
65+
CCACHE=false yarn sample ios
66+
CCACHE=false yarn sample android
67+
```
68+
4769
## Making changes to the Native Module
4870

4971
If your intentions are to modify the TS code for the Native Module under

dev.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
name: checkout-sheet-kit-react-native
22

3+
edition: 2024
4+
35
type: node
46

57
up:
8+
- packages:
9+
- swiftlint
10+
- ccache
611
- ruby
12+
- xcode:
13+
version: '26.0'
14+
runtimes:
15+
ios:
16+
- '26.0'
717
- node:
818
version: v20.11.1
919
yarn: 1.22.22
@@ -28,10 +38,6 @@ up:
2838
meet: |
2939
yarn module build
3040
31-
packages:
32-
- xcode
33-
- swiftlint
34-
3541
check:
3642
lint_swift: ./scripts/lint_swift
3743
lint_module: yarn module lint
@@ -57,6 +63,9 @@ commands:
5763
yarn module clean
5864
yarn sample clean
5965
yarn clean
66+
if command -v ccache >/dev/null 2>&1; then
67+
ccache -C
68+
fi
6069
echo "✅ Cleaned root, module and sample workspaces"
6170
6271
fix:

sample/ios/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ target 'ReactNative' do
3434

3535
post_install do |installer|
3636
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
37+
# Enable ccache by default - controlled via build script PATH manipulation
3738
react_native_post_install(
3839
installer,
3940
config[:reactNativePath],
4041
:mac_catalyst_enabled => false,
41-
# :ccache_enabled => true
42+
:ccache_enabled => true
4243
)
4344

4445
# WORKAROUND

sample/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,6 +2888,6 @@ SPEC CHECKSUMS:
28882888
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
28892889
Yoga: a742cc68e8366fcfc681808162492bc0aa7a9498
28902890

2891-
PODFILE CHECKSUM: 8b772325d9e3958706bda5b26aa6b2b8994a6f25
2891+
PODFILE CHECKSUM: 42a4ad42b0177ca0f927363d8f2b6059c6dd77c7
28922892

28932893
COCOAPODS: 1.15.2

sample/ios/ReactNative.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@
848848
isa = XCBuildConfiguration;
849849
buildSettings = {
850850
ALWAYS_SEARCH_USER_PATHS = NO;
851-
CC = "";
851+
CC = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
852+
CCACHE_BINARY = /opt/homebrew/bin/ccache;
852853
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
853854
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
854855
CLANG_CXX_LIBRARY = "libc++";
@@ -876,7 +877,7 @@
876877
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
877878
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
878879
COPY_PHASE_STRIP = NO;
879-
CXX = "";
880+
CXX = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
880881
ENABLE_STRICT_OBJC_MSGSEND = YES;
881882
ENABLE_TESTABILITY = YES;
882883
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
@@ -897,8 +898,8 @@
897898
GCC_WARN_UNUSED_FUNCTION = YES;
898899
GCC_WARN_UNUSED_VARIABLE = YES;
899900
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
900-
LD = "";
901-
LDPLUSPLUS = "";
901+
LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
902+
LDPLUSPLUS = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
902903
LD_RUNPATH_SEARCH_PATHS = (
903904
/usr/lib/swift,
904905
"$(inherited)",
@@ -931,7 +932,8 @@
931932
isa = XCBuildConfiguration;
932933
buildSettings = {
933934
ALWAYS_SEARCH_USER_PATHS = NO;
934-
CC = "";
935+
CC = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
936+
CCACHE_BINARY = /opt/homebrew/bin/ccache;
935937
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
936938
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
937939
CLANG_CXX_LIBRARY = "libc++";
@@ -959,7 +961,7 @@
959961
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
960962
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
961963
COPY_PHASE_STRIP = YES;
962-
CXX = "";
964+
CXX = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
963965
ENABLE_NS_ASSERTIONS = NO;
964966
ENABLE_STRICT_OBJC_MSGSEND = YES;
965967
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
@@ -976,8 +978,8 @@
976978
GCC_WARN_UNUSED_FUNCTION = YES;
977979
GCC_WARN_UNUSED_VARIABLE = YES;
978980
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
979-
LD = "";
980-
LDPLUSPLUS = "";
981+
LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
982+
LDPLUSPLUS = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang++.sh";
981983
LD_RUNPATH_SEARCH_PATHS = (
982984
/usr/lib/swift,
983985
"$(inherited)",

sample/scripts/build_ios

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
set -ex
44
set -eo pipefail
55

6+
# Add ccache to PATH if available for faster compilation outside of CI environments
7+
# Can be disabled with CCACHE=false for debugging or matching CI behavior locally
8+
if [ "$CI" = "true" ] || [ "$CCACHE" = "false" ]; then
9+
# CI detected or ccache explicitly disabled - skipping ccache for clean builds
10+
if command -v ccache >/dev/null 2>&1; then
11+
ccache -C
12+
fi
13+
else
14+
if [ -d "/opt/homebrew/opt/ccache/libexec" ]; then
15+
export PATH="/opt/homebrew/opt/ccache/libexec:$PATH"
16+
fi
17+
fi
18+
619
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
720
source "$SCRIPT_DIR/simulator"
821
dest="$(get_sim_destination)"

0 commit comments

Comments
 (0)