diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7039d0c30e..6259fbbb360 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,14 +55,14 @@ jobs: test_flags: "--platform=x64 --config=Debug" msbuild_project: "msbuild/ice.proj" - # Xcode SDK builds - # TODO - Should we also test the debug config here as well? - - os: macos-14 - config: "xcodesdk" - working_directory: "cpp" - build_flags: "CONFIGS=xcodesdk PLATFORMS=iphonesimulator" - test_flags: "--config=xcodesdk --platform=iphonesimulator --controller-app" - build_cpp_and_python: true + # # Xcode SDK builds + # # TODO - Should we also test the debug config here as well? + # - os: macos-14 + # config: "xcodesdk" + # working_directory: "cpp" + # build_flags: "CONFIGS=xcodesdk PLATFORMS=iphonesimulator" + # test_flags: "--config=xcodesdk --platform=iphonesimulator --controller-app" + # build_cpp_and_python: true # MATLAB - os: ubuntu-24.04 diff --git a/Package.swift b/Package.swift index 5615c20e45d..e14b7870f5f 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,7 @@ let package = Package( defaultLocalization: "en", platforms: [ .macOS(.v14), - .iOS(.v12), + .iOS(.v17), ], products: [ .library(name: "Ice", targets: ["Ice"]), @@ -66,7 +66,11 @@ let package = Package( ), .target( name: "IceImpl", - dependencies: ["IceCpp", "IceDiscoveryCpp", "IceLocatorDiscoveryCpp"], + dependencies: [ + "IceCpp", + "IceDiscoveryCpp", + "IceLocatorDiscoveryCpp", + ], path: "swift/src/IceImpl", cxxSettings: [ // We rely on a few private headers from Ice diff --git a/config/Make.rules.Darwin b/config/Make.rules.Darwin index 5f8003ae961..31d1d3fb420 100644 --- a/config/Make.rules.Darwin +++ b/config/Make.rules.Darwin @@ -4,6 +4,8 @@ supported-platforms = macosx iphoneos iphonesimulator +xcframeworks = Ice IceDiscovery IceLocatorDiscovery + macosx_ar = libtool macosx_cppflags = -mmacosx-version-min=12.00 macosx_ldflags = $(macosx_cppflags) \ @@ -15,16 +17,22 @@ iphoneos_cc = xcrun -sdk iphoneos clang iphoneos_cxx = xcrun -sdk iphoneos clang++ iphoneos_cppflags = -miphoneos-version-min=15.0 -arch arm64 -fembed-bitcode iphoneos_ldflags = -miphoneos-version-min=15.0 -arch arm64 -iphoneos_configs = %xcodesdk -iphoneos_targetdir = $(if $(filter %/build,$5),/iphoneos) +iphoneos_configs = %static +iphoneos_targetdir = /iphoneos +# TODO: disable all install for this platform +iphoneos_installdir = /iphoneos +iphoneos_components = $(xcframeworks) iphonesimulator_ar = libtool iphonesimulator_cc = xcrun -sdk iphonesimulator clang iphonesimulator_cxx = xcrun -sdk iphonesimulator clang++ iphonesimulator_cppflags = -mios-simulator-version-min=15.0 iphonesimulator_ldflags = $(iphonesimulator_cppflags) -iphonesimulator_configs = %xcodesdk -iphonesimulator_targetdir = $(if $(filter %/build,$5),/iphonesimulator) +iphonesimulator_configs = %static +iphonesimulator_targetdir = /iphonesimulator +# TODO: disable all install for this platform +iphonesimulator_installdir = /iphonesimulator +iphonesimulator_components = $(xcframeworks) ifneq ($(shell command -v brew 2> /dev/null),) MCPP_HOME ?= $(shell brew --prefix mcpp) diff --git a/cpp/Makefile b/cpp/Makefile index 67c97843803..f5e530c5d70 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -25,6 +25,10 @@ include $(foreach p,$(load_first),src/$p/Makefile.mk) include $(filter-out $(foreach p,$(load_first),%/src/$p/Makefile.mk),$(shell find $(lang_srcdir)/src -name Makefile.mk)) $(call make-projects,$(projects),make-cpp-src-project,,$(filter all cpp,$(ICE_BIN_DIST))) +ifeq ($(os),Darwin) +$(call make-xcframeworks) +endif + # # Now, create and load test projects. # diff --git a/cpp/config/Make.xcframework.rules b/cpp/config/Make.xcframework.rules index ad66c08d423..7714d4684fb 100644 --- a/cpp/config/Make.xcframework.rules +++ b/cpp/config/Make.xcframework.rules @@ -1,21 +1,34 @@ # Copyright (c) ZeroC, Inc. All rights reserved. +# Gets the library path for a platform (macosx does not have a platform directory) +# $(call xcframework-library,Ice,macosx) => lib/Ice/libIce.a +# $(call xcframework-library,Ice,iphoneos) => lib/iphoneos/libIce.a +xcframework-library = lib/$(if $(filter macosx,$2),,$2/)lib$1.a + +# Gets a list of library paths for a component for all platforms +xcframework-libraries = $(foreach p,$($1_platforms),$(call xcframework-library,$1,$p)) + +# Gets a list of component flags used when generating an xcframework. One set of flags per platform. +xcframework-flags = $(foreach p,$($1_platforms),-library $(call xcframework-library,$1,$p) $(if $2,-headers include/$1)) + # Creates a xcframework from a static component and its headers -# $1: The name of the framework (Ice, IceDiscovery, etc.) -# $2: The platform -# $3: Output path -define create-xcframework-from-library +# Note: Th headers are coppied into the root of the Headers directory. We move the headers into Header/$1 so that we can +# include Ice as . We also copy the generated headers into the Headers/$1 directory. +# +# $(call create-xcframework,$1=framework-name) +define create-xcframework -lib/$1.xcframework: lib/lib$1.a - $(E) Creating lib/$1.xcframework +lib/$1.xcframework: $(call xcframework-libraries,$1) + $(E) Creating lib/$1.xcframework from $(call xcframework-libraries,$1) $(Q)$(RM) -r lib/$1.xcframework $(Q)if [ -d include/$1 ]; then \ - xcodebuild -create-xcframework -library lib/lib$1.a -headers include/$1 -output lib/$1.xcframework ; \ - mkdir -p lib/$1.xcframework/macos-arm64/Headers/$1 ; \ - find lib/$1.xcframework/macos-arm64/Headers/* -prune ! -name $1 -exec mv {} lib/$1.xcframework/macos-arm64/Headers/$1 \; ; \ - cp include/generated/$1/*.h lib/$1.xcframework/macos-arm64/Headers/$1 ; \ + xcodebuild -create-xcframework $(call xcframework-flags,$1,true) -output lib/$1.xcframework ; \ + find lib/$1.xcframework -name Headers -prune -exec mv {} {}_$1 \; -exec mkdir {} \; -exec mv {}_$1 {}/$1 \; ; \ + if [ -d include/generated/$1 ]; then \ + find lib/$1.xcframework -name Headers -prune -exec cp -r include/generated/$1/* {}/$1 \; ; \ + fi \ else \ - xcodebuild -create-xcframework -library lib/lib$1.a -output lib/$1.xcframework; \ + xcodebuild -create-xcframework $(call xcframework-flags,$1) -output lib/$1.xcframework; \ fi srcs all:: lib/$1.xcframework @@ -23,15 +36,13 @@ srcs all:: lib/$1.xcframework clean:: $(E) Cleaning lib/$1.xcframework $(Q)$(RM) -r lib/$1.xcframework - endef -ifeq ($(filter $(CONFIGS),static),) -Ice_always_enable_configs := static -IceDiscovery_always_enable_configs := static -IceLocatorDiscovery_always_enable_configs := static +ifeq ($(filter $(config),static),) +$(foreach f, $(xcframeworks), $(eval $f_always_enable_configs := static)) endif -$(eval $(call create-xcframework-from-library,Ice)) -$(eval $(call create-xcframework-from-library,IceDiscovery)) -$(eval $(call create-xcframework-from-library,IceLocatorDiscovery)) +define make-xcframeworks +$(foreach f, $(xcframeworks),\ + $(if $($f_platforms),$(eval $(call create-xcframework,$f)))) +endef diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index a3e7abfb3b6..743dec4cb62 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -56,6 +56,12 @@ # include "Ice/PropertiesAdmin.h" # include "Ice/RemoteLogger.h" # include "Ice/Router.h" + +// Include Apple iAP headers if building for iOS +# if defined(__APPLE__) && TARGET_OS_IPHONE != 0 +# include "ios/iAPConnectionInfo.h" +# include "ios/iAPEndpointInfo.h" +# endif #endif #endif diff --git a/cpp/include/IceIAP/ConnectionInfo.h b/cpp/include/Ice/ios/iAPConnectionInfo.h similarity index 98% rename from cpp/include/IceIAP/ConnectionInfo.h rename to cpp/include/Ice/ios/iAPConnectionInfo.h index da88eceea6b..aab87ee1ee6 100644 --- a/cpp/include/IceIAP/ConnectionInfo.h +++ b/cpp/include/Ice/ios/iAPConnectionInfo.h @@ -5,7 +5,7 @@ #ifndef ICE_IAP_CONNECTION_INFO_H #define ICE_IAP_CONNECTION_INFO_H -#include "Ice/Connection.h" +#include "../Connection.h" #if defined(__clang__) # pragma clang diagnostic push @@ -19,7 +19,7 @@ namespace IceIAP { /** * Provides access to the connection details of an IAP connection - * \headerfile IceIAP/IceIAP.h + * \headerfile Ice/Ice.h */ class ConnectionInfo : public Ice::ConnectionInfo { diff --git a/cpp/include/IceIAP/EndpointInfo.h b/cpp/include/Ice/ios/iAPEndpointInfo.h similarity index 97% rename from cpp/include/IceIAP/EndpointInfo.h rename to cpp/include/Ice/ios/iAPEndpointInfo.h index 10cbd775fcb..1de603225ff 100644 --- a/cpp/include/IceIAP/EndpointInfo.h +++ b/cpp/include/Ice/ios/iAPEndpointInfo.h @@ -5,7 +5,7 @@ #ifndef ICE_IAP_ENDPOINT_INFO_H #define ICE_IAP_ENDPOINT_INFO_H -#include "Ice/Endpoint.h" +#include "../Endpoint.h" #if defined(__clang__) # pragma clang diagnostic push @@ -19,7 +19,7 @@ namespace IceIAP { /** * Provides access to an IAP endpoint information. - * \headerfile IceIAP/IceIAP.h + * \headerfile Ice/Ice.h */ class EndpointInfo : public Ice::EndpointInfo { diff --git a/cpp/include/IceIAP/IceIAP.h b/cpp/include/IceIAP/IceIAP.h deleted file mode 100644 index 95f28537211..00000000000 --- a/cpp/include/IceIAP/IceIAP.h +++ /dev/null @@ -1,11 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef ICE_IAP_ICE_IAP_H -#define ICE_IAP_ICE_IAP_H - -#include "ConnectionInfo.h" -#include "EndpointInfo.h" - -#endif diff --git a/cpp/src/IceIAP/Connector.h b/cpp/src/Ice/ios/iAPConnector.h similarity index 89% rename from cpp/src/IceIAP/Connector.h rename to cpp/src/Ice/ios/iAPConnector.h index 0dc5158a03f..022206e06d4 100644 --- a/cpp/src/IceIAP/Connector.h +++ b/cpp/src/Ice/ios/iAPConnector.h @@ -5,10 +5,10 @@ #ifndef ICE_IAP_CONNECTOR_H #define ICE_IAP_CONNECTOR_H -#include "../Ice/Connector.h" -#include "../Ice/ProtocolInstanceF.h" -#include "../Ice/TraceLevelsF.h" -#include "../Ice/TransceiverF.h" +#include "../Connector.h" +#include "../ProtocolInstanceF.h" +#include "../TraceLevelsF.h" +#include "../TransceiverF.h" #include "Ice/Logger.h" #import diff --git a/cpp/src/IceIAP/Connector.mm b/cpp/src/Ice/ios/iAPConnector.mm similarity index 95% rename from cpp/src/IceIAP/Connector.mm rename to cpp/src/Ice/ios/iAPConnector.mm index d30a9ccb8f2..2bed280623c 100644 --- a/cpp/src/IceIAP/Connector.mm +++ b/cpp/src/Ice/ios/iAPConnector.mm @@ -6,10 +6,10 @@ #if TARGET_OS_IPHONE != 0 -# include "../Ice/ProtocolInstance.h" -# include "Connector.h" -# include "EndpointI.h" -# include "Transceiver.h" +# include "../ProtocolInstance.h" +# include "iAPConnector.h" +# include "iAPEndpointI.h" +# include "iAPTransceiver.h" using namespace std; using namespace Ice; diff --git a/cpp/src/IceIAP/EndpointI.h b/cpp/src/Ice/ios/iAPEndpointI.h similarity index 97% rename from cpp/src/IceIAP/EndpointI.h rename to cpp/src/Ice/ios/iAPEndpointI.h index 6af7d90f335..019632e63e5 100644 --- a/cpp/src/IceIAP/EndpointI.h +++ b/cpp/src/Ice/ios/iAPEndpointI.h @@ -5,9 +5,9 @@ #ifndef ICE_IAP_ENDPOINT_I_H #define ICE_IAP_ENDPOINT_I_H -#include "../Ice/EndpointFactory.h" -#include "../Ice/EndpointI.h" -#include "../Ice/ProtocolInstanceF.h" +#include "../EndpointFactory.h" +#include "../EndpointI.h" +#include "../ProtocolInstanceF.h" #include "Ice/SSL/ServerAuthenticationOptions.h" #include diff --git a/cpp/src/IceIAP/EndpointI.mm b/cpp/src/Ice/ios/iAPEndpointI.mm similarity index 97% rename from cpp/src/IceIAP/EndpointI.mm rename to cpp/src/Ice/ios/iAPEndpointI.mm index 026268259c6..0118b7c19b6 100644 --- a/cpp/src/IceIAP/EndpointI.mm +++ b/cpp/src/Ice/ios/iAPEndpointI.mm @@ -6,22 +6,22 @@ #if TARGET_OS_IPHONE != 0 -# include "../Ice/DefaultsAndOverrides.h" -# include "../Ice/EndpointFactoryManager.h" -# include "../Ice/HashUtil.h" -# include "../Ice/Network.h" -# include "../Ice/ProtocolInstance.h" -# include "../Ice/ProtocolPluginFacade.h" -# include "Connector.h" -# include "EndpointI.h" +# include "../DefaultsAndOverrides.h" +# include "../EndpointFactoryManager.h" +# include "../HashUtil.h" +# include "../Network.h" +# include "../ProtocolInstance.h" +# include "../ProtocolPluginFacade.h" # include "Ice/Initialize.h" # include "Ice/InputStream.h" # include "Ice/LocalExceptions.h" # include "Ice/OutputStream.h" # include "Ice/Properties.h" # include "Ice/RegisterPlugins.h" -# include "IceIAP/ConnectionInfo.h" -# include "IceIAP/EndpointInfo.h" +# include "Ice/ios/iAPConnectionInfo.h" +# include "Ice/ios/iAPEndpointInfo.h" +# include "iAPConnector.h" +# include "iAPEndpointI.h" # include diff --git a/cpp/src/IceIAP/Transceiver.h b/cpp/src/Ice/ios/iAPTransceiver.h similarity index 94% rename from cpp/src/IceIAP/Transceiver.h rename to cpp/src/Ice/ios/iAPTransceiver.h index 5ccd6708506..a6ed8322191 100644 --- a/cpp/src/IceIAP/Transceiver.h +++ b/cpp/src/Ice/ios/iAPTransceiver.h @@ -5,10 +5,10 @@ #ifndef ICE_IAP_TRANSCEIVER_H #define ICE_IAP_TRANSCEIVER_H -#include "../Ice/Network.h" -#include "../Ice/ProtocolInstanceF.h" -#include "../Ice/Selector.h" -#include "../Ice/Transceiver.h" +#include "../Network.h" +#include "../ProtocolInstanceF.h" +#include "../Selector.h" +#include "../Transceiver.h" #import #import diff --git a/cpp/src/IceIAP/Transceiver.mm b/cpp/src/Ice/ios/iAPTransceiver.mm similarity index 98% rename from cpp/src/IceIAP/Transceiver.mm rename to cpp/src/Ice/ios/iAPTransceiver.mm index 16e36fcc687..6e680d32193 100644 --- a/cpp/src/IceIAP/Transceiver.mm +++ b/cpp/src/Ice/ios/iAPTransceiver.mm @@ -6,12 +6,12 @@ #if TARGET_OS_IPHONE != 0 -# include "EndpointI.h" -# include "Transceiver.h" +# include "iAPEndpointI.h" +# include "iAPTransceiver.h" -# include "IceIAP/ConnectionInfo.h" +# include "Ice/ios/iAPConnectionInfo.h" -# include "../Ice/ProtocolInstance.h" +# include "../ProtocolInstance.h" # include "Ice/Buffer.h" # include "Ice/LocalExceptions.h" diff --git a/cpp/src/IceIAP/Makefile.mk b/cpp/src/IceIAP/Makefile.mk deleted file mode 100644 index 5521e39d1e0..00000000000 --- a/cpp/src/IceIAP/Makefile.mk +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright (c) ZeroC, Inc. All rights reserved. -# - -$(project)_libraries = IceIAP - -IceIAP_configs := xcodesdk -IceIAP_platforms := iphoneos iphonesimulator - -IceIAP_targetdir := $(libdir) -IceIAP_dependencies := Ice -IceIAP_cppflags := -DICEIAP_API_EXPORTS - -projects += $(project) diff --git a/swift/Makefile b/swift/Makefile index 2db8ce0a8b2..d1b72a9c66e 100644 --- a/swift/Makefile +++ b/swift/Makefile @@ -17,12 +17,14 @@ $1:: test/ios/TestDriverApp.xcodeproj -project test/ios/TestDriverApp.xcodeproj \ -scheme TestDriverApp \ -configuration $(CONFIG) \ + -arch arm64 \ -sdk $2 $3 + endef all:: tests -srcs: +srcs:: $(Q)swift build $(SWIFT_BUILD_FLAGS) tests:: @@ -32,13 +34,14 @@ install:: @echo nothing to install clean:: - $(Q)rm -rf .build + $(Q)rm -rf ../.build $(Q)rm -rf test/.build distclean:: clean -# test-app-platforms ?= iphonesimulator iphoneos +# We just build the test app for the iphonesimulator platform by default +test-app-platforms ?= $(filter iphonesimulator, $(platforms)) -# $(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,tests,$p,build))) -# $(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,clean,$p,clean))) -# $(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,distclean,$p,clean))) +$(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,tests,$p,build))) +$(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,clean,$p,clean))) +$(foreach p,$(test-app-platforms),$(eval $(call xcode-test-app-rule,distclean,$p,clean))) diff --git a/swift/src/IceImpl/include/Config.h b/swift/src/IceImpl/include/Config.h index 94d1367733c..b540d3d37dd 100644 --- a/swift/src/IceImpl/include/Config.h +++ b/swift/src/IceImpl/include/Config.h @@ -6,13 +6,7 @@ #endif #ifdef __cplusplus - # include - -# if TARGET_OS_IPHONE -# include -# endif - #endif #define ICE_SWIFT_UNAVAILABLE(msg) __attribute__((unavailable(msg))) diff --git a/swift/test/Package.swift b/swift/test/Package.swift index 763ffbfc2a8..817c1ff10a5 100644 --- a/swift/test/Package.swift +++ b/swift/test/Package.swift @@ -131,7 +131,7 @@ let package = Package( defaultLocalization: "en", platforms: [ .macOS(.v14), - .iOS(.v12), + .iOS(.v17), ], products: [ .library(name: "TestCommon", targets: ["TestCommon"]), diff --git a/swift/test/ios/TestDriverApp/ControllerI.swift b/swift/test/ios/TestDriverApp/ControllerI.swift index 3b87e4f0d93..4b0d1c5378c 100644 --- a/swift/test/ios/TestDriverApp/ControllerI.swift +++ b/swift/test/ios/TestDriverApp/ControllerI.swift @@ -46,6 +46,7 @@ class ProcessControllerI: CommonProcessController { _ipv4 = ipv4 _ipv6 = ipv6 + //TODO: remove the queues _serverDispatchQueue = DispatchQueue(label: "Server", qos: .background) _clientDispatchQueue = DispatchQueue(label: "Client", qos: .background) } @@ -197,7 +198,7 @@ class ControllerHelperI: ControllerHelper, TextWriter { let className = "\(_testName).\(_exe)" - _queue.async { + Task { do { let testHelper = TestBundle.getTestHelper(name: className) testHelper.setControllerHelper(controllerHelper: self)