首先需要在配置文件申请的时候将hotspot勾选上,之后还要在x-code里添加对应的配置,由于我们并没有用到获取设备周边Wi-Fi的功能,所以就没申请相关权限


相关连接Wi-Fi代码如下:
#import <NetworkExtension/NetworkExtension.h>
//无密码初始化
NEHotspotConfiguration *hotspotConfig = [[NEHotspotConfiguration alloc]initWithSSID:@"Wi-Fi名"];
//有密码初始化
NEHotspotConfiguration *hotspotConfig = [[NEHotspotConfiguration alloc]initWithSSID:@"Wi-Fi名" passphrase:@"密码" isWEP:NO];
\[NEHotspotConfigurationManager sharedManager\]applyConfiguration:hotspotConfig completionHandler:\^(NSError \* **_Nullable** error) {
**if** (error \&\& error.code != 13 \&\& error.code != 7) {
NSLog(@"加入失败");
}**else** **if**(error.code ==7){
NSLog(@"已取消");
}**else**{
NSLog(@"已连接");
}
}\];
\[\[NEHotspotConfigurationManager sharedManager\] getConfiguredSSIDsWithCompletionHandler:\^(NSArray\