如何将Info.plist文件添加到Xcode for admob,error我添加后产生多个命令

uz75evzq  于 2023-08-07  发布在  其他
关注(0)|答案(3)|浏览(126)

多个命令生成'/Users/gan/Library/Developer/Xcode/DerivedData/xx-fpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'
目标'xx'(项目'xx')具有从'/Users/gan/Downloads/xx/Info.plist'到'/Users/gan/Library/Developer/Xcode/DerivedData/x-xfpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'目标'xx'(项目'xx')具有输出为'/Users/gan/Library/Developer/Xcode/DerivedData/xx-fpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'的进程命令
x1c 0d1x的数据
文件内容为:

<?xml version="1.0" encoding="UTF-8"?>
<!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>GADApplicationIdentifier</key>
    <string>ca-app-pub-3940256099942544~1458002511</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>SKAdNetworkItems</key>
    <array>
        <dict>
            <key>SKAdNetworkIdentifier</key>
            <string>cstr6suwn9.skadnetwork</string>
        </dict>
    </array>
    <key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <true/>
    </dict>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UILaunchScreen</key>
    <dict/>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

字符串
在我删除了构建规则设置中的Info.plist后,它出现了以下错误:* 由于未捕获的异常“GADInvalidInitializationException”而终止应用,原因:'Google移动的Ads SDK初始化时没有应用程序ID。Google AdMob发布者,请按照https://googlemobileadssdk.page.link/admob-ios-update-plist中的说明设置有效的应用程序ID。Google Ad Manager发布商,请按照https://googlemobileadssdk.page.link/ad-manager-ios-update-plist上的说明操作
下面是我的代码:

import SwiftUI
import GoogleMobileAds

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        GADMobileAds.sharedInstance().start(completionHandler: nil)
        return true
    }
}

@main
struct CatAPIProjectApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

qojgxg4l

qojgxg4l1#

解决方法是删除这个文件,项目中有一个原始的Info.plist,我们看不到这个文件,只需在“Info”配置中编辑,按“+”添加。

的数据

djmepvbi

djmepvbi2#

Multiple commands produce ... info.plist表示目标中存在重复的info.plist文件。主要有两个原因和解决方案:
1.如果它们使用相同的info.plist,则取消选中其中一个的add to target
1.如果不相同,将它们合并到一个文件中。

注意在较新的Xcode项目中,info.plist背后的文件是隐藏的,需要通过选择项目文件->选择目标->和Info部分来更改其配置:

x1c 0d1x的数据
您也可以回退到使用文件,方法是将文件添加到项目中,并将其路径和Generate Info.plist File的默认设置更改为NO


gblwokeq

gblwokeq3#

要解决在Xcode中为AdMob添加Info.plist文件时出现的“Multiplecommandsproduce...”错误,请确保在构建规则设置中删除对Info.plist的所有引用。然后,将Info.plist文件正确地添加到项目中,并在AppDelegate中设置有效的AdMob应用程序ID。最后,清理并构建您的项目。

相关问题