WEB开发网
开发学院手机开发iPhone 开发 iPhone 开发进阶 使用 Makefile 自动编译 iPhone ... 阅读

iPhone 开发进阶 使用 Makefile 自动编译 iPhone 程序

 2010-02-27 23:28:00 来源:WEB开发网   
核心提示:OBJS += $(patsubst %.m,%.o,$(wildcard ./*.m))OBJS += $(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))OBJS += $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/*.cpp))NIBS

OBJS += $(patsubst %.m,%.o,$(wildcard ./*.m))

OBJS += $(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))

OBJS += $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/*.cpp))

NIBS = $(patsubst %.xib,%.nib,$(wildcard *.xib))

RESOURCES= $(wildcard $(RESDIR)/*)

APPFOLDER= $(TARGET).app

.PHONY: all

all: $(TARGET) bundle

$(TARGET): $(OBJS)

$(LD) $(LDFLAGS) -o $@ $^

%.o: %.m

$(CC) -c $(CFLAGS) $< -o $@

%.o: %.c

$(CC) -c $(CFLAGS) $< -o $@

%.o: %.cpp

$(CXX) -x objective-c++ $(CFLAGS) $< -o $@

%.nib: %.xib

ibtool $< --compile $@

bundle: $(TARGET)

@rm -rf $(BUILDDIR)

@mkdir -p $(BUILDDIR)/$(APPFOLDER)

@cp -r $(RESDIR)/* $(BUILDDIR)/$(APPFOLDER)

@cp Info.plist $(BUILDDIR)/$(APPFOLDER)/Info.plist

@echo "APPL" > $(BUILDDIR)/$(APPFOLDER)/PkgInfo

mv $(NIBS) $(BUILDDIR)/$(APPFOLDER)

# export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate

@ldid -S $(TARGET)

@mv $(TARGET) $(BUILDDIR)/$(APPFOLDER)/$(TARGET)_

install: bundle

@ssh root@$(IP) "cd /Applications/$(APPFOLDER) && rm -R * || echo 'not found' "

@scp -rp $(BUILDDIR)/$(APPFOLDER) root@$(IP):/Applications

@ssh root@$(IP) "cd /Applications/$(APPFOLDER) ; ldid -S $(TARGET)_; killall SpringBoard"

@echo "Application $(APPFOLDER) installed"

uninstall:

ssh root@$(IPHONE_IP) 'rm -fr /Applications/$(APPFOLDER); respring'

@echo "Application $(APPFOLDER) uninstalled, please respring iPhone"

install_respring:

scp respring_arm root@$(IPHONE_IP):/usr/bin/respring

.PHONY: clean

clean:

@rm -f $(OBJS) $(TARGET)

@rm -rf $(BUILDDIR)

然后执行下面的make命令,我们就可以直接在 iPhone 上测试我们的程序了。

make install_respring

make

make install

上一页  1 2 3 4 

Tags:iPhone 开发 进阶

编辑录入:coldstar [复制链接] [打 印]
赞助商链接