Compile Time Incredibly Slow

后端 未结 8 1135
执笔经年
执笔经年 2020-12-22 23:57

My project consists of ~350 Swift files and ~40 cocoa pod dependencies.

As soon as the entire project was migrated to Swift 3, build times have been <

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 00:07

    I'm using Xcode 8.1 My issue was with Dictionary which uses Nil-Coalescing Operator

    this is my code when it takes 10 minutes to build:

        let params: [String:String] = [
            "email": email ?? self.email,
            "clave": password,
            "tipo_documento": documentType?.rawValue ?? self.typeDocument.rawValue,
            "documento": number ?? self.documentNumber,
            "nombre": name ?? self.name,
            "apellidos": lastName ?? self.lastName,
            "fecha_nacimiento": birth?.parse() ?? self.birthDate.parse(),
            "genero": genre?.rawValue ?? self.genre.rawValue,
            "telefono_movil": cel ?? self.cel,
            "direccion": address ?? self.address
        ]
    

    I don't know why but it advertise me that the Dictionary take a long time to compile.

    Then I change it to:

        var params: [String:String] = [:]
            params["email"] = email ?? self.email
            params["clave"] = password
            params["tipo_documento"] = documentType?.rawValue ?? self.typeDocument.rawValue
            params["documento"] = number ?? self.documentNumber
            params["nombre"] = name ?? self.name
            params["apellidos"] = lastName ?? self.lastName
            params["fecha_nacimiento"] = birth?.parse() ?? self.birthDate.parse()
            params["genero"] = genre?.rawValue ?? self.genre.rawValue
            params["telefono_movil"] = cel ?? self.cel
            params["direccion"] = address ?? self.address
    

    Hope it could help some of you.

提交回复
热议问题