Difference between revisions of "Best Practices"

From iPhone Development Wiki
Jump to: navigation, search
(Applications and Tweaks)
(Packages: Moving this over to the packaging page.)
 
(12 intermediate revisions by 7 users not shown)
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 <code>/var/mobile</code> directly - use <code>NSHomeDirectory()</code> 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.
 +
** App Store apps will return their sandbox data path from <code>NSHomeDirectory()</code>.
 
* See [[MobileSubstrate Pitfalls]] for additional guidelines regarding tweaks.
 
* See [[MobileSubstrate Pitfalls]] for additional guidelines regarding tweaks.
 
+
* You should consider the UDID deprecated like Apple has for some time, but if you need the device's UDID, use [[libMobileGestalt.dylib]].
== Packages ==
+
* If you need to use singletons, see [[singleton pattern]] for advice.
* Do not create mobile-owned files and/or directories in your package. Stay out of mobile's home directory!
+
* If you need to respring from a tweak and you are targeting iOS 6 - 7, kill backboardd instead of SpringBoard. Killing SpringBoard has been known to cause some issues regarding the backlight. For iOS 8 and newer, if possible, use <code>-[HBRespringController respring]</code> from [https://github.com/hbang/libcephei/blob/master/HBRespringController.x libcephei] for a more appropriate way to respring. Simply killing the processes can destroy battery usage data (the feature since iOS 8) of the user.
** All package files are installed as root, and hour app should create any required files or directories under mobile's home directory.
 
* Do not use postinst/preinst/extrainst_ for file management purposes!
 
** Do not store in the package directories that your app could make.
 
** Do not enforce permissions that your package could (and arguably should) contain.
 

Latest revision as of 11:41, 28 June 2020

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.
    • App Store apps will return their sandbox data path from NSHomeDirectory().
  • See MobileSubstrate Pitfalls for additional guidelines regarding tweaks.
  • You should consider the UDID deprecated like Apple has for some time, but if you need the device's UDID, use libMobileGestalt.dylib.
  • If you need to use singletons, see singleton pattern for advice.
  • If you need to respring from a tweak and you are targeting iOS 6 - 7, kill backboardd instead of SpringBoard. Killing SpringBoard has been known to cause some issues regarding the backlight. For iOS 8 and newer, if possible, use -[HBRespringController respring] from libcephei for a more appropriate way to respring. Simply killing the processes can destroy battery usage data (the feature since iOS 8) of the user.