High Sierra: Can’t merge BOOTCAMP partition with APFS container

apfsdisk-utilityhard drivehigh sierrapartition

I feel like this is a known problem on High Sierra, but I can't delete my BOOTCAMP partition to gain "Free Space" and I also can't expand my APFS container that contains my MACINTOSH HD. It's like they've turned into seperate hard disks, and I can't move over the space from the old file system to the new one.
This is what I find when I type diskutil list into terminal:

diskutil

I tried manually deleting the BOOTCAMP partition using terminal, and then expanding the container: I tried using the diskutil apfs resizeContainer. But I got an error saying that the target disk has no space (i.e. it doesn't detect the free space).
Any solutions?

Best Answer

First convert the former Boot Camp partition to free space:

sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3

Then expand your APFS container to the max (0 is a magic size here):

diskutil apfs resizeContainer disk0s2 0