zoukankan      html  css  js  c++  java
  • cocos2dx3.8 ios打包脚本编写

    cocos集成了打包命令 cocos compile -p ios

    在这里并没有采用这个方案,而是编写自己的脚本, 理由如下

    1. 脚本掌握在自己手中可以第一时间解决和发现bug
    2. 游戏项目总会出现各种各样定制的需求,官方不可能给出全部的解决方案

    查了一下资料xcode 支持命令行

    xcodebuild:   编译xcode工程生成app文件

    xcrun:       将app文件转换为ipa文件

    如果不清楚, 直接命令行 xcodebuild -help即可查看所有命令

    为了便于管理和扩展 我们在项目根目录下新建了两个文件夹

    1. build/ios:脚本目录,
    2. publish/ios:ipa输出目录 

    直接上脚本, 将XXXX换成自己的证书文件,工程路径即可

    #!/bin/bash
    
    projectPath="$1"
    schemeName="$2"
    
    dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    cd $dir
    cert="XXXXXX"
    profile="XXXXXX"
    sdk=iphoneos8.4
    
    
    if [ ! -d "${projectPath}/bin" ]; then
        mkdir -p "${projectPath}/bin"
    fi
    
    #xcodebuild -project "${projectPath}/lddoudizhu.xcodeproj" -scheme ${schemeName} -sdk ${sdk} -configuration Release clean
    
    xcodebuild -project "${projectPath}/lddoudizhu.xcodeproj" -scheme ${schemeName} -sdk ${sdk} -configuration Release DEPLOYMENT_POSTPROCESSING=YES CONFIGURATION_BUILD_DIR="${projectPath}/bin" CODE_SIGN_IDENTITY="${cert}" PROVISIONING_PROFILE="${profile}" build
    
    xcrun -sdk iphoneos PackageApplication -v "${projectPath}/bin/${schemeName}.app" -o "${projectPath}/bin/${schemeName}.ipa"
    

      我们再编写一个python脚本调用shell并传递schemeName 

    # coding=utf-8
    # !/usr/bin/python
    
    import os,shutil
    import datetime
    
    class BuildIos:
        def __init__(self):
            self.dir = os.path.split(os.path.realpath(__file__))[0]
            self.projectPath = self.dir + "/../../frameworks/runtime-src/proj.ios_mac"
            self.outputPath = self.dir + "/../../publish/ios"
            self.appName = "XXXXX"
            self.schemeName = "XXXXXXX"
        def build(self):
            os.system("sh build_ios.sh " + self.projectPath + " " + self.schemeName)
            
            if not os.path.isdir(self.outputPath):
                os.mkdir(self.outputPath)
            #获得当前时间
            now = datetime.datetime.now()
            outputFile = self.outputPath + "/" + self.appName + "_" + now.strftime("%Y%m%d%H%M") + ".ipa"
            shutil.copy(self.projectPath + "/bin/" + self.schemeName + ".ipa", outputFile)
            print("[Success] " + outputFile)
        def run(self):
            os.chdir(self.dir)
            self.build()
    buildIos = BuildIos()
    buildIos.run()

    以后我们可以继续完善python,比如在不同的平台下 预先进行文件夹的整理,在执行打包脚本之前先将lua编译成字节码并加密,尽情的发挥想象吧!

  • 相关阅读:
    【bzoj4591】[Shoi2015]超能粒子炮·改 Lucas定理
    【bzoj1604】[Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 旋转坐标系+并查集+Treap/STL-set
    十分钟看懂图像语义分割技术
    命令行执行python模块时提示ImportError: No module named xxx
    python json与字典对象互相转换
    C#中json字符串的序列化和反序列化
    Python当前线程休眠1秒钟
    python之bytes和string
    Win32 基本文件读写操作
    C# 字符串与字节数组相互转换
  • 原文地址:https://www.cnblogs.com/ColaZhang/p/4827685.html
Copyright © 2011-2022 走看看