二进制文件因为符号链接无效而被拒绝,有什么想法吗?

Binary rejected because invalid symlink, any ideas?

我不确定在这里问这个问题是否合适,如果我用错了部分,我深表歉意。我们在将我们的应用程序提交到 iTunes Connect 时遇到问题,我们收到的电子邮件说:

Invalid Symlink - Your package contains a symbolic link 'PlugIns/$REDACTED_WATCHKIT_EXTENSION_TARGET_NAME$.appex/$REDACTED_WATCHKIT_EXTENSION_TARGET_NAME$.appex' which resolves to a location '/Users/$REDACTED_USER$/Library/Developer/Xcode/DerivedData/Seta-ctfzptralingvtbxhssdlkkzkclw/Build/Intermediates/ArchiveIntermediates/Seta/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/$REDACTED_WATCHKIT_EXTENSION_TARGET_NAME$.appex' that does not exist or is outside of the package.

我试图通过创建一个与我们的项目具有相同设置的空白 Xcode 项目来重现错误,但我无法从 iTunes Connect 中得到相同的错误。有谁知道为什么要创建该符号链接?我检查了空白的项目 .ipa,它在该路径中不包含该符号链接,所以这显然是错误的,但我找不到创建符号链接的构建 setting/configuration。

我检查了 xcodebuild 的输出,发现了这个:

SymLink build/SetaWatchKitExtension.appex /Users/$REDACTED_USER$/Library/Developer/Xcode/DerivedData/Seta-ctfzptralingvtbxhssdlkkzkclw/Build/Intermediates/ArchiveIntermediates/Seta/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/SetaWatchKitExtension.appex
    cd $REDACTED_PROJECT_PATH$
    export PATH="/Applications/Xcode-7.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-7.1.app/Contents/Developer/usr/bin:$REDACTED_PATH_ENV_VARIABLE$"
    /bin/ln -sfh /Users/$REDACTED_USER$/Library/Developer/Xcode/DerivedData/Seta-ctfzptralingvtbxhssdlkkzkclw/Build/Intermediates/ArchiveIntermediates/Seta/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/$REDACTED_WATCHKIT_EXTENSION_TARGET_NAME$.appex /Users/$REDACTED_USER$/Documents/$REDACTED_PATH$/build/$REDACTED_WATCHKIT_EXTENSION_TARGET_NAME$.appex

这似乎没问题,但不知何故符号链接最终出现在 .ipa 中,这是错误的。在 watchkit 扩展构建目标步骤期间,这发生在创建产品结构之后和 CompileSwiftSources 之前。

非常感谢任何提示或帮助。我正在使用 Xcode 7.1.

尝试直接打开您的 .xcarchive 文件(window->管理器->select 存档->右键单击->在查找器中显示)。

找到任何符号链接并尝试了解它们出现在那里的原因。

这可能是与 cocoapods 相关的问题(如果您使用的是 pods)。尝试更新 cocoapods。

我们不得不使用 DTS 票证,我们收到了 Apple 的以下回复:

Thank you for contacting Apple Developer Technical Support (DTS).

The issue seems to happen when you pass CONFIGURATION_BUILD_DIR=$PWD/build to the xcodebuild command. Instead, try removing CONFIGURATION_BUILD_DIR from the xcodebuild command, and instead, change your build location in your Workspace settings. Follow these steps:

1. In the xcodebuild command, remove CONFIGURATION_BUILD_DIR=$PWD/build
2. Open your Workspace in Xcode
3. Select File > Workspace Settings
4. Click the Advanced button
5. Select Custom > Relative to Workspace
6. Click the Done buttons

This will cause the build products to still go in your build directory, and the symlink in the WatchKit Extension is no longer created.

行得通,遗憾的是命令行工具无法应用此设置,Xcode 正在以下路径创建文件:

Project.workspace/xcuserdata/$USER.xcuserdatad/WorkspaceSettings.xcsettings

显然,您不想将该路径添加到您的 VCS,因此我为我们的 CI 创建了一个小的 ruby 脚本来添加正确的设置并避免这种情况:

settingsFilePath = "#{ENV["PWD"]}/Project.xcworkspace/xcuserdata/#{ENV["USER"]}.xcuserdatad"
FileUtils.mkpath(settingsFilePath)

settings = {'BuildLocationStyle' => 'CustomLocation', 'CustomBuildIntermediatesPath' => 'Build/Intermediates', 'CustomBuildLocationType' => 'RelativeToWorkspace', 'CustomBuildProductsPath' => 'Build/Products'}
File.open("#{settingsFilePath}/WorkspaceSettings.xcsettings", 'w') { |file| file.write(settings.to_plist) }