iOS 命令行打包

作者: anyurchao | 来源:发表于2017-09-14 08:56 被阅读76次

    命令行打包———— 打包步骤

    1.准备

    • 工程环境路径
      workspace_path= /Users/djnet/Desktop/text
    • 项目名称
      project_name=test
    • build的路径
      build_path=$workspace_path/$project_name
    • app生成后的路径
      app_name_path=$build_path/build/Release-iphoneos/${project_name}.app
    • ipa生成后的路径
      ipa_name_path=$build_path/build/Release-iphoneos/${project_name}.ipa

    2.进入项目工程文件

    cd workspace_path

    3.清除历史 builid

    xcodebuild clean

    4.执行编译生成.app命令

    (1).如果是没有用到 Cocoapods的工程这样在命令行操作(没有.xcworkspace的工程)
    xcodebuild
    (2).用到 Cocoapods的工程这样在命令行操作(有.xcworkspace的工程)
    xcodebuild -workspace /Users/djnet/Desktop/text/text.xcworkspace -scheme text
    echo "在项目工程文件内生成一个build子目录,里面有${project_name}.App程序"

    4.导出ipa包

    xcrun -sdk iphoneos PackageApplication -v $app_name_path -o $ipa_name_path

    制作ipa包完成.......................

    遇到问题:
    1.xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
    解决方案:
    Xcode升级到8.3后 用命令进行打包 提示下面这个错误
    xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
    后面根据对比发现新版的Xcode少了这个PackageApplication先去找个旧版的Xcode里面copy一份过来放到下面这个目录:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
    然后执行命令
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
    chmod +x /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication
    最后附上PackageApplication下载地址:链接: https://pan.baidu.com/s/1jIPw0Iy 密码: 4htw

    2.error: Specified application doesn't exist or isn't a bundle directory : 'Build/Release-iphoneos/text.app'
    解决方案:
    打开你的 Xcode 快捷键 Command + , 选择最后一个 Location 点击 Advanced选择 Custom 选项 Relative to Workspace

    Locations.png

    相关文章

      网友评论

        本文标题:iOS 命令行打包

        本文链接:https://www.haomeiwen.com/subject/ejyksxtx.html