-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
239 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...ts/environments/react-native/ios/RealmReactNativeTests/RealmReactNativeTests.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
<key>com.apple.security.personal-information.location</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
# Start in the root directory of the project. | ||
cd "$(dirname "$0")/.." | ||
|
||
# Need npx and node | ||
NODE_DIRECTORY=$(dirname "$NODE_PATH") | ||
export PATH="$NODE_DIRECTORY:$PATH" | ||
|
||
# Take homebrew installs as well | ||
CMAKE_DIRECTORY=$(dirname "$CMAKE_PATH") | ||
export PATH="$CMAKE_DIRECTORY:$PATH" | ||
|
||
PROJECT_ROOT=$(pwd) | ||
SDK_PATH=$PROJECT_ROOT | ||
BINDGEN_PATH=$PROJECT_ROOT/bindgen | ||
BINDING_PATH=$PROJECT_ROOT/binding | ||
SCRIPT=$(basename "${BASH_SOURCE[0]}") | ||
|
||
function usage { | ||
echo "Usage: ${SCRIPT} [-c <configuration>] [<platforms>]" | ||
echo "" | ||
echo "Arguments:" | ||
echo " -c : build configuration (Debug or Release)" | ||
echo " <platforms> : platforms to build for (maccatalyst, ios, or iphonesimulator)" | ||
exit 1; | ||
} | ||
|
||
CONFIGURATION=Release | ||
SUPPORT_PLATFORMS=(maccatalyst ios iphonesimulator) | ||
|
||
function is_supported_platform(){ | ||
for platform in "${SUPPORT_PLATFORMS[@]}"; do | ||
[[ "${platform}" == $1 ]] && return 0 | ||
done | ||
return 1 | ||
} | ||
|
||
# Parse the options | ||
while getopts ":c:" opt; do | ||
case "${opt}" in | ||
c) CONFIGURATION=${OPTARG};; | ||
*) usage;; | ||
esac | ||
done | ||
|
||
echo "Configuration: ${CONFIGURATION}" | ||
|
||
shift $((OPTIND-1)) | ||
PLATFORMS=($@) | ||
|
||
if [ -z ${PLATFORMS} ]; then | ||
echo "No platform given. building all platforms..."; | ||
PLATFORMS=(ios maccatalyst iphonesimulator) | ||
else | ||
echo "Building for..."; | ||
for check_platform in "${PLATFORMS[@]}"; do | ||
if ! is_supported_platform $check_platform; then | ||
echo "${check_platform} is not a supported platform" | ||
usage | ||
exit 1 | ||
fi | ||
echo ${check_platform}; | ||
done | ||
fi | ||
|
||
DESTINATIONS=() | ||
LIBRARIES=() | ||
BUILD_LIB_CMDS=() | ||
|
||
for platform in "${PLATFORMS[@]}"; do | ||
case "$platform" in | ||
ios) | ||
DESTINATIONS+=(-destination 'generic/platform=iOS') | ||
LIBRARIES+=(-library ./out/$CONFIGURATION-iphoneos/librealm-js-ios.a -headers ./_include) | ||
BUILD_LIB_CMDS+=("xcrun libtool -static -D -o ./out/$CONFIGURATION-iphoneos/librealm-js-ios.a ./out/$CONFIGURATION-iphoneos/*.a") | ||
;; | ||
maccatalyst) | ||
DESTINATIONS+=(-destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst') | ||
LIBRARIES+=(-library ./out/$CONFIGURATION-maccatalyst/librealm-js-ios.a -headers ./_include) | ||
BUILD_LIB_CMDS+=("xcrun libtool -static -D -o ./out/$CONFIGURATION-maccatalyst/librealm-js-ios.a ./out/$CONFIGURATION-maccatalyst/*.a") | ||
;; | ||
iphonesimulator) | ||
DESTINATIONS+=(-destination 'generic/platform=iOS Simulator') | ||
LIBRARIES+=(-library ./out/$CONFIGURATION-iphonesimulator/librealm-js-ios.a -headers ./_include) | ||
BUILD_LIB_CMDS+=("xcrun libtool -static -D -o ./out/$CONFIGURATION-iphonesimulator/librealm-js-ios.a ./out/$CONFIGURATION-iphonesimulator/*.a") | ||
;; | ||
*) | ||
echo "${platform} not supported" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
pushd $SDK_PATH/react-native/ios | ||
|
||
mkdir -p build | ||
pushd build | ||
|
||
# If the developer directory is not set, use the default Xcode path | ||
SELECTED_DEVELOPER_DIR="$(xcode-select -p)" | ||
DEVELOPER_DIR="${DEVELOPER_DIR:-${SELECTED_DEVELOPER_DIR}}" | ||
|
||
# Configure CMake project | ||
env DEVELOPER_DIR="$DEVELOPER_DIR" SDKROOT="$SDKROOT" $CMAKE_PATH "$BINDGEN_PATH" -GXcode \ | ||
-DCMAKE_TOOLCHAIN_FILE="$BINDGEN_PATH/vendor/realm-core/tools/cmake/xcode.toolchain.cmake" \ | ||
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(pwd)/out/$<CONFIG>\$EFFECTIVE_PLATFORM_NAME" \ | ||
# -DCMAKE_C_COMPILER="$PROJECT_ROOT/scripts/ccache-clang.sh" \ | ||
# -DCMAKE_CXX_COMPILER="$PROJECT_ROOT/scripts/ccache-clang++.sh" | ||
# -DCMAKE_C_COMPILER="/usr/bin/clang" \ | ||
# -DCMAKE_CXX_COMPILER="/usr/bin/clang++"\ | ||
|
||
|
||
DEVELOPER_DIR="$DEVELOPER_DIR" xcodebuild build \ | ||
-scheme realm-js-ios \ | ||
"${DESTINATIONS[@]}" \ | ||
-configuration $CONFIGURATION \ | ||
# CC="$PROJECT_ROOT/scripts/ccache-clang.sh" \ | ||
# CXX="$PROJECT_ROOT/scripts/ccache-clang++.sh" \ | ||
ONLY_ACTIVE_ARCH=NO \ | ||
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ | ||
SUPPORTS_MACCATALYST=YES | ||
|
||
for cmd in "${BUILD_LIB_CMDS[@]}"; do | ||
eval "${cmd}" | ||
done | ||
|
||
rm -rf _include | ||
mkdir -p _include/realm-js-ios | ||
cp "$BINDING_PATH"/jsi/jsi_init.h _include/realm-js-ios/ | ||
|
||
rm -rf ../realm-js-ios.xcframework | ||
xcodebuild -create-xcframework \ | ||
"${LIBRARIES[@]}" \ | ||
-output ../realm-js-ios.xcframework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
if command -v ccache &> /dev/null; then | ||
# reference for xcode specific cacche settings: reactnative docs and ccache manpage | ||
# https://reactnative.dev/docs/build-speed#xcode-specific-setup | ||
# https://ccache.dev/manual/4.3.html | ||
export CCACHE_MAXSIZE=10G | ||
export CCACHE_CPP2=true | ||
export CCACHE_DIRECT=true | ||
export CCACHE_DEPEND=true | ||
export CCACHE_HARDLINK=true | ||
export CCACHE_FILECLONE=true | ||
export CCACHE_INODECACHE=true | ||
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches,modules,ivfsoverlay,pch_defines,system_headers | ||
exec ccache clang++ "$@" | ||
else | ||
exec clang++ "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
if command -v ccache &> /dev/null; then | ||
# reference for xcode specific cacche settings: reactnative docs and ccache manpage | ||
# https://reactnative.dev/docs/build-speed#xcode-specific-setup | ||
# https://ccache.dev/manual/4.3.html | ||
export CCACHE_MAXSIZE=10G | ||
export CCACHE_CPP2=true | ||
export CCACHE_DIRECT=true | ||
export CCACHE_DEPEND=true | ||
export CCACHE_HARDLINK=true | ||
export CCACHE_FILECLONE=true | ||
export CCACHE_INODECACHE=true | ||
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches,modules,ivfsoverlay,pch_defines,system_headers | ||
exec ccache clang "$@" | ||
else | ||
exec clang "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
# If the developer directory is not set, use the default Xcode path | ||
SELECTED_DEVELOPER_DIR="$(xcode-select -p)" | ||
DEVELOPER_DIR="${DEVELOPER_DIR:-${SELECTED_DEVELOPER_DIR}}" | ||
|
||
PROJECT_ROOT=$(pwd) | ||
BINDGEN_PATH=$PROJECT_ROOT/bindgen | ||
|
||
pushd $PROJECT_ROOT/react-native/ios | ||
|
||
mkdir -p build | ||
pushd build | ||
|
||
# Configure CMake project | ||
SDKROOT="$DEVELOPER_DIR/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/" cmake "$BINDGEN_PATH" -GXcode \ | ||
-DCMAKE_TOOLCHAIN_FILE="$BINDGEN_PATH/vendor/realm-core/tools/cmake/xcode.toolchain.cmake" \ | ||
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(pwd)/out/$<CONFIG>\$EFFECTIVE_PLATFORM_NAME" \ |