ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.79k stars 65 forks source link

Xib file support? #77

Closed iMacker2020 closed 1 year ago

iMacker2020 commented 1 year ago

Hi, I like simple some of the examples. I was hoping to see an example that made use of an xib file. Also can we have an example that calls NSApplicationMain()? This is the description of the method from here: https://developer.apple.com/documentation/appkit/1428499-nsapplicationmain

Creates the application, loads the main nib file from the application’s main bundle, and runs the application. You must call this function from the main thread of your application, and you typically call it only once from your application’s main function. Your main function is usually generated automatically by Xcode.

I feel this function is important because it is responsible for loading values from the info.plist file.

ryanmcgrath commented 1 year ago

So regarding xibs/nibs... I don't use them, haven't touched 'em in close to a decade, and consider them an antipattern. I won't be doing any work to support them.

However, if others want to step up and contribute code for supporting them, I am more than open to incorporating them into the library due to their history as concepts in the ecosystem. So feel free to draft up a PR and I'll take a look. I'll leave this open as a general commentary issue for now.

Regarding loading values from Info.plist - can you be more specific? You should be able to do this regardless of xibs/nibs being a thing.

iMacker2020 commented 1 year ago

I find your answer on xib files to be very interesting. I never thought of them as an antipattern. I use them because they are very easy to create. They are as simple as point and click to make. But they do block you from learning how the AppKit framework works.

The Info.plist file provides the operating system with important information about the application. This can include LSMinimumSystemVersion which tells the operating system if the application can run on it.

This page has a lot more information you might find very useful for possible values it can have: https://developer.apple.com/documentation/bundleresources/information_property_list/bundle_configuration?language=objc

I suppose the user could make code that loads the values from Info.plist, but NSApplicationMain() already does this, so I think wrapping this function would be beneficial to everyone.

ryanmcgrath commented 1 year ago

My point re: Info values is that if you use a bundler - like you have to with cacao to begin with - it should be retrievable and a non issue.

Can you show an example where this isn’t the case? I’m open to missing something.

On Wed, Apr 5, 2023 at 14:33, iMacker2020 @.***> wrote:

I find your answer on xib files to be very interesting. I never thought of them as an antipattern. I use them because they are very easy to create. They are as simple as point and click to make. But they do block you from learning how the AppKit framework works.

The Info.plist file provides the operating system with important information about the application. This can include LSMinimumSystemVersion which tells the operating system if the application can run on it.

This page has a lot more information you might find very useful for possible values it can have: https://developer.apple.com/documentation/bundleresources/information_property_list/bundle_configuration?language=objc

I suppose the user could make code that loads the values from Info.plist, but NSApplicationMain() already does this, so I think wrapping this function would be beneficial to everyone.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

iMacker2020 commented 1 year ago

Well I was hoping that I could use my previous knowledge of how Apple wants us to create applications with a language other than Objective-C. But I see no reason to keep this issue open anymore. Thank you.

ryanmcgrath commented 1 year ago

I mean, you could, but it's increasingly clear that Apple's position is not nibs/xibs as the future, nor is Objective-C (unfortunately).

I also do not really understand your issue regarding Info.plist values, but ultimately like I said I won't resist pull requests for xib/nib features so feel free should you decide to revisit cacao.