objfw
Opinionated guide for writing, debugging, reviewing, and testing Objective-C when the target uses ObjFW. Use for ObjFW classes and APIs, ObjFW-style types, ARC, exceptions, strings, collections, streams, sockets, run loops, portability, objfw-compile, or ObjFWTest in an ObjFW project.
- License 许可
- MIT
- 最近更新
- 2026-08-05
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- objfw
- description
- Opinionated guide for writing, debugging, reviewing, and testing Objective-C when the target uses ObjFW. Use for ObjFW classes and APIs, ObjFW-style types, ARC, exceptions, strings, collections, streams, sockets, run loops, portability, objfw-compile, or ObjFWTest in an ObjFW project.
- compatibility
- Verify selectors and availability against the ObjFW version used by the target project.
02 资源文件 4
- 参考文档references/API_DESIGN.md6.2 KB
- 参考文档references/BUILD_TEST_PORTABILITY.md6.1 KB
- 参考文档references/CORE_TYPES.md5.3 KB
- 参考文档references/IO_ASYNC.md6.0 KB
03 SKILL.md 正文
ObjFW
Write Objective-C that is native to ObjFW rather than Foundation with an OF prefix. Use ARC by default for application and library code. Established project conventions take precedence, especially when contributing to ObjFW itself, whose source also supports non-ARC and older toolchains.
Source Rule
Before guessing an API or ownership rule, check in this order:
- The nearest
AGENTS.md/AGENT.md, build files, and project conventions. - The ObjFW version pinned or installed by the target project: its headers, source, and tests.
- Current upstream ObjFW headers and tests.
- The released API documentation, noting that it may differ from
main.
ObjFW is intentionally incompatible with Foundation. Never derive an API by replacing NS with OF.
Useful upstream sources:
Branch Chooser
Read only the references relevant to the task:
- New classes, initializers, factories, properties, ownership, copying, equality, or exceptions:
references/API_DESIGN.md. - Strings, data, arrays, dictionaries, sets, ranges, encodings, or serialization:
references/CORE_TYPES.md. - Files, streams, sockets, HTTP, asynchronous I/O, delegates, handlers, or run loops:
references/IO_ASYNC.md. - Application entry points, compiler flags, build integration, tests, feature macros, or cross-platform work:
references/BUILD_TEST_PORTABILITY.md.
Read multiple references when a task crosses those boundaries.
Core Defaults
- Use ARC unless the existing target explicitly uses manual reference counting or the task modifies ObjFW's own non-ARC source.
- With ARC, compile with both
-fobjc-arcand-fobjc-arc-exceptions.objfw-config --arcemits both flags. - Under ARC, do not emit
retain,release,autorelease,objc_retain,objc_release,objc_autorelease, or[super dealloc]. - Prefer a class factory at call sites when one exists. For a new public constructible type, normally pair one designated
initWith...initializer with a matching factory. - In ARC code, implement a factory directly as
return [[self alloc] initWithThing: thing];. Do not copy ObjFW's internalobjc_autoreleaseReturnValue(...)MRC implementation into ARC application code. - ObjFW
allocandinitdo not returnnil; initialization failure throws. Do not add Foundation-style nil checks around initialization. - Use
instancetypefor factories and initializers. - Use ObjFW's exact types and selectors: commonly
bool,size_t, fixed-width integers,OFRange,OFTimeInterval,OFString,OFArray, and otherOF*APIs. Do not substituteBOOL,NSUInteger,NSRange,NSError, or Foundation collections. - Use exceptions for exceptional failures and
nilor documented sentinels for ordinary absence. Catch only when the current boundary can recover, translate, add useful context, or perform required cleanup. - Prefer immutable values and collections by default. Introduce mutable variants only where mutation is part of the operation.
- Treat availability, ownership, nullability, pointer lifetime, and callback continuation semantics in the target version's headers as part of correctness.
Workflow
- Establish the target ObjFW version, memory-management mode, supported platforms, and local formatting/build conventions.
- Read the matching reference files and the exact declarations for every unfamiliar selector.
- Inspect neighboring implementation and test code for the same kind of operation.
- Implement with ObjFW-native types, factories, exceptions, and platform abstractions.
- Add or update ObjFWTest coverage and run the narrowest relevant build/test command, then the project's broader checks.
- Report validation performed and any unresolved version, runtime, or platform uncertainty.
Boundary Rules
- Keep Foundation, Core Foundation, POSIX, Win32, and other platform APIs behind explicit adapter boundaries. Do not leak their types into portable ObjFW-facing APIs without a deliberate interoperability requirement.
- At C boundaries, preserve byte counts, encoding, byte order, ownership, null termination, and pointer lifetime explicitly.
- Close files, streams, sockets, subprocess directions, and other finite resources deterministically when their API requires it; ARC manages object lifetime, not protocol/resource completion.
- Guard optional facilities with ObjFW's configured feature macros and provide a fallback or an explicit unsupported path.
- Respect the target's compiler/runtime range. Do not introduce a language or runtime feature merely because it works with the local Apple Clang toolchain.
Do Nots
- Do not import Foundation into portable ObjFW code or mechanically translate Foundation examples.
- Do not add
NSError **APIs to model ordinary ObjFW failures. - Do not assume every target has files, sockets, threads, blocks, shared libraries, or full method forwarding.
- Do not guess selector spelling, exception classes, delegate methods, or async handler return meanings.
- Do not use
OFString.lengthas a UTF-8 byte count. - Do not assume a stream read fills the requested buffer unless using an exact-length API whose contract says so.
- Do not keep borrowed C-string, character-buffer, or collection pointers beyond their documented lifetime.
- Do not swallow
OFExceptionbroadly and continue with invalid state.
04 同仓库更多 Skills
yeetslop
Remove AI-generated code slop introduced in the current branch. User-invoked only.
review-pass
Review a diff, branch, or PR for correctness, security, and quality issues. Use when asked to review code changes, review a PR, or do a code review — especially useful in agents without a built-in review command.
release-notes
Draft release notes or changelog entries from a commit or tag range. Use when asked to write release notes, draft a changelog, or summarize what changed between two versions or tags.
pr-writer
Draft a pull request title and description from the current branch's diff and commit history. Use when asked to write a PR description, draft a PR, or prepare a branch for review.
noteday
Log today's work — a summary of the day plus any tickets worked on — as an entry in the personal Notion "Daily Log" database. Use when the user runs /noteday or asks to note down their day.
learn
Extract non-obvious learnings from the current session into AGENTS.md files, placed as close to the relevant code as possible. Use when asked to capture learnings, save session discoveries, or update AGENTS.md with what was learned.