Monday, June 22, 2009

openURL for 3.0 (and 2.x too, probably)

openURL is part of Erica Utilities. On 3.0, it is not usable anymore because Apple now always throw a "There can only be one UIApplication instance." error even if [UIApplication sharedApplication] still returns nil.

But openURL doesn't require UIApplication. The core method, -[UIApplication openURL:] is actually a wrapper of the undocumented function, GSEventSendApplicationOpenURL.

I've rewritten openURL using GSEventSendApplicationOpenURL, and can be downloaded from http://code.google.com/p/networkpx/downloads/detail?name=openURL.zip. Note that GSEventSendApplicationOpenURL relies on the Graphics Services private framework, and this framework isn't very stable, so there is a chance it won't work on 4.0.

You'll notice that there's now a new argument, "port-name". That's actually not quite useful, but I found that it's used in UIKit, so just added it in. (One more reason is that, the function that obtains the default port is renamed in 3.0.) And that piece of UIKit code doesn't work :(.

4 comments:

  1. You keep referencing 4.0, is this just your way of saying "the next firmware release"?

    ReplyDelete
  2. @fusen: Yes. (Unless they somehow skip the number 4 :p)

    ReplyDelete
  3. coule you post the Makefile?

    what I try does not work:
    APP = openURL
    LDFLAGS= -L"/usr/lib" \
    -lobjc \
    -L"." \
    -F"/System/Library/Frameworks" \
    -F"/System/Library/PrivateFrameworks" \
    -bind_at_load \
    -multiply_defined suppress \
    -framework CoreFoundation \
    -framework GraphicsServices
    LDFLAGS += -lstdc++.6

    CFLAGS += -I"/var/include"
    CFLAGS += -fnested-functions
    CFLAGS += -obj-c++ -DDEBUG -O3 -Wall
    CFLAGS += -Wno-deprecated-declarations

    APP_OBJS = main.o


    all: $(APP)

    $(APP): $(OBJS) $(APP_OBJS)
    $(LD) $(LDFLAGS) -o $@ $^
    ldid -S $(APP)

    %.o: %.mm
    $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

    %.o: %.m
    $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

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

    %.o: %.cpp
    $(CC) -c $(CFLAGS) $< -o $@

    ReplyDelete
  4. @Anonymous: I didn't use any Makefile for this, but you may find this useful:

    alias gcc-iphone='/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -std=c99 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -I/Developer/Platforms/iPhoneOS.platform/Developer/usr/include/gcc/darwin/default -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include -L/usr/local/lib -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/PrivateFrameworks/ -Wall -mcpu=arm1176jzf-s -O2'

    ReplyDelete