xcodebuild在Xcode 14中失败,但在Xcode 13中正常。

huangapple go评论45阅读模式
英文:

xcodebuild failing in Xcode14 but working in Xcode 13

问题

I can help you with the translation. Here is the translated content:

我在使用命令行脚本在Xcode 14中生成构建时遇到了问题,但相同的脚本在Xcode 13中可以工作。

用于归档的函数是:

function buildArchieve {
    BUILD_FILES="$BUILD_DIR/${ASSET_BASENAME}"
    mkdir -p "$BUILD_FILES"

    # 归档构建
    ARCHIEVE_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD/${PRODUCT_NAME}.xcarchive"
    (xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive 1> /dev/null ||
    xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive ||
    failed "XCode failed to build app")

    # 导出归档
    EXPORT_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD"
    xcodebuild -exportArchive -archivePath "$ARCHIEVE_PATH" -exportPath "$EXPORT_PATH" -exportOptionsPlist "$EXPORT_PLIST_FILE" 1> /dev/null

    # 提取DSYM文件
    if [ "$METHOD" == "app-store" ]; then
        DYSM_FILE="${EXPORT_PATH}/${PRODUCT_NAME}.xcarchive/dSYMs/WhiteLabel.app.dSYM"
        ditto -c -k --norsrc "$DYSM_FILE" "${BUILD_FILES}/${PRODUCT_NAME}_${bvers}.dSYM.zip"
    fi

    # 删除归档文件
    rm -rf "$ARCHIEVE_PATH"
}

我在Jenkins控制台上得到以下信息:

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath "administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive" clean archive
用户默认值来自命令行:IDEArchivePathOverride = /Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/BroughSuperior/administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive IDEPackageSupportUseBuiltinSCM = YES`

现在我无法再使用Xcode 13,因为苹果已停止从Xcode 13接受构建。而且相同的命令在Xcode 13中可以工作。

Archive_output.txt文件

命令行调用:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath clean archive

用户默认值来自命令行:
IDEPackageSupportUseBuiltinSCM = YES

解析包图

已解析的源包: Facebook: https://github.com/facebook/facebook-ios-sdk.git @ 13.0.0 Bugsnag: https://github.com/bugsnag/bugsnag-cocoa @ 6.2.0

** 清除成功 **

准备包

计算目标依赖图和提供输入

创建构建描述 构建描述签名: d6adcbd478de817a50f1882539a78d15 构建描述路径: /Users/administrator/Library/Developer/Xcode/DerivedData/BroughSuperior-gmieqdexltbrbsesvhrtzpgzfdig/Build/Intermediates.noindex/ArchiveIntermediates/BroughSuperior/IntermediateBuildFilesPath/XCBuildData/d6adcbd478de817a50f1882539a78d15-desc.xcbuild

注意:以依赖顺序构建目标 警告:运行脚本构建阶段“Build Helper Script”将在每次构建时运行,因为它未指定任何输出。要解决此警告,要么将输出依赖项添加到脚本阶段,要么在脚本阶段中取消选中“基于依赖分析”中的“运行”。 (在项目“BroughSuperior”的目标“WhiteLabel”中) 注意:运行脚本构建阶段“Copy MIBKit Resource Bundle”将在每次构建时运行,因为未选中运行脚本阶段“基于依赖分析”的选项。 (在项目“BroughSuperior”的目标“WhiteLabel”中) 警告:运行脚本构建阶段“Bugsnag”将在每次构建时运行,因为它未指定任何输出。要解决此警告,要么将输出依赖项添加到脚本阶段,要么在脚本阶段中取消选中“基于依赖分析”中的“运行”。 (在项目“BroughSuperior”的目标“WhiteLabel”中) /Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/MIBKit/MIBKit.xcodeproj:错误:找不到签名证书“iOS Development”:找不到与团队ID“HHGY6CWBZB”匹配的“iOS Development”签名证书,也找不到私钥。 (在项目“MIBKit”的目标“MIBKitResources”中) ** 归档失败 **

英文:

I am facing a issue while generating build using command line script in Xcode 14, the same script is working with Xcode 13.

the function to archive is

function buildArchieve {
BUILD_FILES="$BUILD_DIR/${ASSET_BASENAME}"
mkdir -p "$BUILD_FILES"

# archieve the build
ARCHIEVE_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD/${PRODUCT_NAME}.xcarchive"
(xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive 1> /dev/null ||
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive ||
failed "XCode failed to build app")

# export archieve
EXPORT_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD"
xcodebuild -exportArchive -archivePath "$ARCHIEVE_PATH" -exportPath "$EXPORT_PATH" -exportOptionsPlist "$EXPORT_PLIST_FILE" 1> /dev/null

# Extacting DSYM file
if [ "$METHOD" == "app-store" ]; then
    DYSM_FILE="${EXPORT_PATH}/${PRODUCT_NAME}.xcarchive/dSYMs/WhiteLabel.app.dSYM"
    ditto -c -k --norsrc "$DYSM_FILE" "${BUILD_FILES}/${PRODUCT_NAME}_${bvers}.dSYM.zip"
fi

# removing archieve file
rm -rf "$ARCHIEVE_PATH"

}

and I am getting following on the Jenkins console

> /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath "administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive" clean archive
User defaults from command line: IDEArchivePathOverride = /Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/BroughSuperior/administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive IDEPackageSupportUseBuiltinSCM = YES`

I can not use Xcode 13 now, since apple has stopped taking builds from Xcode 13. And the same command works in Xcode 13.

> Archive_output.txt file
>
> Command line invocation:
> /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath clean archive
>
> User defaults from command line:
> IDEPackageSupportUseBuiltinSCM = YES
>
> Resolve Package Graph
>
> Resolved source packages: Facebook:
> https://github.com/facebook/facebook-ios-sdk.git @ 13.0.0 Bugsnag:
> https://github.com/bugsnag/bugsnag-cocoa @ 6.2.0
>
>
>
> ** CLEAN SUCCEEDED **
>
> Prepare packages
>
> Computing target dependency graph and provisioning inputs
>
> Create build description Build description signature:
> d6adcbd478de817a50f1882539a78d15 Build description path:
> /Users/administrator/Library/Developer/Xcode/DerivedData/BroughSuperior-gmieqdexltbrbsesvhrtzpgzfdig/Build/Intermediates.noindex/ArchiveIntermediates/BroughSuperior/IntermediateBuildFilesPath/XCBuildData/d6adcbd478de817a50f1882539a78d15-desc.xcbuild
>
> note: Building targets in dependency order warning: Run script build
> phase 'Build Helper Script' will be run during every build because it
> does not specify any outputs. To address this warning, either add
> output dependencies to the script phase, or configure it to run in
> every build by unchecking "Based on dependency analysis" in the script
> phase. (in target 'WhiteLabel' from project 'BroughSuperior') note:
> Run script build phase 'Copy MIBKit Resource Bundle' will be run
> during every build because the option to run the script phase "Based
> on dependency analysis" is unchecked. (in target 'WhiteLabel' from
> project 'BroughSuperior') warning: Run script build phase 'Bugsnag'
> will be run during every build because it does not specify any
> outputs. To address this warning, either add output dependencies to
> the script phase, or configure it to run in every build by unchecking
> "Based on dependency analysis" in the script phase. (in target
> 'WhiteLabel' from project 'BroughSuperior')
> /Users/administrator/.jenkins/jobs/iOS Bruff
> dev/workspace/MIBKit/MIBKit.xcodeproj: error: No signing certificate
> "iOS Development" found: No "iOS Development" signing certificate
> matching team ID "HHGY6CWBZB" with a private key was found. (in target
> 'MIBKitResources' from project 'MIBKit')
> ** ARCHIVE FAILED **

答案1

得分: 2

日志中的错误消息表明这可能是一个签名问题:

/Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/MIBKit/MIBKit.xcodeproj: error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "HHGY6CWBZB" with a private key was found. (in target 'MIBKitResources' from project 'MIBKit') ** ARCHIVE FAILED **

这表明 Xcode 无法找到与指定的团队 ID 匹配的适当 iOS Development 证书。

在 Jenkins 控制台上

请记住,如果您使用 Jenkins 构建项目,您需要确保正确的证书和配置文件已安装在 Jenkins 服务器上,而不仅仅是在本地机器上。您的 Jenkins 服务器可能是您的本地机器:确保它(Jenkins)正在以您的帐户运行。

首先,请检查您的证书:在用作 Jenkins 服务器的 Mac 上打开 Keychain Access 应用程序,并验证是否存在正确的 iOS Development 证书。如果没有,您可能需要从 Apple Developer 网站下载并安装它。

然后检查您的配置文件(打开 Xcode 并转到 Xcode > Preferences > Accounts,选择您的 Apple ID,然后单击“Manage Certificates”)。查看开发证书是否在证书列表中。如果没有,您可以通过单击加号按钮来添加它。

尝试更新构建设置,方法是在 Xcode 中打开您的项目并检查目标的构建设置。确保“Code Signing Identity”设置为“iOS Developer”,“Provisioning Profile”设置为“Automatic”或正确的特定配置文件。还要确保在“Signing & Capabilities”选项卡中选择了正确的团队。

注意:有时,由于使用了错误版本的 Xcode 命令行工具,可能会出现问题。您可以通过转到Xcode > Preferences > Locations > Command Line Tools 并选择正确的 Xcode 版本来设置正确的版本。

英文:

The error message in your log indicates that it should be a signing issue:

/Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/MIBKit/MIBKit.xcodeproj: error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "HHGY6CWBZB" with a private key was found. (in target 'MIBKitResources' from project 'MIBKit') ** ARCHIVE FAILED **

This suggests that Xcode cannot find the appropriate iOS Development certificate that matches the specified team ID.

> on the Jenkins console

Remember, if you're using Jenkins to build your project, you'll need to ensure that the correct certificates and provisioning profiles are installed on the Jenkins server, and not just your local machine.
Your Jenkins server could be your local machine: make sure it (Jenkins) is running with your account.

First, check your certificates: Open the Keychain Access app on the Mac used as Jenkins server (could be your own machine), and verify that the correct iOS Development certificate is present. If it's not, you might need to download it from the Apple Developer website and install it.

Then check your provisioning profiles (Open Xcode and go to Xcode > Preferences > Accounts, select your Apple ID, and click on "Manage Certificates.") See if the development certificate is present in the list of certificates. If not, you can add it by clicking the plus button.

Try and update your build settings, by opening your project in Xcode and check the build settings for your target. Make sure the "Code Signing Identity" is set to "iOS Developer" and the "Provisioning Profile" is set to "Automatic" or to the correct specific profile. Also, ensure that the correct team is selected in the "Signing & Capabilities" tab.

Note: Sometimes, issues can arise because the wrong version of Xcode is being used by command line tools. You can set the correct version by going to Xcode > Preferences > Locations > Command Line Tools and selecting the correct version of Xcode.

答案2

得分: -2

Changes in Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
    end
  end
end

Source: https://github.com/CocoaPods/CocoaPods/pull/11723/files#diff-48e896df652b2501f6273da535c8613c530227a16358271160cc2ec590c2cb11R603

英文:

I had a similar problem and this helped me.

Changes in Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
    end
  end
end

Source: https://github.com/CocoaPods/CocoaPods/pull/11723/files#diff-48e896df652b2501f6273da535c8613c530227a16358271160cc2ec590c2cb11R603

huangapple
  • 本文由 发表于 2023年5月10日 19:45:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76217995.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定