marmelroy / PhoneNumberKit

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
MIT License
5.1k stars 810 forks source link

Build Error with Xcode 16 Beta 5 - ParseManager: Mutable capture of 'inout' parameter 'buffer' is not allowed in concurrently-executing code #790

Closed schlagelk closed 1 month ago

schlagelk commented 1 month ago

New Issue Checklist

Steps to reproduce

Download the latest Xcode 16 beta 5, build the project. You'll see this error

Screenshot 2024-08-06 at 3 42 46 PM
Expected result

Project compiles

Actual result

Project doesn't compile

Environment

Xcode on main branch

shanecowherd commented 1 month ago

This let me compile, not sure if it fixes it, but I just needed to get the app compiling for today:

I'm on an older branch, around 3.5.7 era

func parseMultiple(_ numberStrings: [String], withRegion region: String, ignoreType: Bool, shouldReturnFailedEmptyNumbers: Bool = false) -> [PhoneNumber] {
    var hasError = false
    var results = [PhoneNumber](repeating: PhoneNumber.notPhoneNumber(), count: numberStrings.count) // Temporary array

    DispatchQueue.concurrentPerform(iterations: numberStrings.count) { index in
        let numberString = numberStrings[index]
        do {
            let phoneNumber = try self.parse(numberString, withRegion: region, ignoreType: ignoreType)
            results[index] = phoneNumber // Update the results array
        } catch {
            results[index] = PhoneNumber.notPhoneNumber() // Update the results array
            hasError = true
        }
    }

    if hasError && !shouldReturnFailedEmptyNumbers {
        results = results.filter { $0.type != .notParsed }
    }

    return results
}
srigginsatebay commented 1 month ago

We have run into the same issue. We localize packages, so I'll apply the patch for now. Thanks!

SynthesOne commented 1 month ago

I have also encountered this bug, would appreciate it being fixed in the new version