|
I am having a difficult time finding swift example code targeted for macOS development. It seems the iOS world is so prolific that the macOS stuff is getting pushed down in the search engines. So, I thought I would ask here to see if there is some kind of cross-walk that would show what one needs to do to convert swift iOS app/code to be compatible with macOS? I try running the examples and I get errors telling me various classes are unknown, which I guess means they aren't being imported into the macOS app. It appears Apple is trying to get to the point where one day it doesn't matter which platform you're targeting in Swift, the code will work on any of their platforms. However, until that happens it seems different libraries have to be imported and different classes loaded in order to get something that works for iOS to work in macOS. I'm just not versed enough in the Swift language to know what I need to do. Some kind of help document would be great to have. So far I've not found anything. |
|
I forgot to mention that in my search I did find this tutorial for porting an iOS app to macOS: https://www.raywenderlich.com/571-porting-your-ios-app-to-macos which then led me to this document by Apple: And maybe this is all that is available. Just thought I would ask to see if there was something else that may be less intense, or shortcuts/tips & tricks to the process. |
|
Swift as a language is the same on both iOS and macOS - there's no porting that you need to do to move logic between the two. What is different between the platforms are the frameworks they support. I'm assuming your issue mostly has to do with migrating from
MacOS has a similar, but incompatible framework for UI creation, called The point I'm trying to make is that even though the two frameworks look very similar (many UI-prefixed classes have their NS---- counterparts in Ultimately, if you're going to be starting to learn macOS development now, I'd recommend you get Paul's book to introduce you to the important platform features (copy-paste, drag and drop, doc-based-apps, etc), but I'd advise to dive into Hope that helped at least a bit. --Jakub |
|
Thanks for the response. I'm new to Swift altogether, just not programming in general. I am working to port a program I wrote in Python to Swift for macOS. I want it to be a native mac App that I may eventually sell subscriptions for through the App store. But yes, I do understand that iOS (and other devices) are the mainstream programming out there. I purchased Paul's excellent book Hacking with Swift for macOS. I learned a lot about the way Swift works. I'm just trying to find more up-to-date information, tutorials, examples, etc. So far I've been searching stackoverflow for most of my needs and have come across a few tutorials that seem to work, even though they are for a much older version of Swift. Version lifecycle in the XCode/Swift world seems to be pretty short lived. I see my system just updated to Catalina version 6 today and XCode is now at 11.6, which I am assuming that would be Swift 5.3 or 5.4. I don't know how to tell which Swift version it is in XCode, if that is even a thing. Anyway, I'm trudging along and finding nuggets of information in the scattered reaches of the web and every now and then something just happens to work when I'm plugging away at it. :) |
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.