讓 Xcode 15 擁有建置給 macOS 10.9 的能力
免責聲明:理論上而言,用這招類推可以建置給早期版本的 iOS。但實際上管不管用我就沒法保證了,因為我不是 iOS 程式師。
本文專門給那些需要在新版本系統當中用新版本 Xcode 將祖產專案建置給早期系統版本的資工業者們。
Xcode 15 需要打 libarclite 才能給早於 macOS 10.13 的系統建置應用程式。
通用做法就是從 Xcode 14.2 或 Xcode 13 當中提取出 libarclite 套裝,然後植入到 Xcode 15 當中。先開啟 toolchains 資料夾:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
再把 libarclite 的東西放進去(也就是 arc
這個資料夾):
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
然而,如果是 macOS 10.9 的話,事情還要複雜一個層次:
macOS 14 Sonoma 開始的 SDK 幾乎把整個 Foundation 當中的很多基礎類型都重寫了。這就導致之前那些被 Swift 從 Objective-C 借走的基礎類型全部都得重新打上「NS」開頭的後綴才可以直接使用。但這還有一個問題:NSLocalizedString 的建構子不能使用了,因為這玩意在 macOS 14 當中也是被(用純 Swift)徹底重構的基礎類型之一。Apple 毫不留情地給這些基礎類型都下了全局的「@available(macOS 10.10, *)
」的宣告:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
這樣一來,除了 libarclite 以外,還需要舊版 macOS SDK 才可以。雖然 macOS 13 Ventura 的 SDK 也可以湊合用,但(保險起見)筆者推薦 macOS 12 Monterey 的 SDK:Release macOS 12.3 SDK · alexey-lysiuk/macos-sdk (github.com)。該 SDK 的安置位置:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
再修改一下 Xcode 專案當中對 macOS SDK 的指定(不用理會 not found):
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
這樣應該就可以正常組建了。如果有提示說 Date 不符合最新版本要求的話,把 Date 改成 NSDate 即可。
$ EOF.