iOS: Use generic simulator device for building apps via xcodebuild

If Xcode wasn't configured with any simulators the build would fail
since we had no device to build for. But we don't need to build for
a specific device, we can build for the generic simulator device,
just like we do for the non-simulator build. This likely didn't
work properly at the time it was first implemented, but now seems
to work fine, and is less fragile than the current solution.

Running tests still enumerates the available simulators,
as that needs a concrete device to run on.

Fixes: COIN-777
Pick-to: 6.2 6.3 5.15
Change-Id: I50e31c1b350cf83ce348275b467051263dea88a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-12-22 13:26:00 +01:00 committed by Volker Hilsheimer
parent 1ed19dc018
commit cd2690dcbf
2 changed files with 11 additions and 9 deletions

View File

@ -58,7 +58,7 @@ debug-%: CONFIGURATION = Debug
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
# Test and build (device) destinations
# Test device destinations
ifneq ($(filter check%,$(MAKECMDGOALS)),)
ifeq ($(DEVICES),)
$(info Enumerating test destinations (you may override this by setting DEVICES explicitly), please wait...)
@ -72,14 +72,10 @@ endif
%-device: DEVICES = $(HARDWARE_DEVICES)
GENERIC_DEVICE_DESTINATION := $(EXPORT_GENERIC_DEVICE_DESTINATION)
GENERIC_SIMULATOR_DESTINATION := $(shell $(MAKEFILE_DIR)devices.py $(EXPORT_DEVICE_FILTER) | tail -n 1)
ifeq ($(GENERIC_SIMULATOR_DESTINATION),)
$(error Could not find any device matching '$(EXPORT_DEVICE_FILTER)'.)
endif
GENERIC_SIMULATOR_DESTINATION := "id=$(GENERIC_SIMULATOR_DESTINATION)"
GENERIC_SIMULATOR_DESTINATION := $(EXPORT_GENERIC_SIMULATOR_DESTINATION)
%-simulator: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_SIMULATOR_DESTINATION))
%-device: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_DEVICE_DESTINATION))
%-simulator: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)","$(GENERIC_SIMULATOR_DESTINATION)")
%-device: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)","$(GENERIC_DEVICE_DESTINATION)")
XCODE_VERSION_MAJOR := $(shell xcodebuild -version | grep Xcode | sed -e 's/Xcode //' | sed -e 's/\..*//')

View File

@ -53,7 +53,13 @@ watchos {
DEVICE_FILTER = --platform watchOS --minimum-deployment-target $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
GENERIC_DEVICE_DESTINATION = "generic/platform=watchOS"
}
QMAKE_EXTRA_VARIABLES += DEVICE_SDK SIMULATOR_SDK DEVICE_FILTER GENERIC_DEVICE_DESTINATION
GENERIC_SIMULATOR_DESTINATION = "$$GENERIC_DEVICE_DESTINATION Simulator"
QMAKE_EXTRA_VARIABLES += \
DEVICE_SDK SIMULATOR_SDK \
DEVICE_FILTER \
GENERIC_DEVICE_DESTINATION \
GENERIC_SIMULATOR_DESTINATION
QMAKE_EXTRA_INCLUDES += $$shell_quote($$PWD/xcodebuild.mk)