Role of spectator ion revealed for the processing of halide perovskites