swift 符号未找到:_PKPaymentNetworkPagoBancomat

wwwo4jvm  于 2023-11-16  发布在  Swift
关注(0)|答案(1)|浏览(119)

所以在我的应用程序中,我已经将ApplePay与Xcode Version 15.0(15 A240 d)集成在一起,我的应用程序的最低iOS版本是v16。
我正在做的是从字面上Map到PKPaymentNetwork的web PaymentNetwork.当我运行iOS 16.4模拟器上的应用程序时,它只是崩溃了以下消息.

dyld[63845]: Symbol not found: _PKPaymentNetworkPagoBancomat
  Referenced from: <BACBF79F-6485-3A1B-84CA-A343341FA5A6> /Users/user.name/Library/Developer/CoreSimulator/Devices/2F7896EF-64AE-40CF-B712-DF4F2DCFF887/data/Containers/Bundle/Application/2D15AF1A-8479-4C03-A674-CF9F3A721573/MyApp.app/MyApp
  Expected in:     <6C22B2D4-5F5B-3FA9-825B-BDA166D45320> /Library/Developer/CoreSimulator/Volumes/iOS_20E247/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 16.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/PassKit.framework/PassKit

字符串
下面是我尝试执行的代码。
请注意,它与iOS 17一起工作!

public enum ApplePayNetwork: String, Codable {
    case amex = "amex"
    case bancomat = "bancomat"
    case bancontact = "bancontact"
    case cartesBancaires = "cartesBancaires"
    case chinaUnionPay = "chinaUnionPay"
    case dankort = "dankort"
    case discover = "discover"
    case eftpos = "eftpos"
    case electron = "electron"
    case elo = "elo"
    case girocard = "girocard"
    case interac = "interac"
    case jcb = "jcb"
    case mada = "mada"
    case maestro = "maestro"
    case masterCard = "masterCard"
    case mir = "mir"
    case privateLabel = "privateLabel"
    case visa = "visa"
    case vPay = "vPay"
    
    public init?(pkPaymentNetwork: PKPaymentNetwork?) {
        guard let pkPaymentNetwork else {
            return nil
        }
        switch pkPaymentNetwork {
        case .amex:
            self = .amex
        case .pagoBancomat:
            self = .bancomat
        case .bancontact:
            self = .bancontact
        case .cartesBancaires:
            self = .cartesBancaires
        case .chinaUnionPay:
            self = .chinaUnionPay
        case .dankort:
            self = .dankort
        case .discover:
            self = .discover
        case .eftpos:
            self = .eftpos
        case .electron:
            self = .electron
        case .elo:
            self = .elo
        case .girocard:
            self = .girocard
        case .interac:
            self = .interac
        case .JCB:
            self = .jcb
        case .mada:
            self = .mada
        case .maestro:
            self = .maestro
        case .masterCard:
            self = .masterCard
        case .mir:
            self = .mir
        case .privateLabel:
            self = .privateLabel
        case .visa:
            self = .visa
        case .vPay:
            self = .vPay
        default:
            return nil
        }
    }
    
    public var toAppNetwork: PKPaymentNetwork {
        switch self {
        case .amex:
            return .amex
        case .bancomat:
            return .pagoBancomat
        case .bancontact:
            return .bancontact
        case .cartesBancaires:
            return .cartesBancaires
        case .chinaUnionPay:
            return .chinaUnionPay
        case .dankort:
            return .dankort
        case .discover:
            return .discover
        case .eftpos:
            return .eftpos
        case .electron:
            return .electron
        case .elo:
            return .elo
        case .girocard:
            return .girocard
        case .interac:
            return .interac
        case .jcb:
            return .JCB
        case .mada:
            return .mada
        case .maestro:
            return .maestro
        case .masterCard:
            return .masterCard
        case .mir:
            return .mir
        case .privateLabel:
            return .privateLabel
        case .visa:
            return .visa
        case .vPay:
            return .vPay
        }
    }
}

gywdnpxw

gywdnpxw1#

PKPaymentNetwork.pagoBancomat仅从iOS 17.0开始可用。这意味着任何提及此网络的内容都应封装在可用性检查中,例如:

if #available(iOS 17.0, *) {
    return .pagoBancomat
}

字符串
但是由于你使用的是switch,你可能需要使用default子句来处理这个特定的网络。你可能需要对tmoney执行类似的操作,因为这个网络也只能从iOS 17.0开始使用。
然而,看起来pagoBancomat网络有问题,而且问题还不止于此。即使使用if #available条件,我的应用在iOS 16.3上启动时也会崩溃
我决定暂时不提pagoBancomat。但如果我不是唯一注意到这个问题的人,我会向Apple提交反馈,这可能是SDK级别的bug,可以在Xcode的后续版本中修复。
备注:

  • 使用Xcode 15.0.1
  • 我已经尝试清理项目并删除派生数据。

相关问题