You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

技术问询:能否在Xcode 9中开发OS X屏幕保护程序?

Can I Develop Screen Savers in Xcode 9?

Hey there! Great question—you absolutely can build screen savers with Xcode 9, even though the dedicated screen saver project template isn’t visible by default anymore. Here’s how to set up your project from scratch:

Step 1: Create a Bundle Project

  • Open Xcode 9 and select Create a new Xcode project.
  • Under the macOS category, choose the Bundle template (found in the Framework & Library section).
  • Configure your project details:
    • Product Name: Name your screen saver (e.g., "MyCoolScreensaver").
    • Bundle Identifier: Use a reverse-domain format (like com.yourusername.MyCoolScreensaver).
    • Critical: Set the Bundle Extension to saver—this tells macOS your bundle is a screen saver.
    • Language: Pick Swift or Objective-C based on your preference.

Step 2: Configure Project Settings

  • Select your project target and navigate to the Build Settings tab.
  • Search for "Base SDK" and confirm it’s set to macOS.
  • Search for "Principal Class" and set it to ScreenSaverView (if using Swift, prepend your module name, e.g., MyCoolScreensaver.ScreenSaverView).
  • Link the ScreenSaver framework: Go to Build Phases → Link Binary With Libraries, click the + button, search for "ScreenSaver", and add it to your project.

Step 3: Build Your Screen Saver Logic

  • Create a new class that inherits from ScreenSaverView (for Swift: class MyScreensaverView: ScreenSaverView).
  • Implement key methods to add functionality:
    • draw(_ rect: NSRect): Use this to render your screen saver’s visuals.
    • startAnimation(): Initialize timers or animation loops here.
    • stopAnimation(): Clean up resources when the screen saver stops.

Step 4: Test and Install

  • Build your project, then find the generated .saver file in the Products group (right-click it and select Show in Finder).
  • Double-click the .saver file—macOS will prompt you to install it to your user-specific screen saver directory (~/Library/Screen Savers/).
  • Open System Preferences → Desktop & Screen Saver to select and preview your new screen saver.

The dedicated template might have been removed in Xcode 9, but this bundle-based approach works just as well and gives you full control over your screen saver’s functionality.

内容的提问来源于stack exchange,提问作者Centell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:44:07