
这几天在研究 macos 应用,打算做一个给大家好好用用,其实之前做过 VB 和 C# 的 webform 和 winform 编程,再来 研究 c++ 的qt5, python的 pyqt5, swift 的 ios 和macos 编程 其实都是一样的,拖拉控件,对控件的操作 什么点击 链接 响应等等,macOS 的研究 看国内还是很缺少教程的。大家都去整 ios 了,其实整过ios 再整 macOS也是非常容易迁移完成的。
这里有比较完善的mac的tutorial 建议大家翻翻看看
https://github.com/CSharpHai/macOS_Development_Tutorials_translation
swift 按道理来说是一门面向未来的语言,不只是做控件,swift 完全是可以 全栈的,说道全栈 必须整整后端,swift 后端 由一个比较强大的 框架 perfect 来完成
perfect 的tutorial 参考
https://github.com/PerfectlySoft/PerfectDocs
https://segmentfault.com/a/1190000007436220
https://github.com/PerfectlySoft/Perfect
https://github.com/Swift-AI/NeuralNet-Handwriting-iOS/blob/master/Handwriting/NeuralNet.swift
https://www.cnblogs.com/ludashi/p/6165418.html
https://github.com/apple/swift-package-manager
https://blog.csdn.net/woaizijiheni/article/details/50614062
https://blog.csdn.net/u014220518/article/details/79217903
https://www.cnblogs.com/ludashi/p/6145344.html
https://blog.csdn.net/loveqcx123/article/details/70240829?locationNum=6&fps=1
https://www.jianshu.com/p/46c59c647b6e?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
perfect 好像和java的 spring ,scala的 play ,python的 Django 还要强大些,支持的wrap 组件 还是非常丰富的,mysql kafka zookeeper 甚至 tensorflow
另外 swift 也在去年发布了 自己的包管理器 spm ,迟到的总要来的,一个没有自己包管理器的语言 要么被淘汰 要么被替代。不过spm 很搞笑也会捡现成的,直接使用的是github的链接做依赖,社会 社会
在使用spm ,在使用swift 写后端,真的有一种 身轻如燕,逃离枷锁的感觉。
另外 swift 还有自己的 机器学习包
https://github.com/Swift-AI/Swift-AI
https://github.com/Swift-AI
在使用spm 我们有一个 样例参考
https://www.jianshu.com/p/4caecb22c4bd
这个讲的很清楚
$ mkdir SPMDemo // 创建文件夹
$ cd SPMDemo // 进入文件夹
$ swift package init --type executable // 初始化为可执行项目
Creating executable package: SPMDemo
Creating Package.swift
Creating .gitignore
Creating Sources/
Creating Sources/main.swift
Creating Tests/
$ swift package generate-xcodeproj //生成Xcode工程,可用Xcode打开
generated: ./SPMDemo.xcodeproj
$ swift build // swift 编译并生成可执行文件
Compile Swift Module 'SPMDemo' (1 sources)
Linking ./.build/debug/SPMDemo
$ ./.build/debug/SPMDemo // 执行生成的文件
Hello, world!
我尝试了一下,运行是正常的,不过中间有个小插曲,我的swift version 是 4.0.1
xcode version 是 9
在 swift package generate-xcodeproj //生成Xcode工程 是报错
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Deve
其实是 swift 找不到 xcode 去执行,原因是可能 xcode的环境变量有问题,或者是 一台电脑安装了多个版本的xcode。
如何操作呢
su root # 切换到 root 用户
sh-3.2# xcode-select --switch /Applications/Xcode.app/Contents/Developer/
执行即可
完事就可以了
另外一些 干货在这
https://www.jianshu.com/p/46c59c647b6e?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
还有就是一个swift的一个后端项目