Page 1 of 1

Plugin writing in Swift

Posted: Sat Nov 11, 2017 10:36 am
by LibertyTrooper
Soooo... I decided to learn Swift by taking and converting the Sample plugin. So far so good because the plugin is loading and the methods are being called. The bad news is that I obviously suck at programming in Swift so I'm able to wipe DVDPedia out pretty much at will.

Ok, to get to the point of this post, perhaps there is a way to pin Plugin development information in one post at the top of a forum? I was digging around to find information on debugging approaches (I've never debugged a plugin on Mac before) . Also, there are a lot of dead links to samples, probably because of the evolution of the API. Yet sometimes even old code may be useful. Actually, what may be even better is to have a github repository.

Best practices I'd like to have in the 'pinned post' if such happens are:

1.) In your debug copy of the app (DVDPedia in my case), remove all the plugins except for IMDB, Wikipedia, and whatever plugin is most useful for your locale. This cuts down on clutter.
2.) Make sure you build the example and run it under the debugger prior to working on your own plugin. This will illuminate you as to the requirements for debugging plugins on the Mac.
3.) Copy the script from the build phase titled 'Quit Copy Launch'. It will save you time and aggravation.
4.) Be very aware of any preconceived notions lingering from previous experiences you may have regarding plugin APIs. They will lead you astray.

In case anyone cares, after my initial brush, Swift strikes me as a complete mess of a language. Though, I do have to say that it is, from appearance only, less verbose than Objective-C, that lack of verbosity is only because the explosion of operators and weird syntactical constructs that exist in, I think, the interest of less typing...

Heh... Its probably the only thing where they have focused on function to the exclusion of form. I betcha Mr Ives had no idea. Otherwise it have been named 'Shiny' instead of Swift.

I'd hate to see the BNF for this strong typed but lazy language.

However, in case I'm only reacting because of my preconceived notions, I will stick with it. Knowing Apple, they are going to deprecate Objective-C at some point.

Yes, for all those who are wondering, without gainful occupation I have a great deal of time on my hands. Thats why I'm going through app comparisons, learning to fully exploit Devonthink and Tinderbox and now the Pedias, finally attempting to gain control of my library, sad attempts at writing humorous forum posts when I'm stuck waiting on something in one of the other projects, exploring new versions of old and favorite programming languages (Smalltalk!), and learning a couple of new ones: All at the same time.



Yay, its Veterans day. Wait.. its on a Saturday and I don't have a job anyways... Damn... I never seem to get to use my benefits.

Re: Plugin writing in Swift

Posted: Sat Nov 11, 2017 2:52 pm
by Conor
Swift is the way to go, it's the future. But like Carbon, it's going to take Apple about 20 years to be able to kill off Objective-C.

I been writing Obj-C for so long, it's hard to like Swift. I like the syntax, but those are improvements they could have brought to Obj-C as well. The simple fact of not needing a semi-colon to end each line would save many fairies. I like the strong type casting, but dislike optionals. I find being able to message nil as a non-operation very useful. Swift lacking this ability is littered with let and guard that are unnecessary.

I don't think we have pinning enabled on the forum software. But thanks for writing those out, I have copied them to use when updating the plugin page and just modernizing everything. If you do make your code public once it's done, do let me know as it would be nice to have a Sample Swift version out there, for users to find.I might even fork it and strip it of most code and make a simplified Swift version.
Actually, what may be even better is to have a github repository.
I have been meaning for years to put the code up in Git repositories with a built version as well, this way allowing the pedias to update directly from the git version and making development easier to collaborate and to download. But it's so low priority that it's been sitting in the back burner for ever. It also has a number of security implications and hence why it's easier to lock the Pedias to downloading from things at our domain.

Re: Plugin writing in Swift

Posted: Sat Nov 11, 2017 8:02 pm
by LibertyTrooper
Swift is the way to go, it's the future. But like Carbon, it's going to take Apple about 20 years to be able to kill off Objective-C.
I was going to say "just like they did Carbon" but I didn't want to irritate anyone
I like the strong type casting, but dislike optionals.
I dislike them as well. It takes over-complication to a whole new level. One far beyond the mere verbosity and Smalltalk-isms of Objc. At least, with ObjC, the complexity was in the typing. Not in trying figure out what the compiler will do as a result of the typing.
I have been meaning for years to put the code up in Git repositories with a built version
Ah, thats too bad. I was only hoping for the current and past example code

I'm working on brevity.