Ubiquity create swapfile btrfs

I don’t know if it’s the right place to ask, but I’m trying to solve the problem of creating the swap file on Btrfs, I reported the problem a few months ago and since nobody solves it, I thought I’d make myself useful and try, specific that I’m not a developer and I know little about programming languages, but my goodwill and since it doesn’t seem too difficult to solve, I’m trying to help.
I emphasize that on my custom ISO using Cubic, I have already managed to create the swap file and it works without problems, but I know it is not the right way to do it, especially if you use ext4.
In order to create the swapfile I modified these files, adding these lines:

/usr/lib/partman/finish.d/25create_swapfile :
log-output -t partman-swapfile --pass-stdout truncate -s 0 /target/swap/swapfile
log-output -t partman-swapfile --pass-stdout fallocate -l ${size}KiB /target/swap/swapfile

/usr/lib/partman/mount.d/70btrfs:
/swap)
btrfs subvolume create /target$mp/@swap
chmod 755 /target$mp/@swap
chattr -R +C /target$mp/@swap
btrfs property set /target$mp/@swap compression none
umount /target$mp
options="${options:+$options,}default,subvol=@swap"
mount -t btrfs -o $options $fs /target$mp

/usr/lib/partman/finish.d/45fstab_swapfile:
printf “%-41s %-15s %-7s %-15s %-7s %s\n” /swap/swapfile none swap sw 0 0 >> /target/etc/fstab

/usr/lib/partman/fstab.d/btrfs:
swap_options=default,subvol=@swap
swap_path="$path"
swap_mp="$mountpoint"swap
if [ “$home_found” = “false” ]; then
echo “$home_path” “$home_mp” btrfs “$home_options” 0 0
echo “$swap_path” “$swap_mp” btrfs “$swap_options” 0 0

I put the links of the complete code on pastebin for better reading.