Best Practices: Difference between revisions

From iPhone Development Wiki
(Reword.)
Line 1: Line 1:
Use the following guidelines to avoid your package or app being fragile or breaking at the slightest gust of wind, and to increase the chances of it being accepted by a community host.
Use the following guidelines to avoid your package or app being fragile and to increase the chances of it being accepted by a community host.


== Applications and Tweaks ==
== Applications and Tweaks ==
* Avoid referring to /var/mobile directly - use NSHomeDirectory() if your code is running as mobile! ("... say tomorrow apple ships iOS 6 and mobile is now named "phoneuser" or something equally insane...")
* Avoid referring to /var/mobile directly - use NSHomeDirectory() if your code is running as mobile!
* If your code is running as root, use extra caution when writing files that mobile can access - you might break the file's access permissions.
* See [[MobileSubstrate Pitfalls]] for additional guidelines regarding tweaks.
* See [[MobileSubstrate Pitfalls]] for additional guidelines regarding tweaks.


== Packages ==
== Packages ==
* Do not create mobile-owned files and/or directories in your package. Stay out of mobile's home directory!
* Do not create mobile-owned files and/or directories in your package. Stay out of mobile's home directory!
** All package files are installed as root, and hour app should create any required files or directories under mobile's home directory.
** All package files are installed as root. Your software should create any required files or directories at runtime.
** This is doubly important for preferences. A user's preferences do not belong in a package: if preferences are stored in the package, they will be overwritten when you release an update, and deleted when the user uninstalls your software (even temporarily!)
* Do not use postinst/preinst/extrainst_ for file management purposes!
* Do not use postinst/preinst/extrainst_ for file management purposes!
** Do not store in the package directories that your app could make.
** Do not store in the package files or directories that your software could create.
** Do not enforce permissions that your package could (and arguably should) contain.
** Do not enforce permissions that your package should contain. dpkg uses an expressive packaging format that has support for permissions, ownership, and links. Use that support!

Revision as of 02:38, 16 April 2013

Use the following guidelines to avoid your package or app being fragile and to increase the chances of it being accepted by a community host.

Applications and Tweaks

  • Avoid referring to /var/mobile directly - use NSHomeDirectory() if your code is running as mobile!
* If your code is running as root, use extra caution when writing files that mobile can access - you might break the file's access permissions.

Packages

  • Do not create mobile-owned files and/or directories in your package. Stay out of mobile's home directory!
    • All package files are installed as root. Your software should create any required files or directories at runtime.
    • This is doubly important for preferences. A user's preferences do not belong in a package: if preferences are stored in the package, they will be overwritten when you release an update, and deleted when the user uninstalls your software (even temporarily!)
  • Do not use postinst/preinst/extrainst_ for file management purposes!
    • Do not store in the package files or directories that your software could create.
    • Do not enforce permissions that your package should contain. dpkg uses an expressive packaging format that has support for permissions, ownership, and links. Use that support!