今年的雪很大、很好玩~
Algorithm
本周选择的算法题是:House Robber。
impl Solution {
pub fn rob(nums: Vec<i32>) -> i32 {
let mut dp = vec![0; nums.len() + 1];
dp[1] = nums[0];
for i in 2..=nums.len() {
dp[i] = std::cmp::max(dp[i - 1], dp[i - 2] + nums[i - 1]);
}
dp[nums.len()]
}
}
Review
A Software Engineer’s Guide for Driving Large Projects
文章很长。
这篇文章对于管理软件项目非常有用,比如 “管理期望也是一个关键部分。它涉及对项目结果、时间表和潜在挑战的态度。这种透明度不仅可以建立信任,还可以让利益相关者为任何可能发生的情况做好准备。”
我们经常忘记确保利益相关者的期望符合现实,也因此导致项目结果在项目结束后并不会得到很好的认可。
虽然看起来项目管理是 PM 的活,但要知道,并非每个组织都有独立的 PM 岗位,许多组织希望他们的高级软件工程师来推动项目,因此作为软件工程师确实应该培养一下项目管理能力,这是晋升到更高级别的要求,而且别忘了,工程师的角色是解决问题,具备确保真正问题得到解决的技能是必要的。
Tip
推荐一个 AI Code Review 的工具:CodeRabbit,能逐行分析代码和并提供精确的改进建议。
Share
再分享一个 Xcode 的 Bug 解决方式吧,没办法,Xcode 的 Bug 属实有点多。
问题的表现是,用 Xcode 编译代码,或者用 pod 执行 lint 时会报如下错误:
...
ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/var/folders/dp/2xq7_lgj7k5fdnl5xm0s126r0000gn/T/CocoaPods-Lint-20230401-1982-y8jwp9-GRDB.swift/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.9, but the range of supported deployment target versions is 10.13 to 13.3.99. (in target 'SQLCipher' from project 'Pods')
** BUILD FAILED **
...
Testing with `xcodebuild`.
-> GRDB.swift (6.10.1)
- NOTE | [GRDB.swift/standard,GRDB.swift/SQLCipher] xcodebuild: note: Using codesigning identity override: -
- NOTE | [GRDB.swift/standard,GRDB.swift/SQLCipher] xcodebuild: note: Building targets in dependency order
- NOTE | [GRDB.swift/standard,GRDB.swift/SQLCipher] xcodebuild: note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'GRDB.swift' from project 'Pods')
- NOTE | [GRDB.swift/standard,GRDB.swift/SQLCipher] xcodebuild: note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'App' from project 'App')
- NOTE | [GRDB.swift/standard,GRDB.swift/SQLCipher] xcodebuild: note: Using codesigning identity override:
- ERROR | [GRDB.swift/SQLCipher] xcodebuild: Returned an unsuccessful exit code.
- NOTE | [GRDB.swift/SQLCipher] xcodebuild: clang: error: linker command failed with exit code 1 (use -v to see invocation)
- NOTE | [iOS] [GRDB.swift/SQLCipher] xcodebuild: Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'SQLCipher' from project 'Pods')
- NOTE | [OSX] [GRDB.swift/SQLCipher] xcodebuild: Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.9, but the range of supported deployment target versions is 10.13 to 13.3.99. (in target 'SQLCipher' from project 'Pods')
- NOTE | [watchOS] [GRDB.swift/SQLCipher] xcodebuild: Pods.xcodeproj: warning: The watchOS Simulator deployment target 'WATCHOS_DEPLOYMENT_TARGET' is set to 2.0, but the range of supported deployment target versions is 4.0 to 9.4.99. (in target 'SQLCipher' from project 'Pods')
- NOTE | [tvOS] [GRDB.swift/SQLCipher] xcodebuild: Pods.xcodeproj: warning: The tvOS Simulator deployment target 'TVOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.4.99. (in target 'SQLCipher' from project 'Pods')
[!] GRDB.swift did not pass validation, due to 1 error.
You can use the `--no-clean` option to inspect any issue.
简单来说就是 xcodebuild
执行失败了:
xcodebuild: Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.0.99.
这个问题蛋疼的地方在于它告诉你,是你的 deployment target 没有正确设置,但这是误导,和你的工程设置没有任何关系,仅仅是 Xcode 的 Bug 而已。
GitHub 上也有类似的问题反馈:
- Xcode 14.3 fix: Pass the -f option when resolving the path to the symlinked source. #11828
- Xcode 15 beta 6 pod repo push fails with deployment target too low #12033
- Xcode 14.3 has
pod lib lint
fail #11839
它的真正原因是:Xcode 在编译 Swift 代码时需要使用 libarclite_xxx.a
文件,这个文件与 CocoaPods 有关,当 Xcode 找不到 libarclite_xxx.a
时,它就会报上述错误。所以你可以先检查一下这些文件是否存在:
如果不存在,你需要:
- 用 git 将 Libarclite-Files clone 到本地
- 如果
arc
目录不存在则需要新创建arc
目录 - 然后将所有文件复制到
arc
目录下 - 重新编译项目
Done.