我手动在 GitHub 操作上尝试签署我的 iOS 应用程序。
我正在使用 fastlane(部分)来帮助我。我不想使用 match,因为我打算在客户之间重用脚本,因此我无法使用共享的 git-repo。
我收到与通过 SPM 添加的第三方框架(Firebase 等)相关的错误。该应用程序在本地构建和存档正常,但从 GitHub 操作会产生错误。这就是归档的执行方式(通过 GitHub 操作上的 fastlane):
我尝试了 xcode 构建的各种参数组合,但没有成功。
这是我的快车道。这不是完整的代码,但概述了我如何执行它:
lane :archive_pixelmost do |options|
providedProjectTeamId = options[:projectTeamId]
bundle_id = ENV['BUNDLE_ID']
appPath = "../buildTarget/build.appmostapp"
if providedProjectTeamId.nil?
iOSProjectTeamId = sh("jq '.buildIOSProjectTeamId' '#{appPath}/app.json' | tr -d '\n' | tr -d '\\' | tr -d '\"'").strip
else
iOSProjectTeamId = providedProjectTeamId
end
UI.user_error!("iOS Project Team ID not found") if iOSProjectTeamId.nil? || iOSProjectTeamId.empty?
# Fetch certificates and provisioning profiles
certificates_and_profiles = fetch_certificates_and_profiles
cert_id = certificates_and_profiles[:cert_id]
provisioning_profile_path = certificates_and_profiles[:profile_path]
provisioning_profile_specifier = File.basename(provisioning_profile_path).split('.').first
profile_name = certificates_and_profiles[:profile_name]
cert_name = certificates_and_profiles[:cert_name]
UI.message("cert_id: #{cert_id}, profile_name: #{profile_name} provisioning_profile_specifier: #{provisioning_profile_specifier}, iOSProjectTeamId: #{iOSProjectTeamId} cert_name: #{cert_name}")
# Update the project team for all targets
update_project_team(
path: "./projectx.xcodeproj",
targets: buildTargetNames + ["BuildTarget_AppClip"],
teamid: iOSProjectTeamId
)
keychain_password = "temporary_password"
keychain_path = "#{ENV['RUNNER_TEMP']}/app-signing.keychain-db"
# Rensa och lås upp keychain före byggningen
sh "security list-keychains -s #{keychain_path} ~/Library/Keychains/login.keychain-db"
sh "security default-keychain -s #{keychain_path}"
sh "security unlock-keychain -p #{keychain_password} #{keychain_path}"
export_options_path = "../projectx/Supporting files/BuildTarget/exportOptions.plist"
unless File.exist?(export_options_path)
UI.user_error!("exportOptions.plist filen finns inte på sökvägen: #{export_options_path}")
end
export_options = Plist.parse_xml(export_options_path)
if export_options.nil?
UI.user_error!("Kunde inte läsa in exportOptions.plist som en Hash. Kontrollera att filen är en giltig plist.")
end
UI.message("bundle_id: #{bundle_id} profile_name: #{profile_name}")
export_options['teamID'] = iOSProjectTeamId
export_options['provisioningProfiles'] = { bundle_id => profile_name }
File.open(export_options_path, 'w') { |f| f.write(export_options.to_plist) }
sh "xcodebuild -resolvePackageDependencies -workspace '../projectx.xcworkspace' -scheme 'BuildTarget'"
sh "xcodebuild clean -workspace '../projectx.xcworkspace' -scheme 'BuildTarget' -configuration Release"
disable_automatic_code_signing(
path: "./projectx.xcodeproj",
use_automatic_signing: false,
targets: ["BuildTarget"]
)
sh "xcodebuild archive -scheme 'BuildTarget' -workspace '../projectx.xcworkspace' -configuration Release -archivePath ../build/BuildTarget.xcarchive DEVELOPMENT_TEAM='#{iOSProjectTeamId}' CODE_SIGN_IDENTITY='#{cert_name}' PROVISIONING_PROFILE_SPECIFIER='#{profile_name}' -allowProvisioningUpdates ARCHS='arm64' VALID_ARCHS='arm64' ONLY_ACTIVE_ARCH=NO CODE_SIGN_STYLE=Manual CODE_SIGNING_REQUIRED=Yes CODE_SIGNING_ALLOWED=Yes"
end
end
这是已解决的运行命令:
xcodebuild archive -scheme BuildTarget -workspace ../projectx.xcworkspace -configuration Release -archivePath ../build/BuildTarget.xcarchive DEVELOPMENT_TEAM=W3KA9856B7 "CODE_SIGN_IDENTITY=Apple Distribution: Appfrilans AB (W3KA9856B7)" "PROVISIONING_PROFILE_SPECIFIER=se.polartouch.reskollen AppStore 1720188299" -allowProvisioningUpdates ARCHS=arm64 VALID_ARCHS=arm64 ONLY_ACTIVE_ARCH=NO CODE_SIGN_STYLE=Manual CODE_SIGNING_REQUIRED=Yes CODE_SIGNING_ALLOWED=Yes
错误:
Exit status of command 'xcodebuild archive -scheme 'BuildTarget' -workspace '../projectx.xcworkspace' -configuration Release -archivePath ../build/BuildTarget.xcarchive DEVELOPMENT_TEAM='W3KA9856B7' CODE_SIGN_IDENTITY='Apple Distribution: Appfrilans AB (W3KA9856B7)' PROVISIONING_PROFILE_SPECIFIER='se.polartouch.reskollen AppStore 1720188299' -allowProvisioningUpdates ARCHS='arm64' VALID_ARCHS='arm64' ONLY_ACTIVE_ARCH=NO CODE_SIGN_STYLE=Manual CODE_SIGNING_REQUIRED=Yes CODE_SIGNING_ALLOWED=Yes' was 65 instead of 0.
/Users/runner/Library/Developer/Xcode/DerivedData/projectx-ajepocrionzredcbzdsapmxpgxgi/SourcePackages/checkouts/GoogleUtilities/Package.swift: error: GoogleUtilities_GoogleUtilities-Reachability does not support provisioning profiles. GoogleUtilities_GoogleUtilities-Reachability does not support provisioning profiles, but provisioning profile se.polartouch.reskollen AppStore 1720188299 has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'GoogleUtilities_GoogleUtilities-Reachability' from project 'GoogleUtilities')
/Users/runner/Library/Developer/Xcode/DerivedData/projectx-ajepocrionzredcbzdsapmxpgxgi/SourcePackages/checkouts/ASN1Swift/Package.swift: error: ASN1Swift does not support provisioning profiles. ASN1Swift does not support provisioning profiles, but provisioning profile se.polartouch.reskollen AppStore 1720188299 has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'ASN1Swift' from project 'ASN1Swift')
/Users/runner/Library/Developer/Xcode/DerivedData/projectx-ajepocrionzredcbzdsapmxpgxgi/SourcePackages/checkouts/GoogleUtilities/Package.swift: error: GoogleUtilities_GoogleUtilities-Environment does not support provisioning profiles. GoogleUtilities_GoogleUtilities-Environment does not support provisioning profiles, but provisioning profile se.polartouch.reskollen AppStore 1720188299 has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'GoogleUtilities_GoogleUtilities-Environment' from project 'GoogleUtilities')
/Users/runner/Library/Developer/Xcode/DerivedData/projectx-ajepocrionzredcbzdsapmxpgxgi/SourcePackages/checkouts/GoogleUtilities/Package.swift: error: GoogleUtilities-Reachability does not support provisioning profiles. GoogleUtilities-Reachability does not support provisioning profiles, but provisioning profile se.polartouch.reskollen AppStore 1720188299 has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'GoogleUtilities-Reachability' from project 'GoogleUtilities')
我通过 SPM 使用的所有框架都会重复此错误:Firebase_FirebaseAuth、FirebaseCore、nanopb_nanopb、FirebaseFirestoreTarget、FirebaseStorage 等
我已经尝试过:
编辑1:
我已经能够在我的计算机上本地运行相同的命令,以加快我的迭代和测试能力。我已在developer.apple.com 中手动创建了证书和配置文件,并将它们导入到我的计算机中。但是,如果我禁用手动代码签名,似乎如果我设置“Apple Development”以外的其他内容,我会收到此错误:
error: Firebase_FirebaseCoreInternal has conflicting provisioning settings.
Firebase_FirebaseCoreInternal is automatically signed for development, but a conflicting code signing identity Apple Distribution has been manually specified.
Set the code signing identity value to "Apple Development" in the build settings editor, or switch to manual signing in the Signing & Capabilities editor.
(in target 'Firebase_FirebaseCoreInternal' from project 'Firebase')
但是,如果我将其设置为“Apple Development”,它确实使用正确的配置文件,但无法将其与(正确的)分发证书匹配,而是选择缺少配置文件的开发证书...
error: Provisioning profile "Polartouch" doesn't include signing certificate "Apple Development: Created via API (AFG4LX6NWZ)". (in target 'BuildTarget' from project 'projectx')
终于成功了。对我来说,解决方案是在 xcodebuild 命令中不包含任何证书或配置文件的参数。相反,直接在构建目标设置中设置这些。
所以生成的命令只会是:
sh "xcodebuild archive -scheme 'BuildTarget' -workspace '../projectx.xcworkspace' -configuration Release -archivePath ../build/BuildTarget.xcarchive DEVELOPMENT_TEAM='#{iOSProjectTeamId}'"
然后我将使用“Xcodeproj”在目标设置中动态设置配置文件说明符。目标的协同设计被设置为“iOS Distribution”。