Xcode_自动构建ipa包

40 篇文章 8 订阅
16 篇文章 1 订阅

XCode 自动打包命令

这里我使用的是Xcode8.3

参考资料:http://www.jianshu.com/p/3f43370437d2


获取证书

貌似xcode7.0以上都可以免费使用开发者证书

  1. 先使用Xcode打开工程,使用免费证书签名

    这里写图片描述

  2. 然后会自动生成 xxx.mobileprovision,这里面就包含了teamId等信息

    MacBook-Pro:Provisioning Profiles wilker$ pwd
    /Users/wilker/Library/MobileDevice/Provisioning Profiles
    MacBook-Pro:Provisioning Profiles wilker$ ls
    fa4ea842-adb4-4dec-82f3-c178f47769d8.mobileprovision

打包命令

  1. 从xcode工程 xxx.xcodeproj 打出 xxx.xcarchive 文件

    cmd = '''xcodebuild -project %s -scheme "MyXMan-mobile" -configuration %s -sdk iphoneos10.3 -archivePath %s archive DEVELOPMENT_TEAM="%s ENABLE_BITCODE=NO" '''% \
           (project_path, debug_tag, archive_path, team_id)
  2. 从 xxx.xcarchive 文件 打出 xxx.ipa 包

    cmd = '''xcodebuild -exportArchive -archivePath %s -exportOptionsPlist %s -exportPath %s '''%(appAchive_path, export_options_plist_path, gself_path)

踩到的一些坑

-project

  • 项目的 xcode工程路径: /Users/wilker/workplace/cocos2dx/MyXMan/frameworks/runtime-src/proj.ios_mac/MyXMan.xcodeproj

-archivePath

  • 导出的 Archive 文件路径

-configuration

  • Debug or Release

查看sdk

  • sdk 设置错误会报错:xcodebuild: error: SDK “iphoneos10.2” cannot be located

  • 查看已有的sdk,命令: xcodebuild -showsdks,然后选择已有的sdk

    MacBook-Pro:Provisioning Profiles wilker$ xcodebuild -showsdks
    iOS SDKs:
    iOS 10.3                        -sdk iphoneos10.3
    
    iOS Simulator SDKs:
    Simulator - iOS 10.3            -sdk iphonesimulator10.3
    
    macOS SDKs:
    macOS 10.12                     -sdk macosx10.12
    
    tvOS SDKs:
    tvOS 10.2                       -sdk appletvos10.2
    
    tvOS Simulator SDKs:
    Simulator - tvOS 10.2           -sdk appletvsimulator10.2
    
    watchOS SDKs:
    watchOS 3.2                     -sdk watchos3.2
    
    watchOS Simulator SDKs:
    Simulator - watchOS 3.2         -sdk watchsimulator3.2
  • 参考资料:http://www.cnblogs.com/zzugyl/p/5438869.html


scheme

  • scheme 设置错误会报错:xcodebuild: error: The project named “MyXMan” does not contain a scheme named “MyXMan”

  • 命令: xcodebuild -project /Users/wilker/workplace/cocos2dx/MyXMan/frameworks/runtime-src/proj.ios_mac/MyXMan.xcodeproj -list

    MacBook-Pro:release_tools wilker$ xcodebuild -project /Users/wilker/workplace/cocos2dx/MyXMan/frameworks/runtime-src/proj.ios_mac/MyXMan.xcodeproj -list
    Information about project "MyXMan":
      Targets:
          MyXMan-mobile
          MyXMan-desktop
    
      Build Configurations:
          Debug
          Release
    
      If no build configuration is specified and -scheme is not passed then "Release" is used.
    
      Schemes:
          MyXMan-mobile
          MyXMan-desktop
          libsimulator Mac
          libsimulator iOS
          libluacocos2d Mac
          libluacocos2d iOS
          libluacocos2d tvOS
          libcocos2d Mac
          libcocos2d iOS
          libcocos2d tvOS


exportOptionsPlist

  • exportOptionsPlist配置文件设置 teamID 错误会报错:Error Domain=IDEDistributionErrorDomain Code=1 “No valid iOS Distribution signing identities belonging to team 38W5465CZX were found.” UserInfo={NSLocalizedDescription=No valid iOS Distribution signing identities belonging to team 38W5465CZX were found.}

  • 配置文件内容

    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>method</key>
      <string>development</string>
      <key>teamID</key>
      <string>JW38L9N6HH</string>
    </dict>
    </plist>
  • 参考资料:

  • 可选参数

    1. compileBitcode: Bool
      • For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.
    2. embedOnDemandResourcesAssetPacksInBundle : Bool
      • For non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified.
    3. iCloudContainerEnvironment
      • For non-App Store exports, if the app is using CloudKit, this configures the “com.apple.developer.icloud-container-environment” entitlement. Available options: Development and Production. Defaults to Development.
    4. manifest : Dictionary
      • For non-App Store exports, users can download your app over the web by opening your distribution manifest file in a web browser. To generate a distribution manifest, the value of this key should be a dictionary with three sub-keys: appURL, displayImageURL, fullSizeImageURL. The additional sub-key assetPackManifestURL is required when using on demand resources.
    5. method : String
      • Describes how Xcode should export the archive. Available options: app-store, ad-hoc, package, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to development.
    6. onDemandResourcesAssetPacksBaseURL : String
      • For non-App Store exports, if the app uses On Demand Resources and embedOnDemandResourcesAssetPacksInBundle isn’t YES, this should be a base URL specifying where asset packs are going to be hosted. This configures the app to download asset packs from the specified URL.
    7. teamID : String
      • The Developer Portal team to use for this export. Defaults to the team used to build the archive.
    8. thinning : String
      • For non-App Store exports, should Xcode thin the package for one or more device variants? Available options: (Xcode produces a non-thinned universal app), (Xcode produces a universal app and all available thinned variants), or a model identifier for a specific device (e.g. “iPhone7,1”). Defaults to .
    9. uploadBitcode : Bool
      • For App Store exports, should the package include bitcode? Defaults to YES.
    10. uploadSymbols : Bool
      • For App Store exports, should the package include symbols? Defaults to YES.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蝶泳奈何桥.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值