How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

huangapple go评论73阅读模式
英文:

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

问题

以下是代码部分的翻译:

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()
        }
    }
}

请注意,这只是代码的翻译,不包括任何其他内容。

英文:

>Multiple commands produce '/Users/gan/Library/Developer/Xcode/DerivedData/xx-fpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'

>Target 'xx' (project 'xx') has copy command from '/Users/gan/Downloads/xx/Info.plist' to '/Users/gan/Library/Developer/Xcode/DerivedData/x-xfpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'
Target 'xx' (project 'xx') has process command with output '/Users/gan/Library/Developer/Xcode/DerivedData/xx-fpgsryfzwqufgxcplcdfxrycppjh/Build/Products/Debug-iphonesimulator/xx.app/Info.plist'

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

The file content is:

<?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>

After I removed the Info.plist in the build rule settings, it has this error:
*** Terminating app due to uncaught exception 'GADInvalidInitializationException', reason: 'The Google Mobile Ads SDK was initialized without an application ID. Google AdMob publishers, follow instructions at https://googlemobileadssdk.page.link/admob-ios-update-plist to set a valid application ID. Google Ad Manager publishers, follow instructions at https://googlemobileadssdk.page.link/ad-manager-ios-update-plist

This is my code:

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()
        }
    }
}

答案1

得分: 1

已解决,只需删除此文件,项目中有一个原始的 Info.plist,我们无法看到该文件,只需在“Info”配置中进行编辑,按“+”添加。 How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

英文:

Solved by just remove this file, there was an original Info.plist in the project, we can't see the file, just edit in the "Info" configuration, press "+" to add. How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

答案2

得分: 0

Multiple commands produce ... info.plist 表示目标中存在重复的 info.plist 文件。因此有两个主要原因和解决方法:

  1. 如果它们使用相同的 info.plist,请取消其中一个的“添加到目标”选项。

  2. 如果它们不相同,请将它们合并成一个单一的文件。

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

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

您还可以通过将文件添加到项目并更改其路径的默认设置以及将生成 Info.plist 文件设置为“否”来回退到使用文件:

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

英文:

The Multiple commands produce ... info.plist means there are duplicate info.plist files in the target. So there are two main reason and solutions for this:

  1. Uncheck add to target for one of them if they are using a identical info.plist

  2. If don't identical, Merge them into a one single file.

Note that in the newer Xcode projects, the file behind the info.plist is hidden and you need to change the configuration of it by selecting the project file -> selecting the target -> and the Info section:

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

You can also fallback to using a file by adding it to the project and changing the default settings for the path to it and the Generate Info.plist File to NO

How to add Info.plist file to Xcode for admob, error Multiple commands produce after I added

huangapple
  • 本文由 发表于 2023年7月17日 08:53:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76700965.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定