Saturday, December 26, 2009

iPhone SDK 3.0 API Explorer

The previous version is for OS 2.2 and is here
http://iphonesdkdev.blogspot.com/2008/12/iphone-sdk-api-explorer.html

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 : http://cydia.iphone.org.hk/apt/
Section: Utilities
Name: API Explorer 3.0

Updated source code for version 3.0 is here
svn checkout http://apiexplorer.googlecode.com/svn/trunk/apiexplorer3

or download it (revision 25) here
http://apiexplorer.googlecode.com/files/apiexplorer3.zip

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

#!/bin/sh
curl -s -L http://ericasadun.com/iPhoneDocs300/annotated.html | grep "tr..td" | 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

#!/bin/sh
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 http://ericasadun.com/iPhoneDocs312/functions_func${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"
done



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 http://media-phone.ch/en/software/smartscreen/sdk/ , I added a Makefile so that it can be compiled under iphone gcc

http://apiexplorer.googlecode.com/files/ClockWidget.zip

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
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)

PROJECTNAME:=Clock
PRINCIPALCLASS:=$(PROJECTNAME)Widget
WIDGETFOLDER:=$(PROJECTNAME).wdgt
INSTALLFOLDER:=/var/mobile/Library/SmartScreen
MINIMUMVERSION:=3.0

CC:=arm-apple-darwin9-gcc
CPP:=arm-apple-darwin9-g++
LD:=$(CC)
SDK:=/var/toolchain/sys30

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

BUILDDIR=./build/$(MINIMUMVERSION)
SRCDIR=./
RESDIR=./Resources
OBJS+=$(patsubst %.m,%.o,$(wildcard $(SRCDIR)/*.m))
OBJS+=$(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))
OBJS+=$(patsubst %.mm,%.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))

CPPFLAGS=$CFLAGS

all: $(PROJECTNAME)

$(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: %.mm %.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),)
    @-cp -r $(RESOURCES) $(BUILDDIR)/$(WIDGETFOLDER)
    @-$(foreach DIR, .svn .DS_Store .git* , find $(BUILDDIR)/$(APPFOLDER) -name '$(DIR)' -prune -exec rm -rfv {} \;;)
endif
    @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)
    @mv $(PROJECTNAME) $(BUILDDIR)/$(WIDGETFOLDER)

install: dist
    @rm -fr $(INSTALLFOLDER)/$(WIDGETFOLDER)
    cp -r $(BUILDDIR)/$(WIDGETFOLDER) $(INSTALLFOLDER)/
    @chown -R mobile:mobile $(INSTALLFOLDER)/$(WIDGETFOLDER)
    @echo "Widget $(WIDGETFOLDER) installed, please respring device"
    @./respring

uninstall:
    @rm -fr $(INSTALLFOLDER)/$(WIDGETFOLDER)
    @./respring
    @echo "Widget $(WIDGETFOLDER) uninstalled, please respring device"

install_respring:
    cp ./respring /usr/bin/respring

distclean:
    @rm -rf $(BUILDDIR)

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

.PHONY: all dist install uninstall install_respring distclean clean