macOS 开发环境搭建的系列问题

319 天前
 ac169

平常都是使用 Windows 和 Linux, 现需要开发一个移动端 APP ,为了方便 Android 和 IOS 同时开发,决定在 macOS 上搭建开发环境,目前操作系统版本:macOS Catalina 10.15.7,刚接触 macOS 并且能又是做开发使用,所以有很多问题不解,希望大家指教!

虽然 APP 和 PKG 包都有默认安装路径,那么其他形式的二进制包放到什么目录比较规范?目前比较多的就是放到用户主目录下的某个位置,但这样放其他用户使用上不太方便有的还有权限问题且感觉很恼火;如果是放到根目录下的 Library 目录又有权限问题,比如:Android SDK 如果你不开写权限那么更新操作又有问题,如果开了,系统加环境变量后又提示这个目录有隐患。

  • APP 包都说直接移到废纸篓就可以了,但有没有文件残余问题,如何清理?
  • PKG 包如何卸载?系统好像有一个 pkgutil 命令行的工具但是好像没有完整的卸载功能,需要通过其他 APP 或者脚本来实现,感觉很恼火!

目前常见的都是将变量写入 ~/.zsrc 或 ~/.bashrc 文件的形式配置用户级环境变量的方法,有方法能配置系统级(所有用户都生效的)环境变量吗?有方法说将变量写入 /etc/profile 或 /etc/path 文件,但文件有保护无法写入。

  • 即使通过环境变量配置了国内源镜像 brew ,但是安装过程中还是有很多跳转到 github.com 造成安装失败,如果这个时候使用代理国内源又无法使用,这个问题如何破?
  • brew 感觉一味的安装新版本,不能针对系统版本来安装相应的版本(比如:brew install ruby 目前安装是最新 1.17.0 ,而这个版本 10.15.x 已经不支持),而指定版本方法又非常曲折(到 github 下载相应版本 rb 文件来安装)。当然对于新系统可能不存在问题但对于版本老一点的系统就是问题了,本身 brew 下载就慢结果搞半天还是错的,恼火!
3356 次点击
所在节点    macOS
40 条回复
ac169
318 天前
@loveumozart
@iamqk
@Xusually

为什么用老系统版本 我在 #5 提及过, 其中一个原因就是现有机器比较老了, 装新版本非常卡才降级回来的! 而 10.11.x 很流畅, 现在升级 10.15.7 感觉上都有点卡了, 为什么不换机器这些问题我觉得就不要讨论了.

本身 APP 功能很简单(实话说复杂功能 ios 也不一定支持), 不是说非要新 xcode 和新系统才能开发出来, 所以首要是要保证大部分工作效率, 至于老版本上架有问题到时候可以单独找一个新版本机器临时用用或者说升级到新版本来做上架适配,卡就卡点, 这个时候工作量也不多了, 这样的思路不行吗?
ac169
318 天前
@kingzeus

3.
5.

这个问题 在后续的 #5 中有提及就不赘述了.
8355
318 天前
@2NUT #18 用不了 2 3 年 intel 系的 cpu 都可能不支持了 就是这么真实。
iamqk
318 天前
@ac169
你用旧 Xcode ,就只能用旧的接口
1 新的接口和开发特性(比如最新的 swift5.8 之类的)以及 SDK 无法使用
2 旧的接口可能在新的环境中已经被弃用 无法编译通过等。

你这样软件简单还好说,软件复杂的话,上线前得不停的做修改,而且不能保持,因为修改后新版的代码也不支持在旧版 xcode 上跑。再次上架还得再来一次,可能得不偿失。
ac169
318 天前
@iamqk

2.

xcode 12.x -> xcode 14.x

iOS 14.4 -> iOS 16.0
Swift 5.3.2 -> Swift 5.7

支持的接口( UI 和 基本 io 方面)变化很大吗, 从那里可以看到这些变化?

个人觉得, 大多 app 开发无非就是写个界面和使用用一些基本的 io 接口!
iamqk
318 天前
@ac169 我反正把我的经验都告诉给你了,你估量着自己处理吧
ac169
318 天前
@iamqk 新特性可以不考虑,但接口变化这个问题肯定要考虑,特别是 UI 基本网络和文件 IO 方面 . 开始的意思是官方文档有没有具体介绍的, 还是这些变化只能自己摸索.
YsHaNg
318 天前
@cnhongwei zap 加 force 可以清理其他方式安装的配置文件
YsHaNg
318 天前
@ac169 ui 和 io 正好是这几个版本变化相当大的地方 如果想上架可能是不得不考虑放弃 10.15
ac169
318 天前
@YsHaNg 官方有详细的说明文档吗? 或能否用几个常用的接口和函数举例一下!
ac169
318 天前
15

Deprecations
supportedPhotoPixelFormatTypes(for:) and supportedRawPhotoPixelFormatTypes(for:) now return [OSType] instead of [NSNumber] in Swift. (64822071)

recommendedVideoSettings(forVideoCodecType:assetWriterOutputFileType:) now returns nullable NSDictionary<NSString *, id> * instead of nullable NSDictionary * in Objective-C and [String: Any]? instead of [AnyHashable: Any]? in Swift. (33784279)

cgImageRepresentation() and previewCGImageRepresentation() now return CGImage? instead of Unmanaged<CGImage>? in Swift. (44734827)

recommendedAudioSettingsForAssetWriter(writingTo:) now returns nullable NSDictionary<NSString *, id> * instead of nullable NSDictionary * in Objective-C and [String: Any]? instead of [AnyHashable: Any]? in Swift. (50450334)




15.4

Deprecations
Some extensions in std::tuple were removed to fix bugs caused by those extensions:

Tuples can no longer be constructed from fewer than the number of elements in the tuple. Previously, elements that weren’t specified were default-constructed; now this is a compiler error.

A tuple can no longer be constructed from an array.

The std::result_of and std::is_literal_type type traits are no longer available in C++20 mode, as specified in the Standard.




16

Deprecations
To improve security, CGImageCreate enforces parameter correctness on macOS 13 Ventura, iOS 16, iPadOS 16, watchOS 9, and tvOS 16. Passing an incorrect CGImageByteOrderInfo is no longer supported, and will result in images failing to load. (94855401)




16.2

Deprecations
In order to improve compiler type-checking performance, we’ve deprecated some Table initializers. They’re replaced with initializers which require an additional parameter that explicitly specifies the type they generate their contents from. This improves type-check performance by avoiding the need to infer a shared type from the bodies of separate closure parameters. For now, these initializers are deprecated. In a future release, those deprecation warnings will become errors. The new initializers add the parameter of:.

The new initializers add the parameter of:. The following shows a Table before, and after adoption of the new API:




16.4 https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_4-release-notes#Deprecations

Core ML
Deprecations
Core ML Model Deployment is being deprecated. Consider using Background Assets or NSURLSession instead. (102993813)

Core Telephony
Deprecations
CTCarrier, a deprecated API, returns static values for apps that are built with the iOS 16.4 SDK or later. (76283818)

Deprecations
TimelineView initializers that pass an instance of TimelineView<_, _>.Context into its content closure have been deprecated in this release, and replaced with equivalent versions that pass an instance of TimelineViewDefaultContext instead.




17 beta 3

Audio Codecs
Deprecations

The QDesign audio codecs (qdmc & qdm2) and Qualcomm PureVoice audio codecs (qclp & qclq) are no longer supported. (82414419)(82414419)




@YsHaNg 由于本身 12.15.7 xcode 12.4 对 14 大部分支持, 所以我直接从 15 开始找 一直到 17, 这个就是我找到的结果 这个对吗?
YsHaNg
318 天前
@ac169 yep 这也是我目前看到的 不是 ios 开发者 了解有限 但根据历年 wwdc 博客 应该还有很多 swiftui objc 相关 framework 改动 甚至包括 kalloc_type 的兼容
ihwbunny
317 天前
安装路径,可以在/usr/local/或者在 app 里面
环境变量:旧版本的 SIP 有问题,/etc/profile, /etc/zprofile, /etc/zshrc 等都改 root 可写,而且新版 macOS 的新账户默认使用 zsh 了
要是开发多用户的,运行时进行初始设置,一般无需设置全局的,如果需要,用 plist 设置,最好不直接全局/etc 中修改。
ac169
317 天前
@ihwbunny

谢谢, 其实关于环境问题我还有一个问题,就是优先级的问题! ~/.bashrc ~/.bash_profile ~/.zsrc ~/.bashrc ... 可以配置用户级的变量的文件都是五花八门, 到底配置那个 比如: 我看有个介绍就说 ~/.bash_profile > ~/.zsrc 或 ~/.bashrc 只有当 bash_profile 文件不存在的时候 才会调用, ~/.bash_profile 调用料 ~/.profile 但我实际配置这个文件 没有什么用 每次还是得 source 一次 , 如果配置在 ~/.zsrc 或 ~/.bashrc 就没有问题
murmur
317 天前
@ac169 非常大,我们升级到 14 ,x 之后程序基本废了,本来就是一堆老的社区组件,结果新版一大堆 c++编译报错,以前的 warning 成 error ,改不动了
ac169
317 天前
@murmur

macOS Catalina 10.15.7 最高支持 Xcode 12.4 而 Xcode 12.4 SDK 已经可以到 macOS 11.1 (20C63)* iOS 14.4 (18D46)* watchOS 7.2 (18S561)* tvOS 14.3 (18K559) , 既然是新项目肯定是以这个为起点, 结合实际来说也就是我只需要考虑 iOS 14.4 -> iOS 16.0 这其中有没有大的变化就可以了, 而这个区别我找了一下区别 在 #31 中列出了, 整个根本性的变化并不多, 再说我还不一定用得上相应的东西, 不知道我的这个理解是否正确?
ihwbunny
316 天前
@ac169

zsh 的:man zsh, 和参考: https://zsh.sourceforge.io/Doc/Release/Files.html#Startup_002fShutdown-Fileshttps://scriptingosx.com/2019/06/moving-to-zsh/

bash 的首先要看启动方式,是 login ,是 interactive ,还是非 interactive
login shell 的话,是/etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile
interactive 的看 ~/.bashrc
非 interactive, 会看 BASH_ENV
运行 scripts 的时候 要看/etc/profile and ~/.profile
remote 的话,看 ~/.bashrc
主要是看 man bash
ac169
316 天前
@ihwbunny 谢谢!
garibellee
314 天前
brew 也遇到过类似问题,svn->1.14.2 支持 openssl3 但是老项目 svn server 不支持 openssl3 ,搞了半天也是找了 rb 才搞定
sjgsgxsfsl
314 天前
除了 homebrew 还有 macports ( https://www.macports.org)

install 之前可以先 search

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/956245

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX