Skip to content

Commit

Permalink
iOS: Use generic simulator device for building apps via xcodebuild
Browse files Browse the repository at this point in the history
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
Change-Id: I50e31c1b350cf83ce348275b467051263dea88a9
Reviewed-by: Volker Hilsheimer <[email protected]>
Reviewed-by: Timur Pocheptsov <[email protected]>
(cherry picked from commit cd2690d)
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
torarnv authored and Tarja Sundqvist committed Oct 20, 2022
1 parent 7ff2473 commit ab28ff2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 4 additions & 8 deletions mkspecs/features/uikit/xcodebuild.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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/\..*//')

Expand Down
8 changes: 7 additions & 1 deletion mkspecs/features/uikit/xcodebuild.prf
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit ab28ff2

Please sign in to comment.