Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save typester/15463 to your computer and use it in GitHub Desktop.
Save typester/15463 to your computer and use it in GitHub Desktop.
package Module::Setup::Flavor::iPhoneApp;
use strict;
use warnings;
use base 'Module::Setup::Flavor';
1;
=head1
Module::Setup::Flavor::iPhoneApp - pack from iphone
=head1 SYNOPSIS
Module::Setup::Flavor::iPhoneApp-setup --init --flavor-class=+Module::Setup::Flavor::iPhoneApp new_flavor
=cut
__DATA__
---
file: Info.plist
template: |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>[% module %]</string>
<key>CFBundleIdentifier</key>
<string>org.unknownplace.[% module | lower %]</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
---
file: Makefile
template: |
PROJECTNAME = [% module %]
VERSION = 0.1
CC = arm-apple-darwin9-gcc
CXX = arm-apple-darwin9-g++
LD = $(CC)
#HEAVENLY=${HOME}/app/toolchain/sysroot
CFLAGS = -objc-abi-version=2 -redefined_supress -std=c99
LDFLAGS = -lobjc -bind_at_load -multiply_defined suppress
LDFLAGS += -framework CoreFoundation
LDFLAGS += -framework Foundation
LDFLAGS += -framework UIKit
LDFLAGS += -framework CoreGraphics
LDFLAGS += -L${HEAVENLY}/usr/lib
LDFLAGS += -F${HEAVENLY}/System/Library/Frameworks
LDFLAGS += -F${HEAVENLY}/System/Library/PrivateFrameworks
BUILDDIR = ./build/$(VERSION)
SRCDIR = ./src
RESDIR = ./resources
OBJS = $(patsubst %.m, %.o, $(wildcard $(SRCDIR)/*.m))
OBJS += $(patsubst %.c, %.o, $(wildcard $(SRCDIR)/*.c))
OBJS += $(patsubst %.cpp, %.o, $(wildcard $(SRCDIR)/*.cpp))
RESOURCES = $(wildcard $(RESDIR)/*)
ZIPNAME = $(PROJECTNAME)-$(VERSION).zip
$(PROJECTNAME): $(OBJS)
$(LD) $(LDFLAGS) $(CPPFLAGS) -o $@ $^
%.o: %.m
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
%.o: %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
%.o: %.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
package: $(PROJECTNAME) $(RESOURCES)
rm -rf $(BUILDDIR)
mkdir -p $(BUILDDIR)/$(PROJECTNAME).app
cp $(PROJECTNAME) $(BUILDDIR)/$(PROJECTNAME).app
cp Info.plist $(BUILDDIR)/$(PROJECTNAME).app
cp $(RESDIR)/* $(BUILDDIR)/$(PROJECTNAME).app
dist: package $(ZIPNAME)
find $(BUILDDIR) -type f -name .DS_Store -print0 | xargs -0 rm
zip -r $(ZIPNAME) $(BUILDDIR)
clean:
@rm -f $(PROJECTNAME)
@rm -f $(SRCDIR)/*.o
@rm -rf $(BUILDDIR)
---
file: src/____var-module-var____AppDelegate.h
template: |
#import <UIKit/UIKit.h>
@interface [% module %]AppDelegate : NSObject {
UIWindow *window;
}
@property (nonatomic, retain) UIWindow *window;
@end
---
file: src/____var-module-var____AppDelegate.m
template: |
#import "[% module %]AppDelegate.h"
@implementation [% module %]AppDelegate
@synthesize window;
-(void)applicationDidFinishLaunching: (UIApplication *)application {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window makeKeyAndVisible];
}
-(void)dealloc {
[window release];
[super dealloc];
}
@end
---
file: src/main.m
template: |
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"[% module %]AppDelegate");
[pool release];
return retVal;
}
---
file: resources/.gitignore
template: ''
---
config:
plugins:
- Template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment