将一个名为”dext”的文件与Xamarin一起打包到iOS的.ipa文件中。

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

Bundling a dext into an iOS .ipa with Xamarin

问题

我有一个项目,它需要经过两个步骤才能构建iOS应用程序。首先是在XCode中构建的本机库和.dext文件,然后将它们链接到Xamarin项目中,我使用VisualStudio Build在C#上完成应用程序的构建。在Xamarin项目中链接静态库很简单,将.dext嵌入到仅在XCode中的其他本机应用程序中也很简单,但我不确定如何将.dext嵌入到Xamarin项目应用程序中。

您是否可以将.dext包中的所有文件(嵌入式配置文件、CodeSignature、Info.plist和构建的驱动程序)都捆绑到.ipa文件中的SystemExtension文件夹中,只需在Xamarin csproj中使用BundleResource?似乎没有办法从Xcode构建中获取已签名的.dext包;特定于驱动程序的dext的“复制文件”中的“复制时签名”复选框存在问题。

英文:

I have an project that takes a two-step process to build an iOS app. There's the native libraries and .dext built in XCode, and then those are linked to a Xamarin project that I use to finish building the app in C# on VisualStudio build. It's simple to link the static libraries in the Xamarin project, and it's simple to embed the .dext to some other native-only app that just in XCode, but I'm not sure how to embed the .dext in the Xamarin project app.

Can you just BundleResource in the Xamarin csproj all of the files in the .dext package (embedded profile, CodeSignature, Info.plist, and the built driver) into a SystemExtension folder in the .ipa? There doesn't seem to be a way to get the signed .dext package from the Xcode build either; the Copy Files "Code Sign On Copy" checkbox is broken for specifically driver dexts.

答案1

得分: 1

我不了解Xamarin,但我可以回答你问题的一部分:

> 似乎没有办法从Xcode构建中获取已签名的.dext包;“复制文件”中的“在复制时签名”复选框仅适用于驱动程序dext。

这是因为你真的不想使用与应用相同的代码签名设置对dext进行签名。它有自己的应用程序ID、权限和相应的配置文件。然而,禁用的复选框仅表示dext在嵌入应用程序时应该已经预先签名。如果你在Xcode/xcodebuild中单独构建dext目标,它应该已经被签名了 - 如果不是这种情况,那么你的dext目标配置可能有问题。

“复制文件”步骤是将项目复制到目标捆绑包之前的操作,而不是将构建的目标复制到其他地方。选项“在复制时签名”会单独为被复制的项目签名,还会在最后对整个捆绑包进行签名。因此,这不适合在构建过程中将构建和签名的dext复制到特定位置的机制。

嵌入dext所需的一切应该是将其复制到应用程序捆绑包的正确位置,然后正常签名应用程序(可能使用communicates-with-drivers权限)。

我不能告诉你如何在Xamarin中完成这个过程,具体来说。然而,我的建议可能是将xcodebuild install步骤作为Xamarin应用程序构建的一部分。这个“安装”目标在构建和签名后,会放置到$DSTROOT/$INSTALL_PATH中。这些变量是Xcode构建设置,可以在.xcodeproj/project.pbxproj中的每个项目/目标/配置或者在xcodebuild命令行上显式设置。如果你将DSTROOT设置为Xamarin将查找要捆绑到应用程序的项目的基本目录,将INSTALL_PATH设置为Library/SystemExtensions,如果我理解正确的话,这应该解决了你的问题。

我相信在iPadOS上,dext需要有一个以应用程序ID的捆绑包ID开头的要求,例如:如果应用程序的捆绑标识符是com.example.apps.myapp,那么类似com.example.apps.myapp.drivername的捆绑包ID。Xcode通常会为你强制执行这一点,但如果你是手动组装捆绑包,就没有什么可以检查这一点的。

英文:

I don't know about Xamarin, but I can answer parts of your question:

> There doesn't seem to be a way to get the signed .dext package from the Xcode build either; the Copy Files "Code Sign On Copy" checkbox is broken for specifically driver dexts.

This is because you really don't want to sign the dext with the same code signing setup as the app. It has its own app ID, entitlements, and corresponding provisioning profile. However, the disabled tickbox just means the dext should already be pre-signed when it comes to embedding it in the app. If you build the dext target on its own in Xcode/xcodebuild, it should already come out signed - if that's not the case, your dext target is misconfigured.

The "copy files" step is for copying items into the target bundle before it's signed, not for copying the built target elsewhere. The "code sign on copy" option individually signs the item(s) copied in, in addition to the whole bundle being signed at the end. So this isn't suitable as a mechanism for copying the built and signed dext into a specific place during your build.

All that is needed to embed the dext should be to copy it into the correct location in your app's bundle, and then sign the app normally (probably with the communicates-with-drivers entitlement).

I can't tell you how that's done with Xamarin, specifically. However, my recommendation would perhaps be an xcodebuild install step for your dext as part of your Xamarin app build. This "installs" the target after build+sign, into $DSTROOT/$INSTALL_PATH. Those variables are Xcode build settings, and can be set per project/target/configuration in the .xcodeproj/project.pbxproj or explicitly on the xcodebuild command line. If you make the DSTROOT a base directory of where Xamarin will look for items to bundle into the app, and the INSTALL_PATH the Library/SystemExtensions, that should solve your problem if I've understood correctly.

I believe on iPadOS there is also a requirement that the dext has a bundle ID that starts with the app ID's bundle ID, so something like: com.example.apps.myapp.drivername if the app's bundle identifier is com.example.apps.myapp. Xcode normally enforces this for you, but if you're assembling your bundle "by hand" there's nothing to check this.

答案2

得分: 1

是的,我可以使用BundleResources将.dext复制到.ipa的SystemExtensions目录中。

我遇到的问题是Xamarin还有OptimizePropertyLists属性,它会混淆捆绑的.dext的Info.plist并使其无法安装。必须在Xamarin应用的构建项目中将该属性设置为false。

英文:

Yes, I can use the BundleResources to copy in the .dext into the .ipa's SystemExtensions directory.

The issue I was facing is that Xamarin also has the OptimizePropertyLists property, which will scramble the bundled .dext's Info.plist and make it unable to install. That property needs to be set false on the Xamarin app's build project.

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

发表评论

匿名网友

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

确定