简体   繁体   English

为什么我在 macOS Mojave 10.14.5 上的 XCode 10.2.1 的 SKAdNetworkInfo 中收到“预期返回字符串的函数中的错误返回”?

[英]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/Sur​​Build1/SurBuild2/Pods/CriteoPublisherSdk/CriteoPublisherSdk/Sources/SKAdNetwork/SKAdNetworkInfo.swift:41:3:预期返回“[String]”的函数中缺少返回/Users/developer/Documents/Sur​​Build1 /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.

相关问题 在 macOS Mojave 上安装 Xcode 11.3? - Install Xcode 11.3 on macOS Mojave? 为什么我不能在Xcode 8中使用新的内联#imageLiteral语法? “返回结果中的预期表达” - Why can't I use the new inline #imageLiteral syntax in Xcode 8? “Expected expression in return result” 为什么我在Xcode中得到NSRangeException - why am I getting NSRangeException in Xcode 我可以使用Xcode 9和macOS Mojave将应用程序上传到iOS AppStore吗? - Can I upload an app to the iOS AppStore using Xcode 9 and macOS Mojave? 如何在 macOS Mojave 10.14.6 上运行 Xcode 11.4 - How to run Xcode 11.4 on macOS Mojave 10.14.6 为什么我在xcode控制台中收到此CPSqliteStatementPerform错误 - Why am I getting this CPSqliteStatementPerform error in xcode console 为什么我在 Xcode 10.1 中出现 swift 编译器错误 - Why I am getting swift compiler error in Xcode 10.1 错误-缺少预期返回'UIInterfaceOrientationMask'的函数中的返回 - Error - Missing return in function expected to return 'UIInterfaceOrientationMask' 在预期会迅速返回的函数中缺少返回 - missing return in a function expected to return swift 如何在 xcode 10.2.1/swift 4.2 中使用“iterateEnum”函数按照枚举列表中指定的特定顺序对数组中的字符串值进行排序 - How to use 'iterateEnum' function in xcode 10.2.1/swift 4.2 to sort string value from array in specific order as specified in the enum list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM