Search code examples
iosswiftwifissidxcode-command-line-tools

CNCopyCurrentNetworkInfo getting nil when app is created through command line tools


My app's deployment target is iOS 13. So I am using CNCopyCurrentNetworkInfo for getting the wifi SSID information. I am facing a strange issue only when I archive and distribute my enterprise app through command line tools. The wifi SSID info is always getting nil when the app is created through command line tools. There are no issues when I archive the app from XCode.

Commands that I have used for creating and exporting the archive are:

  • xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyScheme archive -configuration MyConfig -sdk iphoneos -archivePath MyArchivePath CODE_SIGNING_ALLOWED=NO
  • xcodebuild -exportArchive -archivePath MyArchivePath -exportPath MyExportPath -exportOptionsPlist MyExportOptionPlist

Note: I have added all the necessary entitlements and other info for the ssid access like

  • Privacy - Location When In Use Usage Description
  • Access WiFi Information in entitlements

Solution

  • Dropping the CODE_SIGNING_ALLOWED=NO option fixed my problem. I got the solution from the developer portal.