Support for creating .xcframework
* `make macOS` builds a universal framework * `make xcframework` builds an .xcframework containing frameworks for macOS (universal), iOS, and iOS Simulator * Addresses a compiler warning
This commit is contained in:
@@ -338,7 +338,9 @@ endif ()
|
||||
if (MACOS_FRAMEWORK)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOMIT_JSON_SUPPORT=1")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DOMIT_JSON_SUPPORT=1")
|
||||
include_directories ("/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/")
|
||||
set (CMAKE_XCODE_ATTRIBUTE_ARCHS "$(ARCHS_STANDARD)")
|
||||
set (CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO)
|
||||
include_directories ("/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/include/")
|
||||
endif ()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -486,7 +488,7 @@ if (IN_XCODE)
|
||||
FRAMEWORK_VERSION A
|
||||
DEFINES_MODULE TRUE
|
||||
MACOSX_FRAMEWORK_IDENTIFIER com.cmake.${XCODE_FRAMEWORK_NAME}
|
||||
MODULE_MAP "${PROJ_DIR}/ports/module.modulemap"
|
||||
MODULEMAP_FILE "${PROJ_DIR}/ports/module.modulemap"
|
||||
PUBLIC_HEADER "${frameworkHeaderGlob}"
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
||||
)
|
||||
|
||||
7
Makefile
7
Makefile
@@ -69,6 +69,13 @@ macos_release:
|
||||
$(DIST_BUILD_SCRIPT) macos "release"
|
||||
macos: macos_debug macos_release
|
||||
|
||||
# xcframework
|
||||
xcframework_debug:
|
||||
$(DIST_BUILD_SCRIPT) xcframework "debug"
|
||||
xcframework_release:
|
||||
$(DIST_BUILD_SCRIPT) xcframework "release"
|
||||
xcframework: xcframework_release
|
||||
|
||||
# iOS
|
||||
ios_debug:
|
||||
$(DIST_BUILD_SCRIPT) ios "debug"
|
||||
|
||||
38
dist.sh
38
dist.sh
@@ -181,18 +181,44 @@ macos()
|
||||
cd $XCODE_MACOS_PROJ_DIR
|
||||
# Framework
|
||||
xcodebuild -target zt -configuration "$UPPERCASE_CONFIG" -sdk "macosx"
|
||||
# NOTE: We build the static and dynamic editions in host()
|
||||
# Static library (libzt.a)
|
||||
#xcodebuild -target zt-static -configuration "$UPPERCASE_CONFIG" -sdk "macosx"
|
||||
# Dynamic library (libzt.dylib)
|
||||
#xcodebuild -target zt-shared -configuration "$UPPERCASE_CONFIG" -sdk "macosx"
|
||||
cd -
|
||||
OUTPUT_DIR=$(pwd)/lib/$1/macos-$(uname -m)
|
||||
OUTPUT_DIR=$(pwd)/lib/$1/macos-universal
|
||||
mkdir -p $OUTPUT_DIR
|
||||
rm -rf $OUTPUT_DIR/zt.framework # Remove prior to move to prevent error
|
||||
mv $XCODE_MACOS_PROJ_DIR/$UPPERCASE_CONFIG/* $OUTPUT_DIR
|
||||
}
|
||||
|
||||
# Build xcframework
|
||||
xcframework()
|
||||
{
|
||||
if [[ ! $OSNAME = *"darwin"* ]]; then
|
||||
exit 0
|
||||
fi
|
||||
generate_projects # if needed
|
||||
echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")"
|
||||
UPPERCASE_CONFIG="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"
|
||||
|
||||
OUTPUT_DIR=$(pwd)/lib/$1
|
||||
|
||||
cd $XCODE_MACOS_PROJ_DIR
|
||||
xcodebuild -target zt -configuration "$UPPERCASE_CONFIG" -sdk "macosx"
|
||||
|
||||
cd $XCODE_IOS_PROJ_DIR
|
||||
xcodebuild -arch arm64 -target zt -configuration "$UPPERCASE_CONFIG" -sdk "iphoneos"
|
||||
|
||||
cd $XCODE_IOS_SIMULATOR_PROJ_DIR
|
||||
xcodebuild -target zt -configuration "$UPPERCASE_CONFIG" -sdk "iphonesimulator"
|
||||
|
||||
mkdir -p $OUTPUT_DIR
|
||||
|
||||
rm -rf $OUTPUT_DIR/zt.xcframework # Remove prior to move to prevent error
|
||||
xcodebuild -create-xcframework \
|
||||
-framework $XCODE_MACOS_PROJ_DIR/$UPPERCASE_CONFIG/zt.framework \
|
||||
-framework $XCODE_IOS_PROJ_DIR/$UPPERCASE_CONFIG-iphoneos/zt.framework \
|
||||
-framework $XCODE_IOS_SIMULATOR_PROJ_DIR/$UPPERCASE_CONFIG-iphonesimulator/zt.framework \
|
||||
-output $OUTPUT_DIR/zt.xcframework
|
||||
}
|
||||
|
||||
# Build Java JAR for current host (uses JNI)
|
||||
host_jar()
|
||||
{
|
||||
|
||||
@@ -253,6 +253,7 @@ int zts_restart()
|
||||
_userCallbackMethodRef = _tmpUserCallbackMethodRef;
|
||||
return zts_start(userProvidedPath.c_str(), NULL, userProvidedPort);
|
||||
#else
|
||||
return ZTS_ERR_OK;
|
||||
//return zts_start(userProvidedPath.c_str(), _tmpUserEventCallbackFunc, userProvidedPort);
|
||||
#endif
|
||||
}
|
||||
@@ -415,4 +416,4 @@ void zts_delay_ms(long milliseconds)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user