Skip to content

Commit

Permalink
Add Swift iOS testing to CI (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
externl authored Dec 19, 2024
1 parent 013d81a commit 52fef8e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
# macOS and Linux
- name: Build C++ and Python
run: |
make -C cpp srcs
make ${{ inputs.build_flags }} -C cpp srcs
make -C python
shell: bash
if: (runner.os == 'macOS' || runner.os == 'Linux') && inputs.build_cpp_and_python == 'true'
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ jobs:
test_flags: "--platform=x64 --config=Debug"
msbuild_project: "msbuild/ice.proj"

# Swift iOS
- os: macos-15
config: "swift-ios"
working_directory: "swift"
build_flags: "PLATFORMS='macosx iphonesimulator'"
test_flags: "--platform=iphonesimulator --controller-app --rfilter=Ice/operations" # Remove rfilter once #3286 is fixed
build_cpp_and_python: true

# Static builds
- os: ubuntu-24.04
config: "static"
Expand All @@ -60,13 +68,13 @@ jobs:
working_directory: "cpp"

# # Xcode SDK builds
# # TODO - Should we also test the debug config here as well?
# - macos-15
# config: "xcodesdk"
# working_directory: "cpp"
# build_flags: "CONFIGS=xcodesdk PLATFORMS=iphonesimulator"
# test_flags: "--config=xcodesdk --platform=iphonesimulator --controller-app"
# build_cpp_and_python: true
# # TODO - Should we also test the debug config here as well?
# - macos-15
# 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
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Ice/ios/iAPTransceiver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ - (void)stream:(NSStream*)stream handleEvent:(NSStreamEvent)eventCode
}

Ice::ConnectionInfoPtr
IceObjC::iAPTransceiver::getInfo(bool incoming, string adapterName, string connectionId) const
IceObjC::iAPTransceiver::getInfo([[maybe_unused]] bool incoming, string adapterName, string connectionId) const
{
assert(!incoming);

Expand Down
6 changes: 4 additions & 2 deletions scripts/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4424,10 +4424,12 @@ def getIOSControllerIdentity(self, current):

def getIOSAppFullPath(self, current):
cmd = "xcodebuild -project {0} \
-target 'TestDriverApp' \
-scheme 'TestDriverApp' \
-configuration {1} \
-sdk {2} \
-arch arm64 \
-showBuildSettings \
-sdk {2}".format(
".format(
self.getXcodeProject(current),
current.config.buildConfig.capitalize(), # SwiftPM uses lowercase. Xcode users uppercase.
current.config.buildPlatform,
Expand Down
4 changes: 2 additions & 2 deletions swift/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If targeting Swift for iOS (or iOS simulator), the XCFrameworks must also be bui

```shell
cd cpp
make PLATFORM=all
make PLATFORMS=all
```

### Building with Make
Expand All @@ -58,7 +58,7 @@ make
The `PLATFORMS` argument can be used to include the [iOS test controller]:

```shell
make PLATFORM=all
make PLATFORMS=all
```

### Building with Xcode
Expand Down
13 changes: 10 additions & 3 deletions swift/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ include $(top_srcdir)/config/Make.rules

CONFIG ?= $(if $(filter $(OPTIMIZE),no),Debug,Release)

SWIFT_BUILD_FLAGS ?= $(if $(V),,--quiet) --configuration $(shell echo $(CONFIG) | tr '[:upper:]' '[:lower:]')
SWIFT_BUILD_FLAGS ?= -Xswiftc -warnings-as-errors $(if $(V),,--quiet) --configuration $(shell echo $(CONFIG) | tr '[:upper:]' '[:lower:]')

# $(call make-xcodebuild-rule,$1=rule,$2=platform,$3=action)
define xcode-test-app-rule
$1:: test/ios/TestDriverApp.xcodeproj
xcodebuild $(if $(V),,-quiet) \
-project test/ios/TestDriverApp.xcodeproj \
-scheme TestDriverApp \
-scheme Ice \
-arch arm64 \
-configuration $(CONFIG) \
-sdk macosx $3

xcodebuild $(if $(V),,-quiet) \
-project test/ios/TestDriverApp.xcodeproj \
-scheme TestDriverApp \
-arch arm64 \
-configuration $(CONFIG) \
-sdk $2 $3

endef
Expand All @@ -28,7 +35,7 @@ srcs::
$(Q)swift build $(SWIFT_BUILD_FLAGS)

tests::
$(Q)swift build -Xswiftc -warnings-as-errors --package-path test $(SWIFT_BUILD_FLAGS)
$(Q)swift build --package-path test $(SWIFT_BUILD_FLAGS)

install::
@echo nothing to install
Expand Down
3 changes: 3 additions & 0 deletions swift/src/IceImpl/Connection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ - (BOOL)throwException:(NSError**)error
if (sslInfo)
{
std::string encoded;
// See https://github.com/zeroc-ice/ice/issues/3283
#if TARGET_OS_IPHONE == 0
if (sslInfo->peerCertificate)
{
encoded = Ice::SSL::encodeCertificate(sslInfo->peerCertificate);
}
#endif
return [factory createSSLConnectionInfo:underlying peerCertificate:toNSString(encoded)];
}

Expand Down
2 changes: 1 addition & 1 deletion swift/src/IceImpl/DispatchAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
else
{
// In the case of a twoway request we can just take the memory as its no longer needed after this request.
// Move the request's InputStream into a new stack allocated InputStream.
// Move the request's InputStream into a new heap allocated InputStream.
// When dispatch completes, the new InputStream will be deleted.
auto dispatchInputStream = new Ice::InputStream(std::move(request.inputStream()));

Expand Down

0 comments on commit 52fef8e

Please sign in to comment.