z***@datamind.tech
z***@datamind.tech
  • 发布:2022-08-22 17:23
  • 更新:2022-08-22 20:28
  • 阅读:338

【报Bug】云打包自动添加定位和权限

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 12.5

HBuilderX类型: 正式

HBuilderX版本号: 3.5.4

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: iphone11

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
{  
    "name" : "",  
    "appid" : "__UNI__5383017",  
    "description" : "",  
    "versionName" : "1.0.25",  
    "versionCode" : 26,  
    "transformPx" : false,  
    "app-plus" : {  
        "compatible" : {  
            "ignoreVersion" : true  
        },  
        "ios" : {  
            "UIUserInterfaceStyle" : "Automatic",  
            "urlschemewhitelist" : ""  
        },  
        "usingComponents" : true,  
        "safearea" : {  
            "bottom" : {  
                // "offset" : "auto"  
                "offset" : "none"  
            }  
        },  
        "splashscreen" : {  
            "alwaysShowBeforeRender" : true,  
            "waiting" : true,  
            "autoclose" : true,  
            "delay" : 0  
        },  
        "modules" : {},  
        "distribute" : {  
            "android" : {  
                "permissions" : [  
                    "<uses-feature android:name=\"android.hardware.camera\"/>",  
                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",  
                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",  
                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",  
                    "<uses-permission android:name=\"android.permission.READ_CALENDAR\"/>",  
                    "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",  
                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",  
                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",  
                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",  
                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",  
                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"  
                ],  
                "autoSdkPermissions" : false,  
                "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]  
            },  
            "ios" : {  
                "privacyDescription" : {  
                    "NSPhotoLibraryUsageDescription" : "该应用需要读取你的相册,以便为上传农事操作图片",  
                    "NSPhotoLibraryAddUsageDescription" : "该应用需要读取你的相册,以便拍照保存图片",  
                    "NSCameraUsageDescription" : "该应用需要你的相机,以便你拍摄农事操作照片信息"  
                },  
                "dSYMs" : false,  
                "idfa" : false  
            },  
            "icons" : {  
                "android" : {  
                    "hdpi" : "unpackage/res/icons/72x72.png",  
                    "xhdpi" : "unpackage/res/icons/96x96.png",  
                    "xxhdpi" : "unpackage/res/icons/144x144.png",  
                    "xxxhdpi" : "unpackage/res/icons/192x192.png"  
                },  
                "ios" : {  
                    "appstore" : "unpackage/res/icons/1024x1024.png",  
                    "ipad" : {  
                        "app" : "unpackage/res/icons/76x76.png",  
                        "app@2x" : "unpackage/res/icons/152x152.png",  
                        "notification" : "unpackage/res/icons/20x20.png",  
                        "notification@2x" : "unpackage/res/icons/40x40.png",  
                        "proapp@2x" : "unpackage/res/icons/167x167.png",  
                        "settings" : "unpackage/res/icons/29x29.png",  
                        "settings@2x" : "unpackage/res/icons/58x58.png",  
                        "spotlight" : "unpackage/res/icons/40x40.png",  
                        "spotlight@2x" : "unpackage/res/icons/80x80.png"  
                    },  
                    "iphone" : {  
                        "app@2x" : "unpackage/res/icons/120x120.png",  
                        "app@3x" : "unpackage/res/icons/180x180.png",  
                        "notification@2x" : "unpackage/res/icons/40x40.png",  
                        "notification@3x" : "unpackage/res/icons/60x60.png",  
                        "settings@2x" : "unpackage/res/icons/58x58.png",  
                        "settings@3x" : "unpackage/res/icons/87x87.png",  
                        "spotlight@2x" : "unpackage/res/icons/80x80.png",  
                        "spotlight@3x" : "unpackage/res/icons/120x120.png"  
                    }  
                }  
            },  
            "splashscreen" : {  
                "android" : {  
                    "hdpi" : "",  
                    "xhdpi" : "",  
                    "xxhdpi" : ""  
                },  
                "ios" : {  
                    "iphone" : {  
                        "portrait-896h@3x" : "",  
                        "landscape-896h@3x" : "",  
                        "portrait-896h@2x" : "",  
                        "landscape-896h@2x" : "",  
                        "iphonex" : "",  
                        "iphonexl" : "",  
                        "retina55" : "",  
                        "retina55l" : "",  
                        "retina47" : "",  
                        "retina47l" : "",  
                        "retina40l" : "",  
                        "retina40" : "",  
                        "retina35" : ""  
                    },  
                    "ipad" : {  
                        "portrait-1366h@2x" : "",  
                        "landscape-1366h@2x" : "",  
                        "portrait-1194h@2" : "",  
                        "landscape-1194h@2x" : "",  
                        "portrait-1112h@2x" : "",  
                        "landscape-1112h@2x" : "",  
                        "portrait-retina7" : "",  
                        "landscape-retina7" : "",  
                        "portrait7" : "",  
                        "landscape7" : "",  
                        "portrait-1194h@2x" : ""  
                    }  
                },  
                "iosStyle" : "common",  
                "androidStyle" : "common"  
            }  
        }  
    },  
    "uni-app" : {  
        "scripts" : {  
            "h5-weixin" : {  
                "title" : "微信服务号",  
                "BROWSER" : "Chrome",  
                "env" : {  
                    "UNI_PLATFORM" : "h5"  
                },  
                "define" : {  
                    "H5-WEIXIN" : true  
                }  
            }  
        }  
    },  
    "quickapp" : {},  
    "mp-weixin" : {  
        "usingComponents" : true,  
        "appid" : "",  
        "setting" : {  
            "urlCheck" : true,  
            "minified" : true,  
            "postcss" : true,  
            "es6" : true  
        },  
        "permission" : {}  
    },  
    "h5" : {  
        "router" : {  
            "mode" : "history",  
            "base" : ""  
        },  
        "async" : {  
            "loading" : "AsyncLoading",  
            "error" : "AsyncError",  
            "delay" : 200,  
            "timeout" : 10000  
        },  
        "domain" : "",  
        "title" : "UNI办公"  
    },  
    "mp-qq" : {  
        "setting" : {  
            "minified" : true  
        },  
        "appid" : "111057700"  
    },  
    "locale" : "zh-Hans",  
    "fallbackLocale" : "zh-Hans"  
}  

操作步骤:

点击云打包

预期结果:

预期plist不会出现定位等权限

实际结果:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>运行期&后台运行时访问位置信息</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>后台运行访问位置信息</string>
<key>NSLocationUsageDescription</key>
<string>访问位置信息</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>运行期访问位置信息</string>
<key>NSMicrophoneUsageDescription</key>
<string>使用麦克风</string>
<key>NSMotionUsageDescription</key>
<string>使用传感器</string>

bug描述:

检查过manifest.json和代码,没有用到定位相关的api,但是云打包后查看plist自动添加了相关权限

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>      
<string>运行期&amp;后台运行时访问位置信息</string>      
<key>NSLocationAlwaysUsageDescription</key>      
<string>后台运行访问位置信息</string>      
<key>NSLocationUsageDescription</key>      
<string>访问位置信息</string>      
<key>NSLocationWhenInUseUsageDescription</key>      
<string>运行期访问位置信息</string>      
<key>NSMicrophoneUsageDescription</key>      
<string>使用麦克风</string>      
<key>NSMotionUsageDescription</key>      
<string>使用传感器</string>
2022-08-22 17:23 负责人:无 分享
已邀请:
DCloud_iOS_WZT

DCloud_iOS_WZT

基础模块有判断定位权限的api,所以打包会携带相关权限。这边有遇到什么问题吗

  • z***@datamind.tech (作者)

    感谢您的回复,我这边仔细排查了代码,没有调用location相关的api。不知道哪个包会引起相关权限的调用。我的appid是5383017,可否通过打包日志排查?

    2022-08-22 20:52

  • DCloud_iOS_WZT

    回复 z***@datamind.tech: 不用排查了,uni基础模块目前依赖这些权限

    2022-08-23 10:49

  • 5***@qq.com

    回复 DCloud_iOS_WZT:

    2022-09-01 22:40

该问题目前已经被锁定, 无法添加新回复