在模拟器中工作但不在真实设备上工作 swift xcode alamofire

Working in simulator but not on Real device swift xcode alamofire

在模拟器中工作但不在设备上工作 我从 api 获取数据它在模拟器上正常工作但在真实设备上不工作

并报错No such module 'Alamofire'

这是我的代码ViewController.swift

导入 UIKit

导入 Alamofire

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

@IBOutlet var tableview: UITableView!

var TeamArray = [AnyObject]()
var BackArray = [AnyObject]()
 var countnew = 0
var timer = Timer()
override func viewDidLoad() {
    super.viewDidLoad()

    Alamofire.request("https://www.WebLink.com/api/").responseJSON{
        response in

        if let DataResult = response.result.value{

             if let dictionary = DataResult as? [String: Any] {
                if let Result1 = dictionary["result"] as? [String: Any]{
                    if let nestedDictionary1 = Result1["inPlayEvents"] as? NSArray, let description = nestedDictionary1.value(forKey: "market") as? [[String: Any]],let description1 = description.first?["runners"] as? [[String: Any]],let BAck = description1.first?["back"] as? NSArray{

                        print("JSONResdsd : \(nestedDictionary1)")
                       // print("JSONEvent : \(description)")
                        self.TeamArray = description as [AnyObject]
                        self.BackArray = BAck as [AnyObject]

                         self.timer = Timer.scheduledTimer(timeInterval:1.0, target: self, selector: "sayHello", userInfo: nil, repeats: true)

                    }
                }
            }

        }
    }
    // Do any additional setup after loading the view, typically from a nib.
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return TeamArray.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as?
    CustomTableViewCell

    let title = TeamArray[indexPath.row]["start"]
    let price = BackArray[indexPath.row]["price"]

    let x : Double = title as! Double
    let myString = String(x)
    let pricenew : Double = price as! Double
    let pricestr = String(pricenew)
    print("Price : \(pricestr)")
    print("INT : \(title)")
    //let BPrice = BackArray[indexPath.row]["price"]
 //  ToastView.shared.short(self.view, txt_msg: "HJJDFKH\(String(describing: BPrice)))")
    cell?.TitleLabel.text = String (myString)
    cell?.Back.text = String (pricestr)
   // cell?.Back.text(\())
    return cell!
}

@objc func sayHello()
{
    self.tableview.reloadData()
}

}

你能告诉我你是如何安装 Alamofire 的吗?您可以查看他们的 GitHub 自述文件页面:https://github.com/Alamofire/Alamofire/tree/4.8.0 有几种方法可以将此库添加到项目中。我会推荐你​​使用 Cocoapods:

1) 安装 CocoaPods:

gem install cocoapods

2) 在项目文件夹中创建 Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
   pod 'Alamofire', '~> 4.7'
end

<Your Target Name> 替换为您的目标名称。

3) 运行:

pod install

4) 关闭您的项目并在 Xcode

中打开一个名为 <Your Project Name>.xcworkspace 的新文件