# 18. 解决修改 xcconfig 配置版本号和 build 号不生效的问题

**作者**: [高老师很忙](https://weibo.com/517082456)

之前我有介绍过 `xcconfig` 这个 tip，最近使用中遇到了一点小问题：当我使用 `xcconfig` 来管理版本号和 `build` 号时（如下图所示），

![](/files/-LUYjhmgjN2clNFOESEq)

![](/files/-LUYjhmi8enoUA5r3VUc)

编译一次之后，修改这两个值，此时我在运行的时候想把这两个值读出来，如下图所示：

![](/files/-LUYjhmkXPv7ywRwh_aZ)

发现读出来的依然是修改之前的值，如下图所示：

![](/files/-LUYjhmmkRKc3BJbJ5Ca)

此时打开 `Product` 下面的 `Demo.app` 文件，查看 `Info.plist` 文件发现，里面果然显示的还是老值，如下图所示：

![](/files/-LUYjhmoxz4c2PdzN5VM)

这是因为使用 `xcconfig` 管理这两个值后，`Info.plist` 用的这两个值是 `User-Defined` 变量，并不能检测这两个变量内容有变更导致的缓存问题。最简单的解决办法就是 `Clean` 一下，再运行就能显示正确的值了，但对于中大型项目来说 `Clean` 的成本有点高，所以就想到了用脚本来解决这个问题（如下图所示），

![](/files/-LUYjhmqeNGEVPZsvaxg)

每次运行时更新这两个缓存中的值即可。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://awesome-tips.gitbook.io/ios/xcode/content-17.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
