I've updated Xcode and since updating I've been getting NS_ASSUME_NONNULL_BEGIN
and NS_ASSUME_NONNULL_END
macros around every new header file for every new class that I create.
I know what it does, but I'm not interested in nullability annotations it and it causes unnecessary warnings when I try to set some properties to nil
in my app (which are perfectly okay to set to nil
).
How do I prevent Xcode from creating these every time I create a new file? (other than the obvious: deleting them individually)
Based on this and this arcticles I was able to create custom template to get rid of
NS_ASSUME_NONNULL*
macros.Excerpt from the first arcticle:
create path as follows:
~/Library/Developer/Xcode/Templates/File Templates/Source/My Awesome Template.xctemplate
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source/Cocoa Touch Class.xctemplate
TemplateIcon.png
,[email protected]
andTemplateInfo.plist
to ourMy Awesome Template.xctemplate
folder. You can omit copying icons if you do not need them in browser or use your own.NSObjectObjective-C and NSObjectSwift
folders to be able to create both Obj C and Swift files.___FILEBASENAME___.h
,___FILEBASENAME___.m
,___FILEBASENAME___.swift
, for example put your macros or in our case delete surroundingNS_ASSUME_NONNULL*
macros