Search code examples
iosswiftxcode14.3brother-print-sdk

Not able to discover devices on local network using "startNetworkSearch"?


I am working with below configurations.

Xcode 14.3 and iOS 16.6.1(Swift language) and Brother SDK 4.6.4.Added SDK and plist keys as documented.

I am able to print the label with the above configurations(Manually added the printer IPAddress in code, tested in both scenarios with Printer Wifi direct and Local Wifi network). But not able to discover printer using the below code?

let option = BRLMNetworkSearchOption()
option.searchDuration = 15
 let result = BRLMPrinterSearcher.startNetworkSearch(option) { channel in
 let modelName = channel.extraInfo?.value(forKey: BRLMChannelExtraInfoKeyModelName) as? String ?? ""
 let ipaddress = channel.channelInfo
 print("Channel : \(channel.description)")
 print("Channel Extra info: \(channel.extraInfo)")
 print("Model : \(modelName), IP Address: \(ipaddress)")
 }

Please give any suggestions to discover printer over local wifi network. Thanks in advance.


Solution

  • After two days of research I am able to find the way.Here is the process to integrate Wifi printer SDK in your iOS project.

    Wifi printer:-

    1.Put Net/BRLMPrinterKit.xcframework at any location.

    2.Add it to Embedded Binaries and Linked Frameworks and Libraries of your application target.

    3.Add Framework Search Paths and Header Search Paths if needed.

    4.Add NSLocalNetworkUsageDescription (Privacy - Local Network Usage Description) and NSBonjourServices (Bonjour services) in Info.plist.

    5.Set the text value required in your app in NSLocalNetworkUsageDescription.

    6.Set the following values in NSBonjourServices: _pdl-datastream._tcp_printer._tcp_ipp._tcp.

    7.Target->Build Settings->Preprocessor Macros->WLAN_ONLY(If you didn't set this, you will get header not found error. This is not mentioned in documentation).

    8.Put the PrinterList.plist(you can find this in sample project) file at any location.While searching for the printers you need to set printerslist on BRLMNetworkSearchOption.