xcode xcodebuild 不从 .app 复制文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23682083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xcodebuild not copying file from .app
提问by user1366911
I've created a signed .xcarchive file using the xcodebuild command.
我已经使用 xcodebuild 命令创建了一个签名的 .xcarchive 文件。
Inside the .xcarchive is a .app file. Inside the .app is a file called archived-expanded-entitlements.xcent. This file is the key to my problem.
在 .xcarchive 里面是一个 .app 文件。.app 中有一个名为archived-expanded-entitlements.xcent 的文件。这个文件是我问题的关键。
I run a different xcodebuild command that creates an .IPA file from the .xcarchive.
我运行了一个不同的 xcodebuild 命令,该命令从 .xcarchive 创建了一个 .IPA 文件。
Creating the IPA fails because the archived-expanded-entitlements.xcent file is missing. The thing is, xcodebuild is creating a temporary directory where it copies over my .app file, and inside THAT .app file, there is no archived-expanded-entitlements.xcent file.
创建 IPA 失败,因为 archived-expanded-entitlements.xcent 文件丢失。问题是,xcodebuild 正在创建一个临时目录,它会在其中复制我的 .app 文件,并且在那个 .app 文件中,没有 archived-expanded-entitlements.xcent 文件。
All the other files are in there except this one.
除了这个文件之外,所有其他文件都在那里。
The commands I run are below:
我运行的命令如下:
This creates the xcarchive:
这将创建 xcarchive:
xcodebuild -project diplomat.xcodeproj -scheme schemeName archive -archivePath /Path/To/Archive/name.xcarchive -configuration AppStore CODE_SIGN_IDENTITY="identity" PROVISIONING_PROFILE=provProfile
This creates the IPA:
这将创建 IPA:
xcodebuild -exportArchive -exportFormat IPA -archivePath /Path/To/Archive/name.xcarchive -exportPath /Path/To/Archive/name.ipa
Despite specifying the location of the .xcarchive, it creates a temporary directory and doesn't include the important file. Please note, the archived-expanded-entitlements.xcent file is created during the .xcarchive process (the first command that's run) and fails to copy into the temp directory during the second command run.
尽管指定了 .xcarchive 的位置,但它会创建一个临时目录并且不包含重要文件。请注意,archived-expanded-entitlements.xcent 文件是在 .xcarchive 进程(运行的第一个命令)期间创建的,并且在第二个命令运行期间无法复制到临时目录中。
This is the exact error. Google and StackOverflow have yielded similar errors, but nothing with this actual problem.
这是确切的错误。谷歌和 StackOverflow 产生了类似的错误,但没有解决这个实际问题。
Checking original app
+ /usr/bin/codesign --verify -vvvv /var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541- 42128-00007ED35037747A/name.app
Program /usr/bin/codesign returned 1 :
[/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app: a sealed resource is missing or invalid
file missing:
/private/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app/archived-expanded-entitlements.xcent
]
Codesign check fails :
/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app: a sealed resource is missing or invalid
file missing:
/private/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app/archived-expanded-entitlements.xcent
Done checking the original app
采纳答案by Yossi Shmueli
This is indeed a weird behaviour of xcodebuild, but you can still use the exportArchive command and specify the provisioning profile using exportProvisioningProfile:
这确实是 xcodebuild 的一个奇怪行为,但您仍然可以使用 exportArchive 命令并使用 exportProvisioningProfile 指定配置文件:
xcodebuild -exportArchive -exportFormat IPA \
-archivePath /Path/To/Archive/name.xcarchive \
-exportPath /Path/To/Archive/name.ipa \
-exportProvisioningProfile 'PROVISIONING_PROFILE_NAME'
This will reembed the provisioning profile within the app and you won't actually need to speciify the code signing identity again, because the archive should already be signed during the archive process.
这将在应用程序中重新嵌入配置文件,您实际上不需要再次指定代码签名身份,因为在存档过程中应该已经对存档进行了签名。
回答by user1366911
My answer would be considered a workaround, but it solved the problem. I do not know why the one file was not being copied over, but I found a way so it wasn't important.
我的答案将被视为一种解决方法,但它解决了问题。我不知道为什么一个文件没有被复制,但我找到了一种方法,所以它并不重要。
Replace the 2nd xcodebuild command with this, which utilizes xcrun:
使用 xcrun 替换第二个 xcodebuild 命令:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v /Path/To/Archive/name.xcarchive/Products/Applications/name.app -o /Path/To/Archive/DiplomatStaples.ipa --sign "identity" - -embed "provProfile"
This creates an IPA using the xcarchive and then re-embeds the identity and the provisioning profile, so even though the same error as above still occurs and is printed out,the "double dip" with the code signing identity and provisioning profile makes it meaningless. I can now install the app on devices.
这将使用 xcarchive 创建一个 IPA,然后重新嵌入身份和配置文件,因此即使仍然出现与上述相同的错误并被打印出来,代码签名身份和配置文件的“双浸”使其毫无意义. 我现在可以在设备上安装该应用程序。
For inquiring minds: The reason I'm not just using xcrun in the first place is because even if I specify a prov profile and signing identity, xcrun will use the embedded profile and signing identity in the project based on the configuration (Debug, AppStore, Release, etc) that I specify. xcodebuild will actually sign with the certs I provide it.
求问:一开始我之所以不只使用xcrun,是因为即使我指定了prov profile和signing identity,xcrun也会根据配置(Debug、AppStore)使用项目中嵌入的profile和签名标识、发布等),我指定。xcodebuild 实际上会使用我提供的证书进行签名。
The goal of this operation was to remove the need for provisioning profile certs that the CI system required from developer machines, enabling testing the "AppStore" configuration to be signed with AdHoc distribution certs, and enabling re-signing of the xcarchive later on with the actual App Store distribution certs.
此操作的目标是消除对 CI 系统从开发人员机器所需的配置文件证书的需求,启用测试“AppStore”配置以使用 AdHoc 分发证书签名,并允许稍后使用实际的 App Store 分发证书。