Xcode: Refactor internal file type extension extraction

Move it earlier so it can be used for directories too.
Xcode: Reference '.xcassets' folders as assetcatalog (#15125)
Merge topic 'xcode-assetcatalog-folder-type' into next

8eacc339 Xcode: Reference '.xcassets' folders as assetcatalog (#15125)
02aa5965 Xcode: Refactor internal file type extension extraction