agentleFS
testdino-hqtestdino-hq/google-styleguides-skills/objective-c/SKILL.md

objective-c

Skill15 starsChanged 9 months agoMITView on GitHub

Google's official Objective-C style guide. Covers naming conventions, formatting, memory management, properties, protocols, categories, and Objective-C best practices.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. G1Joshi/Agent-Skills★ 15same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository17 other files it gives its agents.

The file

Files
SKILL.md

Google Objective-C Style Guide

Official Google Objective-C coding standards for consistent iOS/macOS code.

Golden Rules

  1. Use ARC — Automatic Reference Counting (no manual retain/release)
  2. Descriptive naming — clarity over brevity; method names read like sentences
  3. Prefix class names — avoid namespace collisions (2-3 letter prefix)
  4. Use properties — prefer @property over direct instance variables
  5. Nullability annotations — mark nullable/nonnull on APIs
  6. Use modern Objective-C — literals, subscripting, generics
  7. Follow Apple conventions — consistency with Cocoa frameworks

Quick Reference

Naming Conventions

ElementConventionExample
ClassesPrefixUpperCamelCaseGTMUserService
ProtocolsPrefixUpperCamelCaseGTMUserServiceDelegate
MethodslowerCamelCase- (void)getUserById:(NSInteger)userId
PropertieslowerCamelCaseuserCount, firstName
Local variableslowerCamelCaselocalUser
ConstantskPrefixUpperCamelCasekGTMMaxRetries
EnumsPrefixUpperCamelCaseGTMDirection
Enum valuesPrefixUpperCamelCaseGTMDirectionNorth

Class Interface

// ✓ CORRECT - class interface with nullability and generics
@interface GTMUserService : NSObject

@property(nonatomic, readonly) NSInteger userCount;
@property(nonatomic, copy, nullable) NSString *currentUserName;

- (nullable GTMUser *)userWithId:(NSInteger)userId;
- (void)fetchUsersWithCompletion:(void (^)(NSArray<GTMUser *> *_Nullable users,
                                          NSError *_Nullable error))completion;
@end

Properties

// ✓ CORRECT - property declarations
@property(nonatomic, strong) NSMutableArray<GTMUser *> *users;
@property(nonatomic, copy) NSString *title;
@property(nonatomic, assign) BOOL isLoading;
@property(nonatomic, weak) id<GTMUserDelegate> delegate;
@property(nonatomic, readonly) NSInteger count;

// Attribute order: nonatomic/atomic, memory (strong/weak/copy/assign),
// then access (readonly/readwrite)

Methods

// ✓ CORRECT - descriptive method names (reads like a sentence)
- (nullable GTMUser *)userWithFirstName:(NSString *)firstName
                               lastName:(NSString *)lastName;

// ✓ CORRECT - instance method
- (void)setUser:(GTMUser *)user forKey:(NSString *)key;

// ✓ CORRECT - class method (factory)
+ (instancetype)serviceWithBaseURL:(NSURL *)baseURL;

// ✗ INCORRECT - too abbreviated
- (GTMUser *)usr:(NSString *)fn ln:(NSString *)ln;

Modern Objective-C Literals

// ✓ CORRECT - use modern literals
NSArray *colors = @[@"red", @"green", @"blue"];
NSDictionary *config = @{@"host": @"localhost", @"port": @8080};
NSNumber *count = @42;
NSNumber *enabled = @YES;

// ✓ CORRECT - subscripting
NSString *first = colors[0];
NSString *host = config[@"host"];

// ✗ INCORRECT - old style
NSArray *colors = [NSArray arrayWithObjects:@"red", @"green", nil];

Protocols and Delegates

// ✓ CORRECT - optional and required protocol methods
@protocol GTMUserServiceDelegate <NSObject>

@required
- (void)userService:(GTMUserService *)service
    didLoadUser:(GTMUser *)user;

@optional
- (void)userService:(GTMUserService *)service
    didFailWithError:(NSError *)error;

@end

Memory Management with ARC

// ✓ CORRECT - ARC handles retain/release
@implementation GTMUserService {
  NSMutableArray<GTMUser *> *_users;  // strong by default
}

- (instancetype)init {
  self = [super init];
  if (self) {
    _users = [[NSMutableArray alloc] init];
  }
  return self;
}
@end

// ✓ CORRECT - weak references to avoid cycles
__weak typeof(self) weakSelf = self;
[self fetchData:^{
  __strong typeof(weakSelf) strongSelf = weakSelf;
  if (!strongSelf) return;
  [strongSelf processResults];
}];

Nullability Annotations

// ✓ CORRECT - annotate all APIs
NS_ASSUME_NONNULL_BEGIN

@interface GTMUser : NSObject

@property(nonatomic, copy) NSString *name;
@property(nonatomic, copy, nullable) NSString *email;

- (nullable GTMUser *)userWithId:(NSInteger)userId;

@end

NS_ASSUME_NONNULL_END

Common Mistakes

MistakeCorrect Approach
Short/abbreviated namesUse descriptive, sentence-like names
No class prefixUse 2-3 letter prefix to avoid collisions
Direct ivar accessUse @property and synthesized accessors
Missing nullability annotationsUse NS_ASSUME_NONNULL_BEGIN/END
Manual retain/releaseUse ARC
Old collection syntaxUse modern literals @[], @{}
Strong delegate referencesUse weak for delegates

When to Use This Guide

  • Writing new Objective-C code
  • Maintaining legacy Objective-C iOS/macOS apps
  • Code reviews
  • Onboarding new team members

Install

npx skills add testdino-hq/google-styleguides-skills/objective-c

Full Guide

See objective-c.md for complete details, examples, and edge cases.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.