[英]Why am I getting "Missign return in a function expected to return string" in SKAdNetworkInfo in XCode 10.2.1 on macOS Mojave 10.14.5?
我只是在編譯appodeal庫,我沒有寫那個代碼,為什么會拋出錯誤? 我可以以某種方式糾正它們嗎? XCode 截圖: https ://imgur.com/a/isrPe07
//
// SKAdNetworkInfo.swift
// CriteoPublisherSdk
//
// Copyright © 2018-2020 Criteo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
struct SKAdNetworkInfo {
let adNetworkIds: [String]
let hasCriteoId: Bool
init(bundle: Bundle = Bundle.main) {
adNetworkIds = SKAdNetworkInfo.getAdNetworkIds(from: bundle)
hasCriteoId = adNetworkIds.contains(CRSKAdNetworkInfo.CriteoId)
}
}
extension SKAdNetworkInfo {
struct Keys {
static let items = "SKAdNetworkItems"
static let identifier = "SKAdNetworkIdentifier"
}
static func getAdNetworkIds(from bundle: Bundle) -> [String] {
(bundle.object(forInfoDictionaryKey: Keys.items) as? [[String: String]])?
.compactMap { item in item[Keys.identifier] } ?? []
}
}
let skanInfo = SKAdNetworkInfo()
@objc extension CRSKAdNetworkInfo {
public static let CriteoId = "hs6bdukanm.skadnetwork"
public class func hasCriteoId() -> Bool {
skanInfo.hasCriteoId
}
public class func skAdNetworkIds() -> [String] {
skanInfo.adNetworkIds
}
}
錯誤:
/Users/developer/Documents/SurBuild1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:41:3:預期返回“[String]”的函數中缺少返回/Users/developer/Documents/SurBuild1 /SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:51:3:在預期返回“布爾”用戶/開發者/文檔/SurBuild1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/的函數中缺少返回SKAdNetwork/SKAdNetworkInfo.swift:55:3:預期返回“[String]”的函數中缺少返回
外部庫中的代碼怎么會有這樣的編譯錯誤? 語言標准是否改變或發生了什么? 我可以簡單地添加一個“return”指令來使其工作嗎?
@objc extension CRSKAdNetworkInfo {
public static let CriteoId = "hs6bdukanm.skadnetwork"
public class func hasCriteoId() -> Bool {
return skanInfo.hasCriteoId
}
public class func skAdNetworkIds() -> [String] {
return skanInfo.adNetworkIds
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.