Using xprofile_insert_field

Your code does work. It’s just that you are declaring $xfield_args after you have made the call xprofile_insert_field( $xfield_args );

it should look like this

add_action('bp_init', 'field_xprofile_twitter');

function field_xprofile_twitter()
{

   global $bp;
   $xfield_args =  array (
           field_group_id  => 1,
           name            => 'Twitter',
           can_delete      => false,
           field_order     => 1,
           is_required     => false,
           type            => 'textbox'
    );

   xprofile_insert_field( $xfield_args );
}