Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
Libhide: Difference between revisions - iPhone Development Wiki

Libhide: Difference between revisions

From iPhone Development Wiki
(added supported versions and reminder that the github page is old)
(copyediting)
Line 5: Line 5:
}}
}}


== What is libhide? ==
'''libhide''' is a library that allows you to hide / unhide icons on SpringBoard.
For example, if you are loading a [[PreferenceBundles|Preference Bundle]] into your application, you can hide the SpringBoard icon, or you can let the user decide whether to hide it because you still have the Application Bundle in your Preferences app.


'''libhide''' is a library which allows you to hide / unhide icons on SpringBoard.
libhide works on iOS 6 and 7, and possibly earlier versions as well.
If for example you are loading a Preference Bundle into your Application, you can hide the SpringBoard Icon, or let the user decide wether to hide it or not because you still have the Application Bundle in your Preferences app.
 
'''Supported Versions'''
 
* Libhide has been tested on iPhone 5s (iOS 7) so it definitely works with it.
* It worked on iOS 6 as well before it got updated for iOS 7


== Dynamic Loader ==
== Dynamic Loader ==


In order to load the library and to execute its functions you can use the implementations of the dynamic linking loader: '''dlopen()''', '''dlsym()''', '''dlclose()''' and '''dlerror()'''.
In order to load the library and to execute its functions, you can use the implementations of the dynamic linking loader: '''dlopen()''', '''dlsym()''', '''dlclose()''' and '''dlerror()'''.
* dlerror() returns a human readable error message of an error for dlopen and dlsym or NULL if there is no error.
* dlerror() returns a human readable error message of an error for dlopen and dlsym or NULL if there is no error.
* dlopen() loads the dynamic library using the null terminated path given as the parameter. the second parameter expects a flag on how to load the library
* dlopen() loads the dynamic library using the null terminated path given as the parameter. The second parameter expects a flag on how to load the library.
* dlsym() takes a 'handle' returned by dlopen and a symbol name to lookup. It returns either the address of the symbol or NULL if it was not found.
* dlsym() takes a 'handle' returned by dlopen and a symbol name to lookup. It returns either the address of the symbol or NULL if it was not found.


== Some Code ==
== Example code ==


We first declare our static functions which will initialize from the dynamic library
We first declare our static functions which will initialize from the dynamic library:


<source lang=c>
<source lang=c>
Line 44: Line 39:
The flag '''RTLD_LAZY''' performs lazy binding, which means it only resolves symbols as the code that references them is executed.
The flag '''RTLD_LAZY''' performs lazy binding, which means it only resolves symbols as the code that references them is executed.
If the symbol is never referenced, it is never resolved.
If the symbol is never referenced, it is never resolved.
Lazy binding is only performed for functions, variables are bound when the library is loaded.
Lazy binding is only performed for functions; variables are bound when the library is loaded.


<source lang=c>
<source lang=c>
Line 55: Line 50:
</source>
</source>


Now we are able to simply call those three functions as normal functions. Like so:
Now we are able to call those three functions as normal functions. Like so:


<source lang=c>
<source lang=c>
Line 65: Line 60:
</source>
</source>


This is almost all about '''libhide'''. You can easily hide the Icon for your Application.
== External links ==
 
== External Links ==


* '''libhide''' is opensource and you can grab it from [https://github.com/big-boss/Libhide Github (Not up to date)]
* [https://github.com/big-boss/Libhide An older version of libhide is open source on GitHub]
* [http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=libhideDp Libhide Package]
* [http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=libhideDp Libhide package]


{{Navbox Library}}
{{Navbox Library}}
[[Category:Directories in /Library]]
[[Category:Directories in /Library]]

Revision as of 06:23, 15 April 2014

Libhide
Cydia Package
Developer BigBoss
Package ID libhide
Latest Version 2.4.1-1


libhide is a library that allows you to hide / unhide icons on SpringBoard. For example, if you are loading a Preference Bundle into your application, you can hide the SpringBoard icon, or you can let the user decide whether to hide it because you still have the Application Bundle in your Preferences app.

libhide works on iOS 6 and 7, and possibly earlier versions as well.

Dynamic Loader

In order to load the library and to execute its functions, you can use the implementations of the dynamic linking loader: dlopen(), dlsym(), dlclose() and dlerror().

  • dlerror() returns a human readable error message of an error for dlopen and dlsym or NULL if there is no error.
  • dlopen() loads the dynamic library using the null terminated path given as the parameter. The second parameter expects a flag on how to load the library.
  • dlsym() takes a 'handle' returned by dlopen and a symbol name to lookup. It returns either the address of the symbol or NULL if it was not found.

Example code

We first declare our static functions which will initialize from the dynamic library:

#import <dlcfn.h>

static void *libhide;
static BOOL (*IsIconHiddenForDisplayID)(NSString *displayID); //a method to determine if the icon is already hidden or not
static BOOL (*HideIconViaDisplayID)(NSString *displayID); //hides the icon for the display identifier
static BOOL (*UnHideIconViaDisplayID)(NSString *displayID); //unhides the icon
static NSString *appDisplayID = @"com.yourcompany.appdisplayid"; //our bundle identifier

Next we will initialize our functions so we are able to call them.

libhide = dlopen("/usr/lib/hide.dylib", RTLD_LAZY);

The flag RTLD_LAZY performs lazy binding, which means it only resolves symbols as the code that references them is executed. If the symbol is never referenced, it is never resolved. Lazy binding is only performed for functions; variables are bound when the library is loaded.

IsIconHiddenForDisplayID = reinterprete_cast<BOOL (*)(NSString *)>
                                                     (dlsym(libhide,"IsIconHiddenDisplayId"));
HideIconViaDisplayID = reinterprete_cast<BOOL (*)(NSString *)>
                                                     (dlsym(libhide,"HideIconViaDisplayId"));
UnHideIconViaDisplayID = reinterprete_cast<BOOL (*)(NSString *)>
                                                     (dlsym(libhide,"UnHideIconViaDisplayId"));

Now we are able to call those three functions as normal functions. Like so:

if (IsIconHiddenForDisplayID(appDisplayID)) {
       UnHideIconViaDisplayID(appDisplayID);
} else {
      HideIconViaDisplayID(appDisplayID);
}

External links