tuist / XcodeProj

📝 Read, update and write your Xcode projects
https://xcodeproj.tuist.io
MIT License
2.03k stars 309 forks source link

Fix warning compiling for macOS 13 #710

Closed jpsim closed 2 years ago

jpsim commented 2 years ago

Short description 📝

There's a deprecation warning when building with Xcode 14 targeting macOS 13:

Sources/XcodeProj/Extensions/String+md5.swift:63:16: warning: 'init(bytesNoCopy:length:encoding:freeWhenDone:)' was deprecated in macOS 13: String does not support no-copy initialization
        return String(bytesNoCopy: ptr, length: hexLen, encoding: .utf8, freeWhenDone: true)!
               ^

This is because String.init(bytesNoCopy:...) was deprecated in macOS 13: https://developer.apple.com/documentation/swift/string/init(bytesnocopy:length:encoding:freewhendone:)

Further discussion here: https://forums.swift.org/t/does-string-bytesnocopy-copy-bytes/51643/11

Solution 📦

Use String.init(cString:) instead.

Implementation 👩‍💻👨‍💻

jpsim commented 2 years ago

I made a few updates after realizing that the initial code wasn't safe. Should be good to go now.

jpsim commented 2 years ago

CI didn't run on the latest commits of this PR.

Tests failed on main, but they pass for me locally when running swift test with Xcode 14b4.

kwridan commented 2 years ago

Sorry folks had to revert this 😞 as it was causing some reference generation instability (tests caught this when run repeatedly)

jpsim commented 2 years ago

I understand. I don't see how what I wrote is unsafe, but it clearly is.