Xcode 15.1 and 15.2 Objective-C Category/Extension Creation Issue

I'm encountering an issue with the latest versions of Xcode (15.1 and 15.2) while programming in Objective-C. When I try to create a category or an extension for a class, the process does not succeed and there is no response, with the category file not being created. This problem was not present in Xcode 15.0.1. My development environment is macOS Ventura 13.6.1. This bug is affecting my development work significantly. Could you please investigate this issue and provide a solution? Thank you for your assistance.

我在使用最新版本的Xcode(15.1和15.2)进行Objective-C编程时遇到了一个问题。当我尝试为一个类创建分类或扩展时,过程并不成功,没有任何反应,且分类文件没有被创建。在之前的版本Xcode 15.0.1中并没有这个问题。我的开发环境是 macOS Ventura 13.6.1。这个bug严重影响了我的开发工作。您能否调查此问题并提供解决方案?感谢您的帮助。

Answered by Robin1024 in 780300022

This is because new Xcode 15.1/15/2 does not contain CategoryNSObject and CategoryNSObject files on path Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate ,you can copy this file from previous version,or click this link(https://pan.baidu.com/s/1Xs_8PnKyA0rY_8fpBKxhHQ?pwd=g2sm#list/path=%2F) to download and copy it to path.

  1. open path: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate
  2. copy CategoryNSObject file and ExtensionNSObject file to Objective-C File.xctemplate
  3. restart xcode

这是由于新版Xcode安装包目录中缺少 CategoryNSObject 和 CategoryNSObject文件导致的,对应目录:Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate,可以从旧版Xcode目录中找到对应文件复制到这个目录下,如果无 旧版 Xcode,可以用这个链接下载(https://pan.baidu.com/s/1Xs_8PnKyA0rY_8fpBKxhHQ?pwd=g2sm#list/path=%2F)%EF%BC%9B

  1. 打开目录:/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate
  2. 复制文件 CategoryNSObject 及 ExtensionNSObject
  3. 重启Xcode

the process does not succeed and there is no response, with the category file not being created.

I’d like to clarify this. Do it mean that Xcode hung while trying to create the source file? Or that you were able to create the category source file with Xcode but then your program hung?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo: See this thread for more details. Basically the new file creation flow seems to work normally until the final save panel, but then hitting the Create button behaves as if you hit Cancel instead. Xcode keeps running fine but you get no new file and the project file is unchanged.

Oh, interesting.

So, yeah, that’s just an Xcode bug and it’s trivial to work around as you mentioned on that other thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

This is because new Xcode 15.1/15/2 does not contain CategoryNSObject and CategoryNSObject files on path Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate ,you can copy this file from previous version,or click this link(https://pan.baidu.com/s/1Xs_8PnKyA0rY_8fpBKxhHQ?pwd=g2sm#list/path=%2F) to download and copy it to path.

  1. open path: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate
  2. copy CategoryNSObject file and ExtensionNSObject file to Objective-C File.xctemplate
  3. restart xcode

这是由于新版Xcode安装包目录中缺少 CategoryNSObject 和 CategoryNSObject文件导致的,对应目录:Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate,可以从旧版Xcode目录中找到对应文件复制到这个目录下,如果无 旧版 Xcode,可以用这个链接下载(https://pan.baidu.com/s/1Xs_8PnKyA0rY_8fpBKxhHQ?pwd=g2sm#list/path=%2F)%EF%BC%9B

  1. 打开目录:/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Objective-C File.xctemplate
  2. 复制文件 CategoryNSObject 及 ExtensionNSObject
  3. 重启Xcode
Xcode 15.1 and 15.2 Objective-C Category/Extension Creation Issue
 
 
Q