looks like:
"Everyone is welcome to contribute to Swift. Contributing doesn’t just mean submitting pull requests—there are many different ways for you to get involved, including answering questions on the mailing lists, reporting or triaging bugs, and participating in the Swift evolution process."
There might be some preference in doing extra work to support the new language but that is not the main reason. Xcode’s base compiler is LLVM an open source project started by some Apple employees in university years ago. This technology is used widely by many companies and maintained by groups of Apple, Google, Facebook, and other engineers to compile C like languages. Swift has not only made advancements at the language level but works on a higher level swift compiler with a lot of additions that allow it to have the REPL. This is the Read Eval Print Loop
feature that makes Playgrounds possible. And implementing that kind of feature for Objective-C would require a massive rewrite of those systems to allow for the compiler to be at the speed needed for REPL.
I am not saying it can’t be done but even with Apple’s resources it does not make any sense. The cost to benefit analysis of the research alone required for this type of change would be a waste of resources. It is just really hard from a time and cost perspective to see any value in this for the future of Apple development.
The Swift team is more-or-less reimplementing Foundation in Swift with Swift 3.0.
source: https://swift.org/about/#platform-support
That should negate any bridging related performance issues ... still I'm kind of curious about the issues you were running into with bridging as I've found it sufficiently performant for hundreds of thousands of objects in my apps. Not that I'm using a lot of JSON, but definitely a lot of bridging.
The author misses the most important features: Core Libraries. https://swift.org/core-libraries/#foundation
I think we can all agree that as of now swift is mainly a iOS language (which results in ~80% of posts in this subreddig being about iOS development).
If swift had a good (cross platform) standat library (like Go for example) the language adoption would skyrock. Simultaneously swift could reduce/drop ObjectiveC dependencies (like the NS[NextStep]) - like mentioned in the post. This is important because no new swift programmer will care about ObjectiveC... And they shouldn't...
You're getting the error because you are missing a }
before your else
. You also have an error in that there is no such thing as an else do
in Swift and the alert
value won't exist in your else
block even if you fix that.
It's clear from this bit of code that you aren't familiar with the Swift language at all. Do yourself a favor and read through the documentation before trying to do too much with the language.
Lol sorry but I just noticed that nobody had ever asked the question before when I tried googling it across reddit, stackoverflow etc. And I tried to search in the swift manual but didn't know it was called a keypath. Tried to cmd+F search \ in documentations like swift.org but couldn't find an easy explanation.
> Swift 5.3 release date is set to 20th if April
The official blog states that "On April 20, 2020 the release/5.3 branch will be cut in the swift repository".
This means that:
- a new branch of the Swift language, release/5.3
, will be created off the master
branch.
- from that day on new daily Swift 5.3 snapshots will be available to download here.
- Swift 5.3 will start its finalization process (mainly fixing the last bugs before official release).
We might be able to see a new Xcode dot release with Swift 5.3 before WWDC, but if that is not the case, we will have to wait until Xcode 12 is released before we can ship apps using exclusively SPM.
Mmmm note that the linked post uses Rust 1.5.0b5 (may be a performance regression?) and Swift 2.2-dev (possibly performance improvements?). I launched a download of Swift 2.2 snapshot to check.
edit: so after having downloaded the snapshot toolchain, here are the results on my machine (2010 15" MBP)
toolchain | time (real) |
---|---|
rust 1.5.0 | 4.54 |
swift 2.1.1 | 5.61 |
swift 2.2 (2015-12-10) | 3.04 |
here's the assembly for Swift 2.2-snapshot: http://pastebin.com/BV08VSdF
[0] on OSX El Capitan anyway
Swift really isn’t that different than the other C-style languages out there. Most of your programming knowledge will carry over.
I’d start with the official documentaion, there are some good links there. After that there’s the Stanford course and other various courses and books.
Truthfully, I don’t know many of the more popular courses out there because I’ve done quite a bit of C, C++, Java, and Objective-C programming and I was able to pick up Swift mostly from the official documentation and libraries. Other people will take other paths to learn the language, I’m sure.
Good luck on your learning! If you have any programming questions then post them here and I’ll help if I’m able, as will others.
> Type variableName = variableValue; > Was that so hard? Instead, we got: > let initialSquareCenter = square.center > Where's the type? Where the safty?
Swift has type inference (So does C# and a ton of other languages). That means the compiler and you can be certain of the type of initialSquareCenter
based upon the context of its declaration. It'll be of whatever type square.center
is and always will be. Also, since it was declared with let
we know that the value of initialSquareCenter
will not change.
>I'm saying that it's stupid to keep stuff from devs on purpose, which is definitely what they are doing.
>When the iPhone came out and they adopted Obj-C, Java and the concept of "automatic memory management" was well established, but they ignored the issue on purpose.
En la documentación oficial, asumiendo que ya sabes programar.
Si no te recomiendo arrancar por un lenguaje que sea menos nicho, aprender las generalidades, y después meterte con Swift.
UTF-8 and UTF-16 are both variable length encodings. Only UTF-32 is O(1) random access for characters. (However due to combining characters multiple Unicode characters can appear as a single character when rendered. Whether this is relevant depends on the use case. See also Unicode normalization.)
UTF-8 is much more space efficient and can avoid translation or even be zero-copy when interacting with other systems. You can either only have a UTF-8 type and require users to understand that random access is O(n), or you can have both UTF-8 and UTF-32 types and let the user choose based on their needs. You can also have UTF-8 with a "cache" mapping character offsets to byte offsets, similar to the "breadcrumbs" in Swift strings used to convert UTF-8 offsets to UTF-16 offsets.
Personally I think this is a choice the programmer should make and the language/standard library should provide facilities for all encodings. UTF-8 is great and should definitely be the default, but sometimes you want that O(1) random access of UTF-32 even if it quadruples memory usage. UTF-16 isn't very useful on its own but is great for interacting with other UTF-16 systems (eg Windows) without doing copies and translations.
Yes and no.
>Can I learn Swift Programming without Macbook?
Yes, you can. You can install Swift on a computer which runs Ubuntu (download it here) to learn Swift. The programming language isn't tied to iOS or macOS programming, and you don't need macOS to learn it.
>Please guide me I am interested in iOS Development.
For that part you'll need Xcode. Keep in mind you don't have to have the latest Macbook model for that :-) All you need is a Macbook capable of running the latest macOS version (so you can install the latest Xcode).
Your problem has nothing to do with whether it is applicable or not. The second sentence here is “code is read far more than it is written”: if your coworkers can't read it, don't write it. Gradually educate them and explain what's good about that style.
You should not start to use it just because it's cool and you are excited about it, you need to show why it is better that way.
Someone a year ago wrote big chunk of code and then left the company, now you inherit their code and have to maintain it and fix bugs. How would you feel if that code was in Prolog of Visual Basic because that was what they liked?
From the documentation:
> Packages for Linux are tar archives including a copy of the Swift compiler, lldb, and related tools. You can install them anywhere as long as the extracted tools are in your PATH. > > Note that nothing prevents Swift from being ported to other Linux distributions beyond the ones mentioned below. These are only the distributions where these binaries have been built and tested.
What Linux distribution do you want to use it on?
Try the binaries and see if they work. If they don't, try building them yourself from source.
You're young, so It would benefit you to learn to code in the long run. I'm assuming that you have a lot of down time that you can use to learn. As to how you can learn, watch youtube videos, read books, read documentation (https://swift.org/documentation/). There is really no one way to learn, try a few methods and see what works best for you. If your highscool offers any computer science classes, take advantage of those electives and take them.
If you find that it's not for you, then you can look into finding a technical co-founder.
The online book "The Swift Programming Language" by Apple is probably what you're looking for. It has a very comprehensive language guide that is always kept up to date with new versions of Swift. You can also get it on iBooks, if you enjoy the headache that is iBooks. There's also an ePub version.
Otherwise if you're looking for something more basic, my Swift cheatsheet provides some very succinct examples of a number of Swift features.
Swift isn't restricted to iOS, in fact the languate and standard library itself are free to use and incorporate into your own development environment. Right now you can develop apps for Linux in it for example.
It was even considered to be supported by Android Studio as an alternate language, but they ultimately decided on Kotlin (that, let's be honest, it's pretty damn similar to Swift) because it already had a working compiler to JVM bytecode.
If you want to take a look into how the language is faring you can visit https://swift.org/
You're going to need access to macOS for xcode; whether that's a mac device, or a hackintosh doesn't matter too much.
Apple is very protective of their ecosystem, you can probably find some sort of xcode alternative for ubuntu/similar but it probably won't work amazingly.
You can load the swift toolchain on linux though.
Hmm, weird.
The front page has a link to a section on Source Code, and that page has a link to the repository that is a 404. It seems like they updated the swift.org
website before they released the GitHub repository...
You may find all information you might need to run Swift on Linux here. Now, if you are using vscode there are plenty of extensions to add Swift language support to the code editor, your mileage may vary here.
No, Xcode itself is only available for macOS. You can build Swift code on Windows (natively or using Windows Subsystem for Linux), writing it with your editor of choice. To develop apps for Apple's platforms you'll need a Mac, though.
According to this blog post, you also need to install Ninja. The recommended way to do this is to install Visual Studio 2019, which is a separate IDE from Visual Studio Code.
When we talk about Swift and package managers we're talking about installing packages of code (libraries, frameworks, etc.) into our projects so that we can use that code to build programs. With RubyGems you're talking about installing both code and complete programs.
So right now, in Swift, you install packages on a per-project basis and not on a per-system basis like in RubyGems. You also only install code packages, not application packages.
Now, if you want something more like RubyGems et al. you are looking for something like [APT](https://en.wikipedia.org/wiki/APT_(Debian\)). There really isn't any major application package distribution program out there that's specific to Swift.
If what you are asking is how to use the Swift Package Manager then the instructions can be found at the link I gave you. Here's a more specific link:
Swift is a newer programming language created by Apple. It seems like they're pushing it as a modern replacement for Objective-C, for macOS and iOS development.
Swift is open source and it supports Linux, but it appears a lot of people see it as an Apple-only language.
For Swift 4 and later you can pretty much use any Mac that can run macOS High Sierra. An SSD would be nice, as would at least 8GB RAM.
Although compile times will be longer for older Macs you really won't see much difference until your project gets extremely complicated. While you're learning you can use just about any valid system without too much annoyance.
There is no such thing as "naming xxx quickly".
It reminds me of a piece I read some time ago, saying that the two most difficult things in programming were how to multi-thread properly, and naming variables & methods.
I'd say that no matter what you choose, prioritize coherence, especially with methods names, and don't be afraid to be verbose ; though, if you can come up with a shorter name that is equally comprehensive, go for it.
In your examples, I really don't find "gameOverLabel" to be overly verbose. "labelThatStatesThatTheGameIsOver" would be.
On top of all, don't use BS names like Pokemon names and such, or single-lettered names (with the exception of incrementers in loop statements).
Finally, try to use the standard framework naming conventions as much as you can.
Maybe these links could help you, though the Coding Guidelines for Cocoa seem a bit outdated now.
> learn Swift, a proprietary language that is only useful on Mac.
Swift is open source and is officially supported on macOS and Linux. Unfortunately there is no official Windows port. Check https://swift.org/ if you are curious.
This does feel more swifty. One note: the API design doc indicates that group
implies a mutating function. You'd probably want grouped
for a non-mutating version that returns a new dictionary. I haven't really looked at the SE group's patterns, but they may actually want both a non-mutating and a mutating version defined.
"<code>is/as AnyObject</code> always succeed for all types now. It's behaving as intended."
I agree, this is confusing. It's almost like AnyObject isn't actually an enforced type, but merely a slot which can only contain class instances:
> let spy = Spy() > box.value = spy as AnyObject > box.value $R0: AnyObject? = nil > box.value = spy as! AnyObject > box.value $R0: AnyObject? = nil
(There's some strange interaction with weak
here, too, because if you make the var strong, it succeeds in storing in box.value.)
But I think AnyObject is still a type. Perhaps the clue is in another comment on SR-2420:
> This is correct, because everything bridges to 'AnyObject' now.
I don't see it mentioned in the Migration Guide, and I don't see any swift-evo docs that say why this would have happened. In fact, SE-0072 suggests they did exactly the opposite! (Though perhaps only in the context of Objective-C?)
Maybe somebody smarter than me could dig through the built-in bridging convertibles in Swift 3, and figure out when and why this changed?
I think you should definitely file some bugs on this. At the very least, the documentation really needs to be updated.
It was a not a great metonymy, as the Swift API design guidelines prefer a much more concise syntax. In fact, Swift 3 changes how UIKit and other frameworks are imported, to more closely align with those guidelines.
> So any commercial software is a non-starter for hobbyists?
I'm sorry but that's plainly a mischaracterization of what I have said. To understand where I'm coming from, consider the new, young Swift programming language. Check out the Swift website. Note this line on the front page: "For students, learning Swift has been a great introduction to modern programming concepts and best practices. And because it is now open, their Swift skills will be able to be applied to an even broader range of platforms, from mobile devices to the desktop to the cloud."
Their clear focus is to build a development community around the Swift language by making the barrier to entry as low as possible and by targeting new developers as well as existing developers. Swift will soon become a more widely used language than Object Pascal because of this focus.
People are looking for new languages and they're not choosing Object Pascal because it's simply easier to choose another language.
> Also Joseph didn't make that distinction.
I don't know who Joseph is or what distinctions he may or may not have made. Better to focus on what I have said rather than what others may or may not have said.
The Swift API guidelines suggest that functions named like imperative verbs should be mutating, and that non-mutating counterparts should read like nouns or verbs ending in -ed/ing.
Thus, your trimmed()
makes sense, as it returns a trimmed version of the string. But camelize()
, latinize()
etc should be renamed to their -ed counterparts for consistency. capitalize()
doesn't capitalize the string (mutate it), but returns a capitalized copy.
They are reimplementation Foundation in pure Swift, don't know if NSNotificationCenter is done yet though.
Info : https://swift.org/core-libraries/#foundation
GitHub project page : https://github.com/apple/swift-corelibs-foundation
This was actually the Cocoa naming convention. The draft API design guidelines of Swift 3.0 instead encourages nouns for protocols which model a matter, and adjectives ending with -ing
, -ible
and -able
for protocols which describe capabilities.
I downloaded Swift binaries for Ubuntu since someone on /r/swift linked to them: https://swift.org/download/#latest-development-snapshots
I ran the Swift REPL and loved it. I always use Ruby's irb when I want to do some quick work, calculations... And now Swift is also an alternative. I discovered that Swift's reflection is based on the new Mirror concept that is also used in Dart. Here's a sample output:
17> var ms = Mirror(reflecting: a) ms: Mirror = { subjectType = Swift.Array children = { _box = { Swift._AnyCollectionBox = { Swift._AnyCollectionBoxBase = { Swift._AnySequenceBox = {} startIndex = { instance_type = 0x00007ffff7fb4108 } endIndex = { instance_type = 0x00007ffff7fb4108 } } } _base = { _oldMirror = { _value = 3 values { [0] = "aaa" [1] = "bbbbbb" [2] = "ccccccc" } } } } } displayStyle = Collection _makeSuperclassMirror = 0x00007ffff7feb028 _defaultDescendantRepresentation = Generated }
"The Swift core libraries project project aims to extend the cross-platform capabilities of Swift by providing portable implementations of fundamental Apple frameworks (such as Foundation) without dependencies on the Objective-C runtime. Although the core libraries are in an early stage of development, they will eventually provide improved source compatibility for Swift code across all platforms."
source: https://swift.org/about/#platform-support
Foundation and AppKit are the basis of most OS X applications.
Foundation and UIKit are the basis of most iOS applications.
Apple hasn't demonstrated any interest in a cross-platform Foundation since the days of WebObjects and YellowBox.
For similar functionality developers have had to turn to third parties i.e. GNUStep & Cocotron.
>graphic designer/web developer
Cool, I wish I have some time to learn either of these.
You can start with the official Swift Doc since you already know some programming. Then move straight to this course, one of the few I've done and recommended by many. It is updated every year, I did it back in 2017.
At the moment just macOS, but the core disassembler is written in pure Swift so should be portable to Linux at a minimum. Not sure about Windows but I believe there's efforts going on there to support it (https://swift.org/blog/swift-on-windows/).
I feel like some of these cons are outdated. Swift 5 gained ABI stability, so there’s no need to worry about having to rewrite your code base any longer.
As for lack of support for devices running anything under iOS 7, that’s pretty much a non-factor given that 94% of all iOS devices are at least iOS 12.
My only criticisms of Swift are:
Other than that, Swift is still by far my favorite language to work in.
No, and most likely never will be.
If we want to look at the simplest reason for that, the economical one:
A huge chunk of mac users are iOS developers, I don't have numbers, but, just to give you a perspective... Apple sells about 20 million macs per year... And there's more than 20 million registered (=that pay the 100$ annual fee) iOS Developers.
Not all of us would prefer windows/linux over macOS, obviously, but a lot of us would have never have gotten onto macOS if it wasn't for iOS Development.
So, it's fair to say that Xcode being available on windows would impact mac sales significantly
With that said, Swift, instead, is coming to Windows, but that is unrelated to iOS Development.
Apple utilizes AWS a lot, along with their own data centers. I would have a hard time believing Apple would start making server hardware again, even with Apple Silicon. Albeit I would love to see new Xserves.
There’s a big effort in getting Swift in more places. With projects like Swift aws lambda runtime and Swift cluster membership we’re seeing Swift used in more domains than just building apps for Apple’s platforms, and thats exciting.
There’s also a lot of movement with Swift in the AI/ML space since Swift is much faster than the domain dominate Python.
My hope is that Swift starts to be looked at as a more general programming language, as it was meant to be, then just an Apple platform language. This would be a great post for /r/swift which is a more language specific sub.
> no, that is in another class. the other class is like this
OK, it's really hard to picture what your situation is without seeing the actual code.
> public func addNewLizard(time:Double = 0.0,numLiz: Int = 0){
This function captures the lizard property which means you still have the name clash between the property and the class.
Have you tried renaming one or the other to remove the name clash?
> The constructor just doesnt work inside the other SKSCene class.
Are you talking about the graphics
class here?
And seriously, try following the style guidelines (see also: google's guide) and capitalize your type names. They exist for a reason.
Major releases for Swift are tied to Xcode releases so that is the easiest way to start using, if you want to get ahead of that you can either use beta versions of Xcode or install snapshot versions of swift https://swift.org/download/#snapshots
Apple’s swift programming guide is the place to start. It’s excellent and free. Also, there are LOTS of online sources, from blogs to tutorials to courses. Google is your friend.
tl;dr: architectural improvements are being worked on for diagnostics in the upcoming Swift 5.2 release to improve error messages.
Skip to "Examples Of Improved Diagnostics" on the page to see the before/after results so far.
I understand they don't allow this with arbitrary newer versions of the runtime, but they specifically called out the Swift 5 runtime as the one they would support in this way.
Swift does not have selectors or dynamic invocation. Swift does have a lot of metadata about classes and functions, so that verifications can happen at runtime. This metadata isn’t really exposed yet, however Swift Mirror does use it.
In Obj-C, when you classdump a class, methods usually look like doThing:(id)arg1 with:(id)arg2
. If a Swift classdump tool came out, there should be enough metadata to exactly reconstruct function prototypes.
You can download the swift compiler (without Xcode) from https://swift.org/download/#releases (Download "Toolchain" below "Xcode") and do whatever you want.
However, I suspect that is not what you actually want to do, if you really want to do something like a reddit bot, then why do you not want to use Xcode (Are you working on another OS than macOS or do you just want to use another editor?)
With Xcode you can build ordinary command line tools as well...
Funny how everyone came in and downvoted this post. Trying to save you the headache of dissecting the 7 year old obj-c examples from apple only to find out they don't work as expected.
https://swift.org is useful and does define guidelines (This is Apple's swift book). Also, if you are inside of xcode and alt-click on a line of code from the swift base, it will take you inside of the sources where you can view comments and get a better sense of the functionality your are looking for.
One thing worth mentioning is github. You can find out a ton of good information simply by looking at other people's swift code inside libraries, gists, and projects.
Damnit... You're post was so out of left field and errant feeling that I jumped on it.
At any rate, you did refer to Swift as though it in itself is unstable, but I think you simply mean that there's just too much change in the language from release to release for Apple to settle into converting over all of their frameworks.
Anyways, thanks for the lesson.
At this point I’d give Swift a try instead. It’s basically Objective-C with stronger type-safety, modernized, and a lot of cruft removed. It has a very strong Linux and FOSS involvement and is being used on the desktop, Android, iOS, and servers.
Take a look over at Swift.org.
If you haven't already, look into SwiftPM. It's the officially-supported way to build command-line tools that are larger than a single file.
Even though there's a REPL and you can run single scripts from the command-line, Swift is not really a scripting language. There's no way to "import" single other files into your own like you can in Ruby, for example. The way to combine 2 files is to compile them into an executable and run that.
While Foundation is not entirely implemented yet, Vapor has filled in all of the pieces you need to make a web app. (And IMO done a better job than Foundation could).
As Foundation continues to improve, Vapor will slowly start to adopt pieces of it. Especially when https://swift.org/server-apis/ are ready.
However, 95% of this is going to be behind the scenes / behind Vapor's public API. No reason to not start using it today.
Have you started looking into server side Swift? It is a very new area with a ton of potential. Now that Apple is organizing the Server APIs Project it will start to pick up momentum. The revolution will be #swiftlang
Not sure what you mean.
If you actually mean the source code of a whole app (thats presumably open source), than that would usually contain an .xcproj
(Xcode Project) or .xcworkspace
(Xcode Workspace) file. You just open that file with Xcode (prefer the workspace over the project if available) and you're done.
If, on the other hand, you mean import of 3rd Party dependencies, then have a look at CocoaPods, Carthage or Swift Package Manager
> Compare that to Java, C# and JavaScript where they never broke compatibility for practical purposes (Java literally never, C# broke some very minor things you are not likely to even notice, and JS only breaks for security issues and via strict mode which is not actually breaking anything)
Or compare with Swift which casually makes big changes to their language, check a list here: https://swift.org/blog/swift-3-0-released/
If you're trying to sell me what Java does as a better approach, you won't win me over. I respect Java's approach, but I don't believe in it. I only see the huge baggage that this language is lugging around, because they refuse to make some smart changes to the language, say how they handle null and nullable-by-default types.
There are ways to mitigate pain for users. Check what Swift does with migrations, for example. But never breaking BC is basically very slow death. Because you can't always make the right decisions, especially you can't make decisions that are guaranteed to stay right decades later.
BTW what C# does is on-par with with PHP does in terms of breaking BC. Definitely nothing major, especially after 5.0.
But it's not supposed to return a new array because the array still has the same values, it's just supposed to be sorted in a different order, so the function should use "sort" not "sorted."
Swift API Guideline; scroll down to "Name functions and methods according to their side-effects." If it's mutating the array, then use the verb only, so sort.
You can compare the documentation of Swift 2.2 to that of the Swift 3 documentation. You can see that they use the sorted function to return a new array rather than change the one that it's called on.
> but then the tutorials just get so "to add in a sound, know this line of code is what you need".
This can be addressed by learning how to understand/use an API. It's also a good situation for working on your google-fu.
Using your example of writing an app and wanting to add sound effects. Most programmers will not remember the exact syntax for playing a sound effect (unless they work on this kind of thing so often that it becomes memorized). All programmers are, however, aware that it is possible to play a sound effect in an app. This is where using an API or just using google-fu comes in.
I've just found the Swift documentation here. Similar documentation should be available for all major programming languages. Somewhere in there should be the specification for how to add a sound effect in Swift. Alternatively you could search for "swift add sound effect example" to see how its done.
There is something to be said about gaining a better understanding of programming architecture, design patters, data structures, algorithms, and most everything else that a good CS program should be teaching students. Those topics are not specific to any given language, but instead provide knowledge that benefits all of your programming collectively. It might be worth seeing if your library has any books you can check out, or just buy some from amazon.
https://github.com/apple/swift-evolution
There's also the (very active) swift-evolution mailing list where changes are discussed before becoming a proposal.
Okay, here's the script for it:
#!/bin/bash
# Get Swift # I know it's ubuntu 14.04, but there's no Debian one available wget https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-18-a/swift-2.2-SNAPSHOT-2015-12-18-a-ubuntu14.04.tar.gz
# Move it to Downloads mv swift-2.2-SNAPSHOT-2015-12-18-a-ubuntu14.04.tar.gz ~/Downloads
# Untar it tar -zxvf ~/Downloads/swift-2.2-SNAPSHOT-2015-12-18-a-ubuntu14.04.tar.gz
# Set it in $PATH # Copy next line to bashrc to set permanently export PATH=~/Downloads/swift-2.2-SNAPSHOT-2015-12-18-a-ubuntu14.04/usr/bin/:"${PATH}"
# Update packages sudo apt-get update
# Install (lots of) dependencies sudo apt-get install git cmake ninja-build clang uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config
Then, test it with swift --version
.
If you can't read the iBooks format, Apple has an ePub available at :
https://swift.org/documentation/
Direct download link
https://swift.org/documentation/TheSwiftProgrammingLanguage(Swift2.2).epub
The open source Swift project is implementing a Foundation framework in Swift and, it seems, releasing it as part of Swift 3.0.
"The Swift core libraries project project aims to extend the cross-platform capabilities of Swift by providing portable implementations of fundamental Apple frameworks (such as Foundation) without dependencies on the Objective-C runtime."
source: https://swift.org/about/#platform-support
It seems this is being done to support cross-platform development. It remains to be seen how if/when/how much of that project will be rolled back into Apple's own Foundation on OS X, iOS, etc.
This is the most interest I've seen Apple show in cross-platform development since the days of YellowBox and WebObjects. While I'm very much uncertain as to their intention to open-source or implement open-source versions of AppKit or UIKit, I tend to lean toward no. Then again I wouldn't have expected Apple to adopt the Apache license for this project, either.
Yeah use what makes sense for your team. But for swift naming in general, it’s good to follow the Swift API design guides - it’ll make it feel more ‘swifty’.
How did you even pay attention to my original post - I just came across Deque here https://swift.org/blog/swift-collections/
It looks like he might be a loon with a slow computer, because the sluggish movement of the character makes it unbearable to play. Just straight to ‘defeat’ and then I was like 80% from what I’m also thinking if I switch teams I’m officially a bing user
You should really learn how to use the Swift Package Manager. (Full documentation can be found here)
swift package init (options)
creates your package structure. Then you can edit your code and do a swift build
to build it or swift run
to run it.
I understand that. What I'm saying is if platform independent code uses platform dependent code as a reference, there is a question as to whether the specification is platform independent. Given the contents of this Swift document is a strong goal for the future, but needs to be verified at this time. As I said in another post, I lived through the UNIX wars where the initial platform independent specification for UNIX was based on how UNIX behaved on an AT&T 3B2 computer.
Let me ask this... as an experienced developer new to the iOS world... what resources, courses, etc. would you recommend? The swift.org language guide is really good and has helped me through most things... but there are still some mysteries specifically to iOS. Definitely some lifecycle mysteries, to me at least.
Most of the lessons I've seen are either expecting you to know nothing... or expecting you to have had a long history developing iOS. Not a lot of inbetween.
I think OP needs to define "worth." Presently, there aren't any IDEs or editors geared toward Swift editing so you'll need to use editors and such.
Right now, I have a Fedora server with it installed so I can get the basics under wraps -- like class definitions, extensions, protocols, etc. so yes - it could be a great learning tool. However, I'm unsure what libraries are currently available to do any real lifting on Linux, but it didn't complain when I imported Foundation for some reason. I know the only documentation that I can reliably say is for Linux (or whatever platform -- not Apple) is on swift.org's site, but even that tracks back to Apple so take with a grain of salt.
You should be able to download and install a prebuilt Swift Toolchain which has the basic tooling you’re looking for. You may need to add the installed tools to your $PATH
explicitly if you want to reference them.
Interesting! Just found this blog post on compiling Swift for Windows. Didn't know it was so readily possible, and that definitely makes it way easier than I'd thought! I assumed the most viable way to run it on Windows would be similar to how Android apps "ported" to Windows 11 run in a JVM.
From Evolving Swift On Apple Platforms After ABI Stability
> With the release of Swift 5.0, Swift is now ABI stable and is delivered as a core component of macOS, iOS, tvOS, and watchOS.… [A]s a result of this, the Swift runtime is now a component of the user’s target operating system rather than part of the developer’s toolchain. As a consequence, in the future, for a Swift project to adopt new Swift runtime and standard library functionality, it may also have to require new OS versions that include an updated Swift runtime supporting the added features. (Emphasis in original)
It continues:
> This tradeoff between adopting new language features and frameworks or maintaining compatibility with older OS versions has always existed for Objective-C and Apple system frameworks, and will now be a factor for Swift as well.
Unfortunately, following ABI stability a lot of new language features will need to wait for new OS versions. https://swift.org/blog/abi-stability-and-apple/
​
Basically, prior to API stability, each app used to ship with an embedded Swift runtime. (Meaning you would basically ship whatever Swift version you wrote the app in.) Now we have to use the system Swift version and cannot use language features that aren’t shipped with our minimum supported OS version.
Start working on an idea of your - maybe a TCP/IP based chat app or a calculator.
Also I’d recommend reading through documentations through The Swift Website and checking the tutorial
A bit late now, but I just came across Deque here
https://swift.org/blog/swift-collections/
It looks like it's going for the circular buffer and its stats are quite good.
About 5 years ago: I was you. I just started programming. I went and spent all my money, at 16, on a MacBook Pro. I knew nothing about programming or coding.
It took me almost four full years of dedicating myself to be able to build anything I want. Up until that fourth year, I couldn't build much. Then one day it all clicks. If you keep at it just trying to learn one small piece at a time: one day it will all click together and make sense.
The most underrated Swift website: https://swift.org/
There's a language guide that will help you understand basic programming concepts and the actual implementation in Swift. If you're brand new to coding: start basic. Learn logic/control flows/etc.
Keep working on an app, but don't expect grand results overnight.
No, I'm trying to get a Swift development environment on Windows and a Swift compiler on Windows. Swift has an official Windows release with a getting started tutorial: https://swift.org/getting-started/
But when I try to take Swift code that I've written and compile it into an executable, I get the errors I posted above. The Swift "code" that I'm compiling is just a print statement, so the problem is not in the code itself.
Just visit here
https://swift.org/documentation/#the-swift-programming-language
And read without skipping... after that, open your IDE and practice. Think about a pet project and try to reach success on it, when you stuck, search on internet for solutions 😉
Here is the steps I would take if I would learn programming again from scratch
1 - Stanford Cs101 this a very basic introduction to programming cover most of the things you need to know as a programmer.
2 - Read the swift documentation don’t worry if don’t understand the complex stuff like closures and stuff it would make sense later on. But read it fully !
3 - Stanford IOS Lecture this covers all the main things on iOS and gives you a detailed explanation. Do the homework and reading assignment.
Good luck ✊🏽
> Swift officially supports windows https://swift.org/platform-support/
Yes, just to be clear here since I mentioned it as well. Swift on Windows is a super awful experience right now. On Linux it is awful as well. getting it to even work is not fun, feels very very very not ready and if it is... then they are setting the bar low because on MacOS Swift is such a great experience.
I feel the same way. I started off just making small toy apps with XCode/Swift and I just really enjoy it. I, however have the same feeling as you... when it is only compatible within the apple ecosystem (remember that includes: IOS, MacOS, tvOS, watchOS, ...) My hope is that because Swift compiles to LLVM that it will soon be cross platform. There is a movement to make Swift Cross platform including Windows: (https://swift.org/download/#releases) My fingers are crossed that is successful.
I would love to hear someone who is active in the apple ecosystem with Swift and how they approach this problem or if it is a problem at all for being financially successful? For example, is there any major successful games on the appstore that are made in Swift and NOT Unreal Engine/Unity?
So many choices.
Swift/Vapor can work if you're already familiar with Swift.
JavaScript or TypeScript + Node.js is very popular these days.
Serverless functions via Amazon or Google are getting more common and you can combine them with a managed or unmanaged MySQL or PostgreSQL database. I think Amazon even supports Swift lambdas now.
One of my clients just made the jump to GraphQL via Apollo and it's kind of interesting, although probably overkill for you.
Rolling your own system from scratch is tempting and I've been toying with it, but a lot of things can be handled easier via 3rd party APIs, like eMail or SMS account validation, 2-factor, etc.
I found links in your comment that were not hyperlinked:
I did the honors for you.
^delete ^| ^information ^| ^<3
Im so new to swift but I was just reading about this on swift.org last night as nil optionals things that basically say "if this has any value, it's true" sort of boolean expression. I can't find it now that its been 12 hours since I read up on it...
I was able to find the ref for nil-coalescing operators, a variant of the ternary conditional, in the Language Guide under Basic Operators.
Would be cool, but the team would either have to:
Code it using Swift for Windows, which may have inconsistencies when compared to Swift for iOS
Learn another programming language, and program Notability in that programming language, which would take a couple years
I use Vapor and APNSwift to send push notifications, and it will do what you want. It should be fairly easy to setup a small API that would forward your push notifications, the messages will be dynamic as you have to send messages individually anyway.
As APNSwift in build on SwiftNIO you may be able to use it with Swift for AWS Lambda (I haven't used it with Lambda and I'm not sure how well it will work, as I assume it would create a new connection to APNs for each message, and you're not meant to do that)
I found links in your comment that were not hyperlinked:
I did the honors for you.
^delete ^| ^information ^| ^<3
I was facing a similar issue when showing a sheet with a UIViewControllerRepresentable that was running several animations and layout calls in viewDidLoad.
In my case both SwiftUI and UIView.animate(...) were trying to write the same memory address and got caught in runtime by the “Exclusive Access to Memory” protection (https://swift.org/blog/swift-5-exclusivity/).
Maybe building your app with release config will help you at least reproduce the bug
That was already the case, this just makes your life easier if you do. I develop software on my mac which runs on linux servers and I've got to say I'm pumped about this. Might make me give swift a try.
The actual swift blog post goes into more technical detail: https://swift.org/blog/swift-system/
Pretty cool stuff.
You still need to have explicit code paths for Apple platforms, Linux and Windows is WIP after all these years.
This is the sample code on Swift's web site:
1> import Glibc 2> random() % 10 $R0: Int32 = 4
Anyone new to Swift will look at it and think that even for basic stuff like random numbers they aren't able to provide something that is cross platform.
https://swift.org/getting-started/#using-the-repl
And is mostly true, because what one gets outside Apple platforms is just the bare bones language, the Frameworks aren't cross platform.
Thank you, extremely helpful post. I will have to pore through that link tomorrow. Is this something that should be in the Swift documentation? Or am I perhaps looking in the wrong place?
Swift 5.3 is allegedly going to support Windows. See 5.3 release process.
Separately, if you're just looking to develop Swift on Windows (and deploy elsewhere), then it works pretty well using the Swift Linux toolchains under a WSL2 Ubuntu distro.
I very rarely comment on reddit, mostly post memes and stuff but I have to say this endeavour is most certainly spectacular. The idea it self is amazing, the execution (based on the limited information of the app) is well done and product is unique.
I'm currently learning Swift and going through the Swift.org documentation (closures have been a pain in the ass for the last 2 days or so), it's an amazing language supported by a great company. Seeing products like these really motivates me to continue to learn in hopes of making great apps and or providing amazing services in the future, thank you.
I would like to you wish you nothing but success and truly hope that this app takes off and makes the lives of people with allergies easier.
Bravo 👏
I don't know what they are going to do, just what they state.
> Swift is intended as a replacement for C-based languages (C, C++, and Objective-C).
Taken from https://swift.org/about/
> Swift is a successor to both the C and Objective-C languages.
Taken from https://developer.apple.com/swift/
Naturally whatever they might end up rewriting will take its time, however I bet that many kernel extensions will be eventually done in Swift, now that they are migrating everything to userspace, micro-kernel style.
Just like Metal, real time audio audio, and vector processing have Swift bindings.
As excited as I am for this, this has been posted here at least 3 times, but from the official source here
I already knew your current job is PHP when you said it was written by a programmer who does not even use functions.
A literal quotation from PHP's creator: "I have absolutely no idea how to write a programming language" and "I don't know how to stop it, there was never any intent to write a programming language".
Not saying PHP is bad. Modern PHP (especially PHP 7) added in a lot of good, modern programming language features.
But, to support "old style" PHP, even in modern PHP you can get away with writing code entirely without using those modern features. And many companies are still wedded to old PHP versions.
Not trying to talk shit or anything—it's just that I was a PHP dev myself for awhile, so I... fully understand your pain... in very deep ways... like the bond shared by those men who survived the trench warfare of World War 1, or those men who first explored the Amazon jungle.
Ahem.
Now comes the part where I tell you to learn Swift.
Look up IBM's Kitura webserver, written in Swift for linux. There are a couple of other, similar things, but that one has great documentation.
If your background is in C++ then you will appreciate the fact that the Swift compiler is open source and written in C++. Head over to https://swift.org and check it out.
Being a mobile developer on Apple's platforms has paid off really well for me.
If you're more the Android type then Kotlin is a very Swift-like language that compiles to JVM code.
On Apple's blog in the first paragraph they say "this release will expand the number of platforms where Swift is available and supported, notably adding support for Windows and additional Linux distributions.", but I don't know when they will release it actually. https://swift.org/blog/5-3-release-process/
<pats on head> Sure you are buddy... sure you are.
Just to help you along, there are examples from Apple's APIs in here: https://swift.org/documentation/api-design-guidelines/
I wish you the best during your internships.