How to fix the error: 'The app identifier "com.example.apple-samplecode.BreakfastFinder" cannot be registered to your development team.'

How to fix the error: 'The app identifier "com.example.apple-samplecode.BreakfastFinder" cannot be registered to your development team.'

当我尝试从 Apple 构建 BreakfastFinder 示例代码时,它会为模拟器构建它,但不会为我的 iPhone X 和 IOS 13(Public Beta 3) 构建它。

我尝试取消配对并修复设备,将标识符从 "com.example.apple-samplecode.BreakfastFinder"com.<myID>.TestApp2

从此处下载项目示例:https://developer.apple.com/documentation/vision/recognizing_objects_in_live_capture

只有在崩溃后我才更改了构建标识符。

我希望构建完成并 运行,但它给了我这些错误。 来自 Xcode 的两个错误:

  1. Failed to register bundle identifier. The app identifier "com.example.apple-samplecode.BreakfastFinder" cannot be registered to your development team. Change your bundle identifier to a unique string to try again.
  2. No profiles for 'com.example.apple-samplecode.BreakfastFinder' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.example.apple-samplecode.BreakfastFinder'.

在项目目录中,查找文件 Configuration > SampleCode.xcconfig

在那里你会看到第 13 行:

SAMPLE_CODE_DISAMBIGUATOR=${DEVELOPMENT_TEAM}

${DEVELOPMENT_TEAM}替换成你自己的队名

SAMPLE_CODE_DISAMBIGUATOR=your_team_name

对我有用

当我将其放入 SampleCode.xcconfig 文件中时,这对我有用:

SAMPLE_CODE_DISAMBIGUATOR=3323GT3XP
  • 如果你要添加 SAMPLE_CODE_DISAMBIGUATOR key 在目标的 Build Settings as a User-Defined条目,那么你不需要在SampleCode.xcconfig文件中手动添加你的开发团队 .

  • 当你selectSigning & Capabilities下的团队时,它会自动填充下的开发团队 SampleCode.xcconfig 文件.

Apple 将此方法用于示例代码。我在 Soup Chef 项目中找到了它,他们演示了如何设置 Siri 快捷方式和捐赠意图。

如果您打开 Configuration/SampleCode.xcconfig 文件,您将看到:

The SAMPLE_CODE_DISAMBIGUATOR configuration is to make it easier to build and run a sample code project. Once you set your project's development team, you'll have a unique bundle identifier. This is because the bundle identifier is derived based on the 'SAMPLE_CODE_DISAMBIGUATOR' value. Do not use this approach in your own projects—it's only useful for sample code projects because they are frequently downloaded and don't have a development team set.

你可以自己验证:例如SoupChef,SoupChef.xcodeproj/project.pbxproj包含这样的行:

PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.SoupChef${SAMPLE_CODE_DISAMBIGUATOR}";

现在,您需要查找团队。正如其他人在评论中提到的,您可以在thread.

之后查找它

据我所知,您实际上可以使用任何消歧器,唯一重要的是它对您来说是独一无二的。但是,您可能只想坚持他们的建议并查找您的团队 ID,因为它可以降低以后出现某些未知问题的风险。

请务必阅读并遵循示例代码说明中的其他说明。

我仍然需要在“签名和功能”选项卡中通过 和 select 团队,但我不必手动修改每个目标的包标识符。

在我的示例项目中,应用程序组也必须在几个目标中手动设置,并且我必须编辑 Swift 文件 Shared/Support/UserDefaults+DataSource.swift.

所有这些都更新后,我就可以在我的手机上构建并启动该应用程序 phone。