AVAssetWriter codec type hevc

I a trying to transcode an H264 video to HEVC using AVAssetWriter and it fails on iPhone 6s. Supposedly, iPhone 6s supports HEVC for transcoding, not real time video encoding. The same code works on iPhone 7 and above. If iPhone 6s doesn't supports hevc codec, how do we programmatically determine supported codecs at runtime?

                let bitrate = trackBitrate/5 
                let trackDimensions = trackSize
                let compressionSettings: [String: Any] = [

                    AVVideoAverageBitRateKey: bitrate,
                    AVVideoMaxKeyFrameIntervalKey: 30,
                    AVVideoProfileLevelKey: kVTProfileLevel_HEVC_Main_AutoLevel
                ]
                var videoSettings: [String : Any] = [
                    AVVideoWidthKey: trackDimensions.width,
                    AVVideoHeightKey: trackDimensions.height,
                    AVVideoCompressionPropertiesKey: compressionSettings
                ]

                videoSettings[AVVideoCodecKey] =  AVVideoCodecType.hevc