简体   繁体   中英

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? Can I correct them somehow? XCode screenshot: 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]'

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?

@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
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM