bmob/agent-skills/bmob-database-ios
Claude Code and agent skill by bmob/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing Bmob NoSQL database CRUD in an iOS native project — both Objective-C and Swift / SwiftUI / UIKit. Triggers: BmobSDK, BmobSDK.xcframework, pod 'BmobSDK', #import <BmobSDK/Bmob.h>, Bmob registerWithAppKey, [Bmob register(withAppKey:)], BmobObject objectWithClassName, BmobQuery queryWithClassName, BmobUser, BmobInstallation, BmobFile, BmobGeoPoint, BmobRelation, saveInBackgroundWithResultBlock, getObjectInBackgroundWithId, findObjectsInBackground, Bridging-Header.h. NOT for cross-platform JavaScript / WeChat Mini Program (use bmob-database-javascript), Android (use bmob-database-android), Flutter / Dart (use bmob-database-flutter), or any other language via REST (use bmob-database-restful). If Bmob MCP is configured, call get_project_tables via bmob-mcp before writing code.
Install
npx vskill@latest install bmob/agent-skills/bmob-database-iosSKILL.md
The same SKILL.md was published earlier as bmob/agent-skills/bmob-database-ios.
Bmob Database — iOS Native SDK
iOS SDK 名为 BmobSDK,是 Objective-C 编写的 framework,Swift 项目通过 Bridging Header 桥接使用。SDK 数据模型以 BmobObject 为核心,不需要为每个表写子类(与 Android 不同)。
核心原则
1. 安装 SDK — 强推 CocoaPods:
装完后只打开 `.xcworkspace`,不要再打开.xcodeproj,否则找不到 Pod 引入的库。
也可手动导入 BmobSDK.xcframework,并链接以下系统库(详见 `references/install.md`)。
2. Swift 必须桥接: 新建任意 .m 文件让 Xcode 弹"Create Bridging Header",然后在生成的 项目名-Bridging-Header.h 加:
3. 初始化(OC) — AppDelegate.m:
3. 初始化(Swift / SwiftUI) — AppApp.swift:
4. 域名重置(上线必做): 工信部要求正式上线必须用备案域名:
OC 端用 [Bmob resetDomain:@"https://sdk.yourapp.com"];。
5. 不要硬编码 Master Key 到 App bundle。客户端只用 Application ID(必要时配 Secret Key + 加密授权)。
安全清单
- [ ] release 关闭调试输出:测试期
[Bmob setDebug:YES],上架前删掉。 - [ ] App Transport Security(ATS):如果备案域名是 HTTP(不推荐),需要在
Info.plist加NSAppTransportSecurity → NSAllowsArbitraryLoads = YES,但 App Store 审核可能拒;尽量用 HTTPS。 - [ ] 写入的表必须配 ACL:否则任意用户可改任意行。
- [ ] Bridging Header 不要 commit 真实 AppKey:用配置文件 / xcconfig / environment 注入。
- [ ] release 前替换备案域名:参见上面"4. 域名重置"。
常见问题
跨平台 Q&A:`shared/faq.md`。
反模式
见 `shared/anti-patterns.md`。本端重点:勿 commit 真实 AppKey;ATS 尽量 HTTPS。
单条 CRUD(Swift 现代写法)
添加
查询单条
更新(按 objectId)
注意 API 名称是outDatatWithClassName(拼写历史遗留,不要改)——用这个方法获取的BmobObject不会先发 GET 查询,直接拿来 update / delete。
删除
查询列表(带条件 + 排序 + 分页)
单条 CRUD(Objective-C)
与 MCP 联动
如已配置 Bmob MCP,先 get_project_tables 拿真实 schema,避免:
- 字段名拼错(
setObject:forKey:不校验 schema) - BmobObject 与 BmobUser 混用
排错速查
跨平台现象先查 `shared/faq.md`。
| 现象 | 排查 | |
|---|---|---|
| 100 报错 | 请求内容(查询条件)有误 | |
| 20003 none objectid | 更新 / 删除 / 查询单条没传 objectId | |
| 20004 none object | 查询结果为空 | |
| 20006 cloud function failed | 云函数执行报错 | |
| 20017 init not finish | 在 register 完成前调用了 SDK;检查 init {} 顺序 | |
| Swift "use of undeclared identifier 'BmobObject'" | Bridging Header 没建或没 #import <BmobSDK/Bmob.h> | |
| Xcode 14+ 找不到 Pod 库 | 打开了 .xcodeproj 而不是 .xcworkspace | |
| App Store 审核拒 ATS | 备案域名换 HTTPS,移除 NSAllowsArbitraryLoads | |
| release 包请求被拒 / 403 | 没配 SDK 类型备案域名;或 resetDomain 调用顺序错(必须在 register 前) | |
| 9015 | 兜底错误码,必读响应描述 |
进阶能力(按需读 references/)
| 主题 | 路径 | |
|---|---|---|
| 端到端场景 | `shared/recipes/` | |
| BmobDocs 同步代码片段 | `references/snippets/` | |
| 完整安装 + Bridging + framework 链接 + ATS 配置 | `references/install.md` | |
| 高级查询(or / 子查询 / 地理位置 / include) | `references/query.md` | |
| Pointer / Relation | `references/pointer-and-relation.md` | |
| 用户系统 / SMS / 第三方登录 | (P1: bmob-auth-ios) | |
| 文件上传 / BmobFile | (P1: bmob-storage-ios) |
参考
- OC 完整 API:develop_doc.md
- Swift 完整 API:swift_develop_doc.md
- Swift Quickstart:swift_quick_start.md
- SDK 源码:<https://github.com/bmob/Bmob-iOS-SDK>
- Swift Demo:<https://github.com/bmob/bmob-ios-demo/blob/master/SwiftDemo.zip>
- 错误码:`bmob-error-codes`
- MCP 联动:`bmob-mcp`
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/bmob-database-ios/SKILL.md
Popularity
- Repository stars
- 4
- Repository forks
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bmob/agent-skills/bmob-database-ios)