I am in need of help in compiling a toggle for SBSettings. I have the source code for the Locations Toggle and I'm trying to compile that as an example but I keep getting errors during compiling. I am compiling via command line on my iPhone using MobileTerminal as I do not have access to Xcode for development. I'm stuck on compiling and programming on my phone for the time being. Any help on how to compile a .dylib for SBSettings will be much appreciated. I have GCC and tool chain installed on my iPhone. I have listed the three differed methods I used for compiling.
My makefile:
My only source file:
Thank you in advance.
root# make
arm-apple-darwin-gcc -lobjc -dynamiclib -bind_at_load -F"/System/Library/PrivateFrameworks" -framework CoreTelephony -framework CoreFoundation -framework Foundation -framework UIKit -framework CoreGraphics -framework SystemConfiguration -o Toggle.dylib main.o
/usr/local/bin/ld: unknown flag: -aspen_version_min
collect2: ld returned 1 exit status
make: *** [Toggle.dylib] Error 1
root# ldid -S Toggle.dylib
./minimal/mapping.h(54): _assert(2:false)
root# ldid -s Toggle.dylib
./minimal/mapping.h(54): _assert(2:false)
My makefile:
CC=arm-apple-darwin-gcc
LD=$(CC)
LDFLAGS=-lobjc -dynamiclib -bind_at_load -F"/System/Library/PrivateFrameworks" -framework CoreTelephony -framework CoreFoundation -framework Foundation -framework UIKit -framework CoreGraphics -framework SystemConfiguration
CFLAGS=-fconstant-cfstrings -std=gnu99 -Wall -O2 -I/var/include -I..
VERSION=1.0
all: * *Toggle.dylib
Toggle.dylib: main.o
** * * *$(LD) $(LDFLAGS) -o $@ $^
** * * */usr/bin/ldid -S Toggle.dylib
%.o: %.m
** * * *$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
** * * * **
%.o: %.c
** * * *$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
clean:
** * * *rm -f *.o edge
My only source file:
#import <UIKit/UIKit.h>
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
// Determines if the device is capable of running on this platform. If your toggle is device specific like only for
// 3g you would check that here.
BOOL isCapable()
{
** * * *return YES;
}
// This runs when iPhone springboard resets. This is on boot or respring.
BOOL isEnabled()
{
** * * *NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile"/var/mobile/Library/Preferences/com.apple.locationd.plist"];
** * * *BOOL Location = [[plistDict objectForKey"LocationEnabled"] boolValue];
** * * *return Location;
}
// This function is optional and should only be used if it is likely for the toggle to become out of sync
// with the state while the iPhone is running. It must be very fast or you will slow down the animated
// showing of the sbsettings window. Imagine 12 slow toggles trying to refresh tate on show.
BOOL getStateFast()
{
** * * *return isEnabled();
}
// Pass in state to set. YES for enable, NO to disable.
void setState(BOOL Enable)
{
** * * *NSMutableDictionary *plistDict = [NSMutableDictionary dictionaryWithContentsOfFile"/var/mobile/Library/Preferences/com.apple.locationd.plist"];
** * * *if (Enable == YES)*
** * * *{
** * * * * * * *[plistDict setValue:[NSNumber numberWithBool:YES] forKey"LocationEnabled"];
** * * * * * * *[plistDict writeToFile"/var/mobile/Library/Preferences/com.apple.locationd.plist" atomically: YES];
** * * *}
** * * *else if (Enable == NO)*
** * * *{
** * * * * * * *[plistDict setValue:[NSNumber numberWithBool:NO] forKey"LocationEnabled"];
** * * * * * * *[plistDict writeToFile"/var/mobile/Library/Preferences/com.apple.locationd.plist" atomically: YES];
** * * *}
** * * *//notify_post("com.apple.locationd/Prefs");
}
// Amount of time spinner should spin in seconds after the toggle is selected.
float getDelayTime()
{
** * * *return 0.6f;
}
// Runs when the dylib is loaded. Only useful for debug. Function can be omitted.
__attribute__((constructor))*
static void toggle_initializer()*
{*
** * * *NSLog(@"Initializing LServices Toggle\n");*
}
Thank you in advance.