Skip to content

Commit 8da33a3

Browse files
authored
Merge pull request #7802 from realm/tg/xcode-16
RCORE-2166 Fix building with Xcode 16
2 parents d318021 + 9f3e7d3 commit 8da33a3

File tree

9 files changed

+25
-24
lines changed

9 files changed

+25
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
1010
* Valgrind could report a branch on an uninitialized read when opening something that is not an encrypted Realm file as an encrypted Realm file ([PR #7789](https://github.com/realm/realm-core/pull/7789), since v14.10.0).
1111
* Opening an FLX realm asynchronously may not wait to download all data ([#7720](https://github.com/realm/realm-core/issues/7720), since FLX sync was introduced).
12+
* Fix compilation with Xcode 16 ([PR #7802](https://github.com/realm/realm-core/pull/7802))
1213

1314
### Breaking changes
1415
* None.
@@ -19,7 +20,7 @@
1920
-----------
2021

2122
### Internals
22-
* None.
23+
* Switch to building the Swift package and Cocoa binaries as C++20 ([PR #7802](https://github.com/realm/realm-core/pull/7802)).
2324

2425
----------------------------------------------
2526

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ endif()
3434
set(PROJECT_VERSION ${DEP_VERSION})
3535

3636
# Project-wide build flags
37-
set(CMAKE_CXX_STANDARD 17)
37+
if (NOT DEFINED CMAKE_CXX_STANDARD)
38+
set(CMAKE_CXX_STANDARD 17)
39+
endif()
3840
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3941
set(CMAKE_CXX_EXTENSIONS OFF)
4042

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,5 +565,5 @@ let package = Package(
565565
.headerSearchPath("../"),
566566
] + cxxSettings) as [CXXSetting]),
567567
],
568-
cxxLanguageStandard: .cxx17
568+
cxxLanguageStandard: .cxx20
569569
)

evergreen/config.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,6 @@ buildvariants:
16741674
expansions:
16751675
cmake_bindir: "/opt/homebrew/bin"
16761676
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
1677-
extra_flags: "-DCMAKE_XCODE_ATTRIBUTE_SDKROOT=iphoneos"
16781677
cmake_build_tool_options: "-sdk iphonesimulator -arch arm64"
16791678
cmake_generator: Xcode
16801679
max_jobs: $(sysctl -n hw.logicalcpu)
@@ -1707,12 +1706,11 @@ buildvariants:
17071706
expansions:
17081707
cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz"
17091708
cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin"
1710-
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
17111709
cmake_generator: Xcode
17121710
max_jobs: $(sysctl -n hw.logicalcpu)
17131711
cmake_build_type: Release
17141712
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
1715-
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=x86_64
1713+
extra_flags: -DREALM_ENABLE_ASSERTIONS=ON
17161714
tasks:
17171715
- name: benchmarks
17181716
- name: compile_test
@@ -1724,12 +1722,11 @@ buildvariants:
17241722
expansions:
17251723
cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz"
17261724
cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin"
1727-
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
17281725
cmake_generator: Xcode
17291726
max_jobs: $(sysctl -n hw.logicalcpu)
17301727
cmake_build_type: Release
17311728
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
1732-
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64
1729+
extra_flags: -DREALM_ENABLE_ASSERTIONS=ON
17331730
tasks:
17341731
- name: benchmarks
17351732

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
add_subdirectory(realm)
22
add_subdirectory(external/IntelRDFPMathLib20U2)
3-
add_subdirectory(external/bson EXCLUDE_FROM_ALL)
3+
if (NOT REALM_BUILD_LIB_ONLY)
4+
add_subdirectory(external/bson EXCLUDE_FROM_ALL)
5+
endif()
46

57
if (REALM_ENABLE_GEOSPATIAL)
68
add_subdirectory(external/s2)

src/realm/util/time.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ inline std::string format_utc_time(std::time_t time, const char* format)
6969

7070
} // namespace realm::util
7171

72-
#if __cplusplus < 202002L
72+
#if __cplusplus < 202002L || (defined(__apple_build_version__) && __apple_build_version__ < 15000309)
7373
// This is a C++17 version of https://en.cppreference.com/w/cpp/chrono/duration/operator_ltlt to make
7474
// logging and comparing durations easier - especially in tests.
7575
//

test/benchmark-larger/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int main()
163163
<< std::endl;
164164
start = end;
165165
for (size_t i = 0; i < probe_size; ++i) {
166-
sum += objects[i].get<Int>(col2);
166+
sum = sum + objects[i].get<Int>(col2);
167167
}
168168
end = std::chrono::steady_clock::now();
169169
diff = end - start;

test/test_util_file.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,15 @@ TEST(Utils_File_dir)
117117

118118
TEST(Utils_File_dir_unicode)
119119
{
120+
#if __cplusplus < 202002L
120121
using std::filesystem::u8path;
122+
#else
123+
auto u8path = [](const std::string& str) {
124+
return std::filesystem::path(reinterpret_cast<const char8_t*>(str.c_str()));
125+
};
126+
#endif
121127

122-
constexpr char all_the_unicode[] = u8"фоо-бар Λορεμ ლორემ 植物 החלל جمعت søren";
128+
const char* all_the_unicode = (const char*)u8"фоо-бар Λορεμ ლორემ 植物 החלל جمعت søren";
123129
std::string dir_name = File::resolve(all_the_unicode, test_util::get_test_path_prefix());
124130

125131
// Create directory

tools/cmake/xcode.toolchain.cmake

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator;-appletvos;-appl
1515
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES")
1616
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2,3,4,7")
1717

18-
# With Xcode 14+ the base SDK *mostly* doesn't matter any more, as it
19-
# officially supports multi-platform builds from a single target.
20-
# However, as of Xcode 15 beta 8 xcodebuild (but not Xcode itself) requires the
21-
# visionOS SDK to build for visionOS. 15.0 final doesn't include the visionOS
22-
# SDK, so the SDKROOT is explicitly set by the invoker when building with the
23-
# beta Xcode rather than here.
24-
# Xcode 13 requires using the correct SDK. We no longer support Xcode 13, but
25-
# still use it on evergreen to build the macOS tests (and nothing else).
18+
# As of Xcode 14 the iphoneos SDK supports building for all platforms to
19+
# support multi-platform builds. However, we still have some Xcode 13 builds (for
20+
# benchmarks) that need to set the SDKROOT to macosx.
2621
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_SDKROOT)
27-
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1500 "iphoneos")
28-
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1400 "iphoneos")
29-
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1300 "macosx")
30-
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "$(SDKROOT_$(XCODE_VERSION_MAJOR))")
22+
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "iphoneos")
3123
endif()
3224

3325
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "12.0")
@@ -39,3 +31,4 @@ set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET "12.0")
3931

4032
set(REALM_ENABLE_ASSERTIONS ON CACHE BOOL "Enable release assertions")
4133
set(REALM_XCODE_TOOLCHAIN TRUE)
34+
set(CMAKE_CXX_STANDARD 20)

0 commit comments

Comments
 (0)