Saturday, December 26, 2009

iPhone SDK 3.0 API Explorer

The previous version is for OS 2.2 and is here

It is now updated to support OS 3.0 and with on-line reference to Erica Sadun 3.1.2 class documentation

Installation Instructions:

Cydia Source :
Section: Utilities
Name: API Explorer 3.0

Updated source code for version 3.0 is here
svn checkout

or download it (revision 25) here

The project can be built using Xcode or iphone gcc. The Makefile has been updated, so that it can be compiled under iphone gcc for 3.0 framework. Refer here for the 3.0 headers for iphone gcc.

The Cydia version did not have all the frameworks (e.g. GameKit and others). To explore more frameworks, you need to download the source code and build your own version.

For Xcode, just add the required frameworks before build. For iphone gcc, just add LDFLAGS (like the one below) in the Makefile and then make install.

LDFLAGS += -framework GameKit

If you want to have on-line reference to 3.0.0 framework instead of 3.1.2 from Erica's website, you should build your code.plist. Here is the script to dump the dictionary key-string pairs for 3.0.0

curl -s -L | grep "" | sed -e "s/^.*href=\"\(.*html\)\".\(.*\)\/a.*$/\<key\>\2\/key\>\<string\>\1\<\/string\>/g;"

This is how to dump the method name to class key-string values
method2class.plist Select all

for page in "" _0x61 _0x62 _0x63 _0x64 _0x65 _0x66 _0x67 _0x68 _0x69 _0x6a _0x6b _0x6c _0x6d _0x6e _0x6f _0x70 _0x71 _0x72 _0x73 _0x74 _0x75 _0x76 _0x77 _0x78 _0x79 _0x7a ; do
curl -s -L${page}.html | awk '/^.li./{s=$0;next}{print s " "$0}' | sed -e "s/^.li.\(.*\)\s[:,].*a\sclass..el..href..*html.*\">\(.*\)<\/a>$/\<key\>\1\<\/key\>\<array\>\<string\>\2\<\/string\>\<\/array\>/g;" | grep "<key>" | sed -e "s/(.*)//g" | awk -F "</key>" '!arr[$1] {arr[$1] = $0; next} {arr[$1] = arr[$1] " " $2} END {for(i in arr) {print arr[i]}}' | sed -e "s/<\/array> <array>//g"

Latest screen dump for version 3.1 (not yet released)

Wednesday, December 9, 2009

[How-to] compile SmartScreen widget in iphone gcc

Here is a sample clock widget source from SmartScreen sdk , I added a Makefile so that it can be compiled under iphone gcc

Make sure you have installed iphone gcc and 3.0 headers (refer here for the 3.0 headers) and also SmartScreen (Lite or full version) before your testing.

If you have installed toolchain and 3.0 headers under cygwin or linux, just modify the sdk location in the Makefile and it should compile as well.

SmartScreen widget will be installed under the folder /var/mobile/Library/SmartScreen

To compile and install this sample clock widget under iphone gcc

make install

To uninstall the clock widget

make uninstall

This is the updated Makefile for SmartScreen ClockWidget
Makefile Select all

# Makefile for gcc compiler for iPhone (SmartScreen Widget)



LDFLAGS = -arch arm -lobjc
LDFLAGS += -framework CoreFoundation
LDFLAGS += -framework Foundation
LDFLAGS += -framework UIKit
LDFLAGS += -framework CoreGraphics
//LDFLAGS += -framework AddressBook
//LDFLAGS += -framework AddressBookUI
//LDFLAGS += -framework AudioToolbox
//LDFLAGS += -framework AudioUnit
//LDFLAGS += -framework AVFoundation
//LDFLAGS += -framework CoreSurface
//LDFLAGS += -framework CoreAudio
//LDFLAGS += -framework CoreData
//LDFLAGS += -framework CFNetwork
//LDFLAGS += -framework GraphicsServices
//LDFLAGS += -framework OpenAL
//LDFLAGS += -framework OpenGLES
//LDFLAGS += -framework MediaPlayer
//LDFLAGS += -framework QuartzCore
//LDFLAGS += -framework Security
//LDFLAGS += -framework SystemConfiguration
//LDFLAGS += -framework WebCore
//LDFLAGS += -framework WebKit
//LDFLAGS += -framework SpringBoardUI
//LDFLAGS += -framework TelephonyUI
//LDFLAGS += -framework JavaScriptCore
//LDFLAGS += -framework PhotoLibrary
LDFLAGS += -L"$(SDK)/usr/lib"
LDFLAGS += -F"$(SDK)/System/Library/Frameworks"
LDFLAGS += -F"$(SDK)/System/Library/PrivateFrameworks"
LDFLAGS += -bind_at_load
LDFLAGS += -multiply_defined suppress
LDFLAGS += -march=armv6
LDFLAGS += -mcpu=arm1176jzf-s
LDFLAGS += -mmacosx-version-min=10.5
LDFLAGS += -dynamiclib

CFLAGS += -I"$(SDK)/usr/include"
CFLAGS += -DDEBUG -std=gnu99 -O0
CFLAGS += -Diphoneos_version_min=$(MINIMUMVERSION)
CFLAGS += -Wno-attributes -Wno-trigraphs -Wreturn-type -Wunused-variable

OBJS+=$(patsubst %.m,%.o,$(wildcard $(SRCDIR)/*.m))
OBJS+=$(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))
OBJS+=$(patsubst,%.o,$(wildcard $(SRCDIR)/*.mm))
OBJS+=$(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/*.cpp))
OBJS+=$(patsubst %.m,%.o,$(wildcard ./*.m))
PCH=$(wildcard *.pch)
RESOURCES=$(wildcard $(RESDIR)/*)

CFLAGS += $(addprefix -I,$(SRCDIR))



$(PROJECTNAME): $(OBJS) Makefile
    $(LD) $(LDFLAGS) $(filter %.o,$^) -o $@

%.o: %.m %.h $(PCH) $(filter-out $(patsubst %.o,%.h,$(OBJS)), $(wildcard $(SRCDIR)/*.h))
    $(CC) --include $(PCH) -c $(CFLAGS) $< -o $@

%.o: %.c %.h $(PCH)
    $(CC) --include $(PCH) -c $(CFLAGS) $< -o $@

%.o: %.h $(PCH) $(filter-out $(patsubst %.o,%.h,$(OBJS)), $(wildcard $(SRCDIR)/*.h))
    $(CPP) --include $(PCH) -c $(CPPFLAGS) $< -o $@

%.o: %.cpp %.h $(PCH)
    $(CPP) --include $(PCH) -c $(CPPFLAGS) $< -o $@

dist: $(PROJECTNAME) Info.plist Makefile $(RESOURCES)
    @rm -rf $(BUILDDIR)
    @mkdir -p $(BUILDDIR)/$(WIDGETFOLDER)
ifneq ($(RESOURCES),)
    @-$(foreach DIR, .svn .DS_Store .git* , find $(BUILDDIR)/$(APPFOLDER) -name '$(DIR)' -prune -exec rm -rfv {} \;;)
    @cp Info.plist $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist
    @./plutil -key CFBundleExecutable -value $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist
    @./plutil -key CFBundleName -value $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist
    @./plutil -key NSPrincipalClass -value $(PRINCIPALCLASS) $(BUILDDIR)/$(WIDGETFOLDER)/Info.plist
    ldid -S $(PROJECTNAME)

install: dist
    @chown -R mobile:mobile $(INSTALLFOLDER)/$(WIDGETFOLDER)
    @echo "Widget $(WIDGETFOLDER) installed, please respring device"

    @echo "Widget $(WIDGETFOLDER) uninstalled, please respring device"

    cp ./respring /usr/bin/respring

    @rm -rf $(BUILDDIR)

    @rm -f $(OBJS)
    @rm -rf $(BUILDDIR)
    @rm -f $(PROJECTNAME)

.PHONY: all dist install uninstall install_respring distclean clean