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

Xcode 9 制作Framework时添加自定义设置的方法及禁用问题解决

Hey there! Let's work through your questions about adding custom settings and variables when building a Framework in Xcode 9— I’ve dealt with this exact setup (and that annoying disabled button issue) before, so let’s break it down.

1. How to Add User-Defined Settings Normally

If the "Add User-Defined Setting" option is enabled, follow these straightforward steps:

  • Open your Framework project, and make sure you’ve selected your Framework target (not the top-level project— this is a super common mix-up!)
  • Switch to the Build Settings tab
  • Look for the small + button in the top-left corner of the Build Settings pane
  • Select Add User-Defined Setting from the dropdown
  • Name your setting (e.g., FRAMEWORK_VERSION_SUFFIX or MY_CUSTOM_CONFIG) and set its value as needed. You can even add different values for Debug and Release configurations by clicking the disclosure triangle next to the setting name.
2. Fixing the Disabled "Add User-Defined Setting" Option

If that + button is grayed out, don’t panic— here are two reliable workarounds:

Workaround 1: Double-Check Your Selection

First, triple-confirm you’ve selected the Framework target, not the project itself. When you have the project selected instead of the target, the option to add user-defined settings is disabled by default. Click on your target in the left sidebar (under "Targets") and try again— this fixes the issue 90% of the time.

Workaround 2: Manually Edit the Project File

If selecting the target doesn’t help, you can manually add the setting directly to the project’s .pbxproj file:

  • Close Xcode completely (important to avoid file conflicts)
  • Find your .xcodeproj file in Finder, right-click it, and select Show Package Contents
  • Open the project.pbxproj file with a text editor (like VS Code or TextEdit— just make sure it’s not a rich text editor)
  • Search for your Framework target’s name to locate its XCBuildConfiguration sections (you’ll see separate entries for Debug and Release usually)
  • Inside the buildSettings block of the configuration(s) you want, add your custom setting in this format:
    MY_CUSTOM_VAR = "MyCustomValue";
    
  • Save the file, then reopen Xcode. Your new user-defined setting should now appear in the Build Settings tab under the "User-Defined" section.

Bonus: Alternative for Custom Variables

If you just need a custom variable to use in your code or build scripts, you can also add it to the Preprocessor Macros section under Build Settings. For example, add APP_CUSTOM_KEY="xyz123" here— it’ll be available as a macro in your code, and you can reference it in scripts using $(APP_CUSTOM_KEY) too.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:57:22