Error using Wifi.h lib

Hi, i'm using an ESP32 DEV KIT DOIT board and the goal of the project is sense 3 sensors and upload that info to Ubidots.
I'm using the example code that provides Ubidots for ESP32. First, we copy that code in Arduino IDE (without sensors, just doing an analog read) and that worked.
But, later we put that code into Visual Studio Code (using Platformio extension for arduino programming) and added the correspondig lines for sensors. But when compiled the code, it show the next error:

error: invalid abstract return type 'WiFiClient'

We used in both IDEs the same libraries. Code attached.
Somebody knows why doesn't compile in Platformio and in Arduino does?

/*--------------------------------------------------------------------------------
* Trabajo práctico ESP32 - WiFi - Sensores - Ubidots
* Ingeniería Electrónica - Quinto año 2019
* 
*
*
*/

//--------------------------------------------------------------------------------
//Inludes
//--------------------------------------------------------------------------------
#include <Arduino.h>
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <hcsr04.h>

//#include <WiFiManager.h>

//--------------------------------------------------------------------------------
//Defines
//--------------------------------------------------------------------------------
#define TRIG_PIN 32                                    //Trigger pin para HCSR04
#define ECHO_PIN 35                                    //Echo pin para HCSR04
#define LED 2                                          //Onboard BLUE led 
#define DHTPIN 21                                      //Communication pin for dht11 sensor
#define DHTTYPE DHT11                                  //Define el tipo de sensor DHT -> DHT11
#define PHPIN 15                                       //Pin para phmetro

#define WIFISSID "Fibertel WiFi570 2.4GHz"                    // Put your WifiSSID here
#define PASSWORD "0143647912"                                  // Put your wifi password here
#define TOKEN "BBFF-TIP4mJJazPaJVIgIudb2API2O7nask"           // Put your Ubidots' TOKEN
#define MQTT_CLIENT_NAME "Cipolatti15"                      // MQTT client Name, please enter your own 8-12 alphanumeric character ASCII string; 
                                                          //it should be a random and unique ascii string and different from all other devices

#define VARIABLE_LABEL1 "DHT11"                              // Assing the variable label
#define VARIABLE_LABEL2 "HCSR04"                              // Assing the variable label
#define VARIABLE_LABEL3 "PH"
#define DEVICE_LABEL "esp32"                                 // Assig the device label
//--------------------------------------------------------------------------------
//Inicialización de clases
//--------------------------------------------------------------------------------
HCSR04 hcsr04(TRIG_PIN, ECHO_PIN, 20, 4000);                   //HCSR04, min range: 20, max range: 1000
DHT_Unified dht(DHTPIN, DHTTYPE);                              //Define el tipo de sensor DHT y el pin que va a utilizar
sensors_event_t event;

//--------------------------------------------------------------------------------
//Variables globales
//--------------------------------------------------------------------------------
float phprom;
char mqttBroker[]  = "industrial.api.ubidots.com";
char payload[100];
char topic[150];
// Space to store values to send
char str_temperatura[10];

//--------------------------------------------------------------------------------
//Funciones privadas
//--------------------------------------------------------------------------------
void SendUbidots(float variable, String variable_label);

WiFiClient ubidots;
PubSubClient client( ubidots);



void callback(char* topic, byte* payload, unsigned int length) {
  char p[length + 1];
  memcpy(p, payload, length);
  p[length] = NULL;
  String message(p);
  Serial.write(payload, length);
  Serial.println(topic);
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.println("Attempting MQTT connection...");
    
    // Attemp to connect
    if (client.connect(MQTT_CLIENT_NAME, TOKEN, "")) {
      Serial.println("Connected");
    } else {
      Serial.print("Failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 2 seconds");
      // Wait 2 seconds before retrying
      delay(2000);
    }
  }
}

//--------------------------------------------------------------------------------
//Main
//--------------------------------------------------------------------------------

void setup() {
  Serial.begin(115200);
  WiFi.begin(WIFISSID, PASSWORD);
  Serial.println();
  Serial.print("Wait for WiFi...");
  
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  
  Serial.println("");
  Serial.println("WiFi Connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  client.setServer(mqttBroker, 1883);
  client.setCallback(callback);  
  
  dht.begin();                                          //Arranca el sensor  DHT11 
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }

  dht.temperature().getEvent(&event);
  float tempamb = event.temperature;

  dht.humidity().getEvent(&event);
  float hum = event.relative_humidity;

  for(int g=0; g<1000; g++){
    float ph = analogRead(PHPIN);
    float voltaje = (3.3/4095)*ph;
    float phposta = 7 + ((1.5-voltaje)/0.1839);
    phprom = phprom + phposta;
  }
  phprom = phprom/1000;

  float dist = hcsr04.distanceInMillimeters();
}

void SendUbidots(float variable, String variable_label){
  sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
  sprintf(payload, "%s", ""); // Cleans the payload
  sprintf(payload, "{\"%s\":", variable_label); // Adds the variable label
  dtostrf( variable, 4, 2, str_temperatura);
  sprintf(payload, "%s {\"value\": %s}}", payload, str_temperatura); // Adds the value
  Serial.println("Publishing data to Ubidots Cloud");
  client.publish(topic, payload);
  client.loop();
  delay(1000);
}

It shows this error: error: invalid abstract return type 'WiFiClient'
I know that one option is do the project in the Arduino IDEm but my objetive is do it in Platformio. Thanks

main.cpp (5.54 KB)

As far as I know platformIO doesn't promise Arduino IDE compatibility. So you cannot expect to use libraries made for the Arduino IDE without changing them before.
We don't support the platformIO IDE on this forum, so you better ask on a platformIO forum.