How to disable Swapfile in OS X El Capitan
El Capitan has its System Integrity Protection system, which you must disable before you can touch some OS inner workings, such as swap.

You'll need to reboot your Mac in Recovery Mode (holding Command+R at boot time). Open Terminal as root, then disable System Integrity with:

csrutil disable


Now you can disable swap.

After all done, you should enable System Integrity again using:

csrutil enable