iOS Compiling a .dylib on iOS

allejo

macrumors newbie
Original poster
Jun 23, 2010
20
0
Los Angeles, California
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.

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:mad:"/var/mobile/Library/Preferences/com.apple.locationd.plist"];
** * * *BOOL Location = [[plistDict objectForKey:mad:"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:mad:"/var/mobile/Library/Preferences/com.apple.locationd.plist"];
** * * *if (Enable == YES)*
** * * *{
** * * * * * * *[plistDict setValue:[NSNumber numberWithBool:YES] forKey:mad:"LocationEnabled"];
** * * * * * * *[plistDict writeToFile:mad:"/var/mobile/Library/Preferences/com.apple.locationd.plist" atomically: YES];
** * * *}
** * * *else if (Enable == NO)*
** * * *{
** * * * * * * *[plistDict setValue:[NSNumber numberWithBool:NO] forKey:mad:"LocationEnabled"];
** * * * * * * *[plistDict writeToFile:mad:"/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.
 

allejo

macrumors newbie
Original poster
Jun 23, 2010
20
0
Los Angeles, California
Dylibs can be compiled on iOS for Cydia apps. All SBSettings Toggles are dylibs. So I know it's possible. I'm assuming something is outdated because it's referring to aspen and aspen hasn't been used since '08. Anyone have any idea on what I need to change or update?
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
I think there is your problem.
This is Cydia, most of us (well at least me) are real iOS developers, not Cydia. Because of those programs, programs of us can get hacked. So I'm not a big supporter of those. Don't think these are the right forums for such a question.