Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to building with Xcode 14 #6647

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-----------

### Internals
* None.
* Prebuilt libraries for Apple platforms are now built with Xcode 14.

----------------------------------------------

Expand Down
7 changes: 3 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def doBuildMacOs(Map options = [:]) {
getArchive()

dir('build-macosx') {
withEnv(['DEVELOPER_DIR=/Applications/Xcode-13.1.app/Contents/Developer/']) {
withEnv(['DEVELOPER_DIR=/Applications/Xcode-14.app/Contents/Developer/']) {
// This is a dirty trick to work around a bug in xcode
// It will hang if launched on the same project (cmake trying the compiler out)
// in parallel.
Expand All @@ -669,7 +669,7 @@ def doBuildMacOs(Map options = [:]) {
)
}
}
withEnv(['DEVELOPER_DIR=/Applications/Xcode-13.1.app/Contents/Developer']) {
withEnv(['DEVELOPER_DIR=/Applications/Xcode-14.app/Contents/Developer']) {
runAndCollectWarnings(
parser: 'clang',
script: 'xcrun swift build',
Expand Down Expand Up @@ -712,8 +712,7 @@ def doBuildApplePlatform(String platform, String buildType, boolean test = false
rlmNode('osx') {
getArchive()

withEnv(['DEVELOPER_DIR=/Applications/Xcode-13.1.app/Contents/Developer/',
'XCODE_14_DEVELOPER_DIR=/Applications/Xcode-14.app/Contents/Developer/']) {
withEnv(['DEVELOPER_DIR=/Applications/Xcode-14.app/Contents/Developer/']) {
sh "tools/build-apple-device.sh -p '${platform}' -c '${buildType}' -v '${gitDescribeVersion}'"

if (test) {
Expand Down
11 changes: 1 addition & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.6

import PackageDescription
import Foundation
Expand Down Expand Up @@ -348,21 +348,12 @@ let bidExcludes: [String] = [
"wcstod64.c",
]

#if swift(>=5.7)
let platforms: [SupportedPlatform] = [
.macOS(.v10_13),
.iOS(.v11),
.tvOS(.v11),
.watchOS(.v4)
]
#else
let platforms: [SupportedPlatform] = [
.macOS(.v10_10),
.iOS(.v11),
.tvOS(.v9),
.watchOS(.v2)
]
#endif

let package = Package(
name: "RealmDatabase",
Expand Down
29 changes: 0 additions & 29 deletions tools/build-apple-device.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,4 @@ cmake \

xcodebuild -scheme ALL_BUILD -configuration ${buildType} -destination "${buildDestination}"

# When building watchOS and XCODE_14_DEVELOPER_DIR is set, run an additional build with Xcode 14 for the new arm64 architecture slice.
# TODO: remove when Core switches to Xcode 14 on CI
if [ -n "$XCODE_14_DEVELOPER_DIR" ] && [ "$platform" == "watchos" ]; then
function combine_library() {
local path="$1"
local target="$2"
local library="$3"
local out_path="$path/${buildType}-${platform}/${library}"

# Building just arm64 results in the library being created directly in the
# final output location rather than in the per-arch directories, but lipo
# can't operate in-place so we need to move it aside.
mv "$out_path" "${out_path}.tmp"
lipo -create -output "$out_path" \
"${out_path}.tmp" \
"build/${target}.build/${buildType}-${platform}/Objects-normal/armv7k/Binary/${library}" \
"build/${target}.build/${buildType}-${platform}/Objects-normal/arm64_32/Binary/${library}"
rm "${out_path}.tmp"
}

DEVELOPER_DIR="$XCODE_14_DEVELOPER_DIR" xcodebuild -scheme ALL_BUILD -configuration ${buildType} -sdk watchos -arch arm64
[[ "$buildType" = "Release" ]] && suffix="" || suffix="-dbg"
combine_library src/realm/object-store ObjectStore "librealm-object-store${suffix}.a"
combine_library src/realm/object-store/c_api RealmFFIStatic "librealm-ffi-static${suffix}.a"
combine_library src/realm/parser QueryParser "librealm-parser${suffix}.a"
combine_library src/realm/sync Sync "librealm-sync${suffix}.a"
combine_library src/realm Storage "librealm${suffix}.a"
fi

PLATFORM_NAME="${platform}" EFFECTIVE_PLATFORM_NAME="-${platform}" cpack -C "${buildType}"
1 change: 1 addition & 0 deletions tools/build-cocoa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if [[ -n $BUILD ]]; then
-D REALM_ENABLE_GEOSPATIAL=OFF \
-D CPACK_SYSTEM_NAME=macosx \
-D CPACK_PACKAGE_DIRECTORY=.. \
-D CMAKE_OSX_ARCHITECTURES='x86_64;arm64' \
${CMAKE_FLAGS} \
-G Xcode ..

Expand Down
41 changes: 8 additions & 33 deletions tools/cmake/xcode.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,17 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME "\$ENV{PLATFORM_NAME}")
endif()

set(CMAKE_XCODE_ATTRIBUTE_ARCHS "$(ARCHS_STANDARD)")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator macosx")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator;-appletvos;-appletvsimulator;-watchos;-watchsimulator;-maccatalyst")

set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET_1300 "9.0")
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET_1400 "11.0")
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "$(IPHONEOS_DEPLOYMENT_TARGET_$(XCODE_VERSION_MAJOR))")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_1300_CATALYST_NO "10.9")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_1400_CATALYST_NO "10.13")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_1300_CATALYST_YES "10.15")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_1400_CATALYST_YES "10.15")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "$(MACOSX_DEPLOYMENT_TARGET_$(XCODE_VERSION_MAJOR)_CATALYST_$(IS_MACCATALYST))")
set(CMAKE_XCODE_ATTRIBUTE_WATCHOS_DEPLOYMENT_TARGET_1300 "2.0")
set(CMAKE_XCODE_ATTRIBUTE_WATCHOS_DEPLOYMENT_TARGET_1400 "4.0")
set(CMAKE_XCODE_ATTRIBUTE_WATCHOS_DEPLOYMENT_TARGET "$(WATCHOS_DEPLOYMENT_TARGET_$(XCODE_VERSION_MAJOR))")
set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET_1300 "9.0")
set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET_1400 "11.0")
set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET "$(TVOS_DEPLOYMENT_TARGET_$(XCODE_VERSION_MAJOR))")

set(CMAKE_XCODE_ATTRIBUTE_ARCHS "$(ARCHS_STANDARD)")

set(CMAKE_XCODE_ATTRIBUTE_REALM_ALIGN_FLAG "")
set(CMAKE_XCODE_ATTRIBUTE_REALM_ALIGN_FLAG[arch=armv7] "-fno-aligned-new")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $(REALM_ALIGN_FLAG)")

# Bitcode
set(CMAKE_XCODE_ATTRIBUTE_REALM_ENABLE_BITCODE_1300 "YES")
set(CMAKE_XCODE_ATTRIBUTE_REALM_ENABLE_BITCODE_1400 "NO")
set(CMAKE_XCODE_ATTRIBUTE_REALM_ENABLE_BITCODE "$(REALM_ENABLE_BITCODE_$(XCODE_VERSION_MAJOR)")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE[sdk=iphone*] "$(REALM_ENABLE_BITCODE)")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE[sdk=appletv*] "$(REALM_ENABLE_BITCODE)")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE[sdk=watch*] "$(REALM_ENABLE_BITCODE)")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "\$(BITCODE_GENERATION_MODE_\$(CONFIGURATION))")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_Debug "marker")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_Release "bitcode")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_RelWithDebInfo "bitcode")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE_MinSizeRel "bitcode")
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "11.0")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_CATALYST_NO "10.13")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET_CATALYST_YES "10.15")
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "$(MACOSX_DEPLOYMENT_TARGET_CATALYST_$(IS_MACCATALYST))")
set(CMAKE_XCODE_ATTRIBUTE_WATCHOS_DEPLOYMENT_TARGET "4.0")
set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET "11.0")

set(REALM_ENABLE_ASSERTIONS ON CACHE BOOL "Enable release assertions")
set(REALM_XCODE_TOOLCHAIN TRUE)