gpt4 book ai didi

swift - 如何解决 NSAppleMusicUsageDescription 错误

转载 作者:行者123 更新时间:2023-12-03 20:53:08 28 4
gpt4 key购买 nike

我目前正在我自己的设备上运行我的应用程序。目标是播放本地保存在音乐应用程序中的歌曲。我导入 MediaPlayer 并尝试执行以下操作

            MPMediaLibrary.requestAuthorization { (status) in
if status == .authorized {
print("authorized")
}
}

我的 Info.plist 如下所示
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSAppleMusicUsageDescription</key>
<string>This app requires access to play music</string>
</dict>
</plist>

但是,每当我在设备上运行该应用程序时,它都会立即崩溃并给我

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSAppleMusicUsageDescription key with a string value explaining to the user how the app uses this data.



我错过了什么?

最佳答案

结果发现 Info.plist 有多个实例……我正在看目录下的那个,那个很容易被发现的。

相反,您需要通过转到顶部的项目设置-> 信息选项卡来访问正确的 plist。在那里添加它。

关于swift - 如何解决 NSAppleMusicUsageDescription 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61982490/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com