Swift Compiler: `warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX'`

When building a Swift codebase targeting CMAKE_SYSTEM_NAME: "iOS" the platform doesn’t appear to be propagated onto the swiftc call?

For what I gather the -target should be passed to swiftc. I checked the source and it appears as though this was incomplete or am I going mad?

As a workaround I have used this after the first call to project()

# Swift on iOS needs explicit specify target platform but not sure this is correct but appears to work
if (IOS)
    set(CMAKE_Swift_FLAGS_INIT 
        "-target ${CMAKE_OSX_ARCHITECTURES}-apple-ios${CMAKE_OSX_DEPLOYMENT_TARGET}"
    )
endif()