美文网首页
Jenkins iOS打包问题(更新)

Jenkins iOS打包问题(更新)

作者: 一个人的思考 | 来源:发表于2019-03-13 20:08 被阅读0次

    这次在新版 Xcode 的中又遇到了一些问题。简单的总结下吧。

    一、前言

    • 有段时间没有使用过 Jenkins 打包,有的生疏。
    • 这次是由于领导要求更新下 App 的基本内容,重新使用打包。

    二、两个关键点

    • 更换开发者账号 (旧开发者账号由于不可抗力,无法继续使用。重新申请了新的开发者账号。)
    • 打包配置更新

    三、打包的曲折之路

    错误一

    Code Signing Error: No certificate for team '' matching '' found: Select a different signing certificate for CODE_SIGN_IDENTITY

    Check dependencies
    Code Signing Error: No certificate for team 'TVJxxxxxG43' matching 'iPhone Developer: develop@kxxxxe.com (VVPxxGM)' found:  Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning.
    Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.4'
    
    ** ARCHIVE FAILED **
    
    错误一

    可能出现问题的原因:

    • teamID 配置失败?
    • 证书导入错误?

    解决方案:
    由于是新开发者账号,需要将开发者账号相关信息配置到 Jenkins 中。

    • 在Jenkins -- 系统管理 -- Keychains and Provisioning Profiles Management 中添加配置。
      • 上传 login.keychain
      • 更新identities ;注意 (开发的证书:有两个 ,一个是团队的team开发证书,一个是person开发证书;不要选错)


        开发证书
      • 上传更新 Provisioning Profiles 描述文件
      • 复制描述文件到 Jenkins 对应的 MobileDevice 的目录下
     /Users/Shared/Jenkins/Library/MobileDevice/Provisoning Profiles
    

    确保 Jenkins 环境下的login.keychain 上传并更新


    错误二

    No profile for team matching 'xxx' found

    Check dependencies
    Code Signing Error: No profile for team 'X5656X29T3' matching 'PatientClientDev' found:  Xcode couldn't find any provisioning profiles matching 'X5656X29T3/PatientClientDev'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor.
    Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.4'
    
    ** ARCHIVE FAILED **
    

    出现原因:

    • 描述文件没有上传到Jenkins中
    • 描述文件没有复制
    • 打包中的 shell 脚本配置是否正确

    解决方案:

    • 上传最新的描述文件
    • 复制描述文件到 Jenkins 的 MobileDevice 对应的目录中

    错误三

    codesign failed with exit code 1

    archive 过程中签名失败

    codesign 的过程中需要对应的权限

    解决方案:
    查看 Jenkins 的login.keychain 中的证书 是否 给 codesign 相应的权限,没有的话请添加 codesign 如下图


    添加 codesign

    备注

    打包环境:

    Mac os 10.13.6
    Xcode 9.4.1
    jenkins 2.150.3

    目前,自己的Xcode 是10.1,服务器的Xcode 暂时没有升级。


    macOS Sierra中 login.keychain-db 是旧版本的 login.keychain

    系统的 keychain 路径 :

    /Users/用户名/Library/Keychains/login.keychain
    
    /Users/用户名/Library/Keychains/login.keychain-db
    

    Jenkins 的keychain 路径:

    /Users/Shared/Jenkins/Library/Keychains/login.keychain
    
    /Users/Shared/Jenkins/Library/Keychains/login.keychain-db
    
    

    下面是部分打包的shell脚本,可以一起研究讨论下。谢谢。

    # Project Configuration
    PROJECT_DIR=${WORKSPACE}
    
    CONFIGURATION="Debug"
    PROJECT_SCHEME="xxxxxxx"
    APP_DISPLAY_NAME="xxx开发"
    PROVISIONING_PROFILE_ID="edd8af66-xxxxxxx-9eb7094ae03c"
    BUNDLE_IDENTIFIER="com.xxxx.xx"
    RELEASE_METHOD="development"
    TEAM_ID="XxxxxxxT3"
    PROVISIONING_PROFILE_NAME="Doxxxxxxxev"
    
    PROJECT_INFO_PATH="${PROJECT_DIR}/xxxxxx/Info.plist"
    PROJECT_NAME="xxxxxxx"
    DEVELOPPER_NAME="iPhone Developer: Yxxxxxxx (4SJxxxxxxx75)"
    UPLOAD_URL="https://dn-xxxxx.qbox.me"
    RELEASE_SUFFIX="dev"
    RELEASE_NAME="xxxxx"
    
    # Release Configuration
    BUILD_DIR="${PROJECT_DIR}/build"
    
    RELEASE_DATE=$(date "+%Y%m%d-%H%M%S")
    
    RELEASE_VERSION=$(defaults read "${PROJECT_INFO_PATH}" CFBundleShortVersionString)
    BUILD_VERSION_TEMP=$(defaults read "${PROJECT_INFO_PATH}" CFBundleVersion)
    
    BUILD_VERSION=${BUILD_NUMBER}
    
    # Update build version
    defaults write "${PROJECT_INFO_PATH}" CFBundleVersion "${BUILD_VERSION}"
    
    APPLICATION_NAME="${RELEASE_NAME}-${RELEASE_SUFFIX}-${BUILD_VERSION}-${RELEASE_DATE}"
    
    IPA_DIR="${BUILD_DIR}/src/${RELEASE_VERSION}"
    RELEASE_PATH="${BUILD_DIR}/www/${RELEASE_VERSION}"
    
    # Clean & Build
    echo "Cleaning"
    /bin/rm -rf "${BUILD_DIR}/"
    
    echo "Building"
    cd "${PROJECT_DIR}" && mkdir -p "${BUILD_DIR}"
    
    echo '<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>compileBitcode</key>
        <false/>
    <key>method</key>
    <string>'${RELEASE_METHOD}'</string>
    <key>teamID</key>
    <string>'${TEAM_ID}'</string>
        <key>provisioningProfiles</key>
        <dict>
            <key>'${BUNDLE_IDENTIFIER}'</key>
            <string>'${PROVISIONING_PROFILE_NAME}'</string>
        </dict>
    </dict>
    </plist>' > ${BUILD_DIR}/exportOptions.plist
    
    # Sign & Pack
    /usr/bin/xcodebuild -scheme "${PROJECT_SCHEME}" -workspace "${PROJECT_NAME}.xcworkspace" -configuration "${CONFIGURATION}" clean archive -archivePath "${IPA_DIR}/${APPLICATION_NAME}" CODE_SIGN_IDENTITY="${DEVELOPPER_NAME}" PROVISIONING_PROFILE="${PROVISIONING_PROFILE_ID}"
    
    /usr/bin/xcodebuild -exportArchive -archivePath "${IPA_DIR}/${APPLICATION_NAME}.xcarchive" -exportPath "${IPA_DIR}" -exportOptionsPlist "${BUILD_DIR}/exportOptions.plist" -allowProvisioningUpdates
    
    # Release
    mkdir -p "${RELEASE_PATH}"
    echo "Release Path ${RELEASE_PATH}"
    
    mv "${IPA_DIR}/${PROJECT_SCHEME}.ipa" "${RELEASE_PATH}/${APPLICATION_NAME}.ipa"
    cd "${IPA_DIR}" && zip -r "${APPLICATION_NAME}.zip" "${APPLICATION_NAME}.xcarchive"
    
    
    

    相关文章

      网友评论

          本文标题:Jenkins iOS打包问题(更新)

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