Skip to content

Adopt swift-foundation #5001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
parkera opened this issue Jul 5, 2024 · 11 comments · Fixed by #4977 or #5008
Closed

Adopt swift-foundation #5001

parkera opened this issue Jul 5, 2024 · 11 comments · Fixed by #4977 or #5008
Assignees

Comments

@parkera
Copy link
Contributor

parkera commented Jul 5, 2024

"Re-core" swift-corelibs-foundation on top of swift-foundation, and remove now-duplicated types from swift-corelibs-foundation.

This brings swift-corelibs-foundation up to date with the shared sources used in Darwin's Foundation.framework.

@parkera parkera linked a pull request Jul 5, 2024 that will close this issue
@parkera
Copy link
Contributor Author

parkera commented Jul 5, 2024

The package branch is tracking this work.

@ethanc8
Copy link

ethanc8 commented Jul 26, 2024

@parkera Which version of CoreFoundation is currently in main due to this change? Is this version of CoreFoundation more minimal than the one used before the "re-core"ing? Is this expected to become an issue for downstream users if CoreFoundation?

@ethanc8
Copy link

ethanc8 commented Jul 26, 2024

Additionally, how different is this foundation from Darwin's Foundation.framework?

@parkera
Copy link
Contributor Author

parkera commented Jul 26, 2024

This is essentially the same CF as was in swift-corelibs-foundation as before, with a bunch of minor edits. We just use a lot less of it because many functionalities around things like TimeZone, Calendar, Locale have been completely reimplemented in Swift, in swift-foundation. The C implementations here are left for compatibility with things we haven't replaced in C usage yet, primarily things like CFDateFormatter and the like.

On Darwin we use Objective-C as a shim to call up from CoreFoundation to the new Swift implementations and this C code is completely deleted. We didn't have that option here, so it's more of a fork than before in that sense.

One last thing - we don't intend for CoreFoundation to be an API for Swift apps on non-Darwin platforms. It's always been an implementation detail of swift-corelibs-foundation. We really want people to write code in Swift, not C, wherever possible.

@parkera
Copy link
Contributor Author

parkera commented Jul 26, 2024

The README has some info on the project structure, what is shared with Darwin (the answer to that is the vast majority of swift-foundation), and what this project is now focused on.

@ethanc8
Copy link

ethanc8 commented Jul 26, 2024

This is essentially the same CF as was in swift-corelibs-foundation as before, with a bunch of minor edits

So this is based on Monterey CoreFoundation, then? And if I want a Ventura CoreFoundation, I should use the closed Ventura Merge PRs? Also, will Sonoma CoreFoundation and future CoreFoundations be published, or will Ventura CoreFoundation be the last CoreFoundation to be published?

On Darwin we use Objective-C as a shim to call up from CoreFoundation to the new Swift implementations and this C code is completely deleted. We didn't have that option here, so it's more of a fork than before in that sense.

So for ObjC applications on Darwin, both CoreFoundation and Foundation include wrappers to call swift-foundation for any APIs implemented by swift-foundation, and continue to use the old C/ObjC implementations for the rest?

One last thing - we don't intend for CoreFoundation to be an API for Swift apps on non-Darwin platforms. It's always been an implementation detail of swift-corelibs-foundation. We really want people to write code in Swift, not C, wherever possible.

Unfortunately, using the Swift API is not feasible for ObjC applications on non-Darwin platforms. I currently maintain a fork of Catalina CoreFoundation which toll-free bridges to GNUstep Base (a cross-platform Foundation implementation written in ObjC), and was planning to update it to Ventura CoreFoundation when I discovered that swift-corelibs-foundation was undergoing some pretty major changes. I understand that CoreFoundation is considered an implementation detail of swift-corelibs-foundation, but I was prepared to fix any issues out-of-tree so that I could support existing ObjC applications.

@ethanc8
Copy link

ethanc8 commented Nov 6, 2024

@parkera Are the closed PRs for Ventura CoreFoundation the latest CoreFoundation I can use if I need it for a C or ObjC project? Additionally, will future CoreFoundations such as Sonoma and Sequoia be released?

@parkera
Copy link
Contributor Author

parkera commented Nov 7, 2024

I think your best bet is to use the C code available here, or in an older tag here as we transition away from it. In truth the C code on Darwin is primarily being "updated" to delete it and replace it with more Swift.

@ethanc8
Copy link

ethanc8 commented Nov 7, 2024

So I should probably stick to the Monterey code from before the adoption of swift-foundation? Since swift-foundation was not adopted yet in Ventura, why would I not want to use the Ventura CoreFoundation?

@parkera
Copy link
Contributor Author

parkera commented Nov 7, 2024

If you want to work from one of the closed PRs, you can do that too - but it's not as likely to compile and work as the merged versions.

@ethanc8
Copy link

ethanc8 commented Nov 7, 2024

Ok, thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment