EspressifApp/EsptouchForIOS

Undefined Symbol: _OBJC_CLASS_$_ESPTouchTask, Undefined Symbol: _OBJC_CLASS_$_ESPTools

Abhesheksh opened this issue · 3 comments

Error :

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_ESPTouchTask", referenced from:
objc-class-ref in homeVC.o
"OBJC_CLASS$_ESPTools", referenced from:
objc-class-ref in addDeviceVC.o
objc-class-ref in homeVC.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My code : the two files where the error originates :

import UIKit
import FBSDKLoginKit
import Firebase
import FBSDKCoreKit
import SystemConfiguration.CaptiveNetwork
import FirebaseFirestore
import FirebaseAuth
import SystemConfiguration.CaptiveNetwork


class homeVC: UIViewCon
![Screenshot 2021-11-07 at 12 37 28 PM](https://user-images.githubusercontent.com/9547435/140636034-60d5505a-d765-47ee-b804-5d8e4fbf678d.png)
![Screenshot 2021-11-07 at 12 37 21 PM](https://user-images.githubusercontent.com/9547435/140636041-e16d8aea-2503-44ed-8689-2fdfa4641f45.png)
![Screenshot 2021-11-07 at 12 37 11 PM](https://user-images.githubusercontent.com/9547435/140636043-d64b5a36-94b2-45c7-b725-e5a5b75f1471.png)
![Screenshot 2021-11-07 at 12 36 31 PM](https://user-images.githubusercontent.com/9547435/140636045-abd544cf-44e8-4271-89d0-7c024b3fce5e.png)
troller, ESPTouchDelegate {
    
    
  
    
   
var userNameString: String?
let db = Firestore.firestore()

    
    
    
    
   
    @IBAction func addSmartDevice(_ sender: UIButton) {
        
               //let secretKey = "897219736"
              // var aes : ESPAES

              // aes = ESPAES.init(key: secretKey)
        
        var task : ESPTouchTask
            
        task = ESPTouchTask.init(apSsid: ESPTools.getCurrentWiFiSsid(), andApBssid: ESPTools.getCurrentBSSID(), andApPwd: "12345678")

               task.setEsptouchDelegate(self)
               //UIApplication.shared.windows[0].actv
               //task.executeForResult()
    
               task.setPackageBroadcast(true)
               DispatchQueue.global(qos: .userInitiated).async {
                   let result = task.executeForResult()!
                   // 在主线程中显示结果
                   DispatchQueue.main.async {
                       // 隐藏等待框
                       // UIApplication.shared.windows[0].hideToastActivity()
                   // 重新启用连接按钮
                   //self.nextStepBtn.enable()
                   // 判断配置结果
                       if (result.isSuc) {
                           print("SUCCESS")
                           self.onEsptouchResultAdded(with: result)
                        
                            //PASS EMAIL TO THE DEVICE
                        if let email = Auth.auth().currentUser?.email {
                             let url = URL(string: "http://192.168.1.199/get?email=\(email)")!
                             var request = URLRequest(url: url)
                            request.httpMethod = "GET"
                            let emailTask = URLSession.shared.dataTask(with: request) { (data, response, error) in
                                guard let data = data,
                                let response = response as? HTTPURLResponse,
                                error == nil else
                                {
                                    print("error", error ?? "Unknown Error")
                                return
                                }
                                let responseString = String(data : data, encoding : .utf8)
                                print("response String = \(responseString)")
                            }
                            emailTask.resume()
                            
                            
                        
                        }
                       
                        
                            //END PASS EMAIL
                        
                      }
    else {
                           print("FAILURE")
                       }
                      }
               }
               
        
    }
    
    func onEsptouchResultAdded(with result: ESPTouchResult!) {
          print(result.description)
      }

import UIKit
import SystemConfiguration.CaptiveNetwork

class addDeviceVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        printData()
        
        
        // Do any additional setup after loading the view, typically from a nib.
        ESPTools.getCurrentBSSID()
        ESPTools.getCurrentBSSID()

    }
    
    
    func getSSID() -> String? {
        guard let interface = (CNCopySupportedInterfaces() as? [String])?.first,
            let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: Any],
            let ssid = unsafeInterfaceData["SSID"] as? String else{
                return nil
        }
        return ssid
    }



    // Return IP address of WiFi interface (en0) as a String, or `nil`
    func getWiFiAddress() -> String? {
        var address : String?

        // Get list of all interfaces on the local machine:
        var ifaddr : UnsafeMutablePointer<ifaddrs>?
        guard getifaddrs(&ifaddr) == 0 else { return nil }
        guard let firstAddr = ifaddr else { return nil }

        // For each interface ...
        for ifptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
            let interface = ifptr.pointee

            // Check for IPv4 or IPv6 interface:
            let addrFamily = interface.ifa_addr.pointee.sa_family
            if addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) {

                // Check interface name:
                let name = String(cString: interface.ifa_name)
                if  name == "en0" {

                    // Convert interface address to a human readable string:
                    var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
                    getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
                                &hostname, socklen_t(hostname.count),
                                nil, socklen_t(0), NI_NUMERICHOST)
                    address = String(cString: hostname)
                }
            }
        }
        freeifaddrs(ifaddr)
        return address
    }

    func getWiFiSsid() -> String? {
        var ssid: String?
        if let interfaces = CNCopySupportedInterfaces() as NSArray? {
            for interface in interfaces {
                if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {

                    ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
                }
            }
        }
        return ssid
    }

    func getSSIDtwo() -> String? {
        let interfaces = CNCopySupportedInterfaces()
        if interfaces == nil {
            //print("Not interfaces")
            return nil
        }

        let interfacesArray = interfaces as! [String]
        if interfacesArray.count <= 0 {
            return nil
        }
        let interfaceName = interfacesArray[0] as String
        let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName as CFString)
        if unsafeInterfaceData == nil {
            return nil
        }

        let interfaceData = unsafeInterfaceData as! Dictionary <String,AnyObject>
        return interfaceData["SSID"] as? String
    }

    func printData() {
        let one = getWiFiSsid();
        let two = getSSIDtwo();
        let three = getSSID();
        print("PRINTING SSID DETAILS. PRINTING SSID DETAILS. SSID DETAILS FOLLOWING")

        print(one);
        print(two);
        print(three);
    }}

Bridging Header :

#ifndef Storme_Bridging_Header_h
#define Storme_Bridging_Header_h

#import "ESPTouch/esptouch/ESPTouchTask.h"
#import "ESPTouch/esptouch/ESPTouchResult.h"
#import "Common/ESPUtils/ESP_NetUtil.h"
#import "ESPTouch/esptouch/ESPTouchDelegate.h"
#import "Common/ESPUtils/ESPAES.h"
#import "Common/AFNetworking/AFNetworking.h"

#import "Common/ESPUtils/ESPTools.h"

#endif /* Storme_Bridging_Header_h */

@Abhesheksh Have you been able to fix this error by chance? If yes, please share your solution with me. Currently, I got the error and still cannot fix it. I've tried many ways but with no success. Thank you

Hi, I don't have my system with me right now, I will get back to you with. I don't exactly remember what I did to sort this out but I think it was an issue with the bridging header itself. Let me check & get back to you in 48 hours.