[英]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?
I am just compiling the appodeal library, I have not wrote that code, why is is throwing errors?我只是在编译appodeal库,我没有写那个代码,为什么会抛出错误? Can I correct them somehow?
我可以以某种方式纠正它们吗? XCode screenshot: https://imgur.com/a/isrPe07
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
}
}
The errors:错误:
/Users/developer/Documents/SurBuild1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:41:3: Missing return in a function expected to return '[String]' /Users/developer/Documents/SurBuild1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:51:3: Missing return in a function expected to return 'Bool' Users/developer/Documents/SurBuild1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:55:3: Missing return in a function expected to return '[String]'
/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]”的函数中缺少返回
How can a code from external library have such compile errors?外部库中的代码怎么会有这样的编译错误? Was the language standard changed or what happened?
语言标准是否改变或发生了什么? Can I simply add a "return" directive to make it work?
我可以简单地添加一个“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.