I am creating a .NET library that ought to work on Android, iOS, and desktop OSs. It really works nice in all places — besides iOS. In actual fact on iOS I had it working for native deployment, however the Apple Retailer rejected an app primarily based on it as a result of the native dependency should be in an Apple “Framework”.
So I did a bunch of analysis and discovered about frameworks an xcframeworks, and refactored my nupkg to ship the native dependency inside an xcframework construction. With that, the iOS csproj builds and seems to deploy each the .NET meeting and its native dependency with the app, however the app now throws DllNotFoundException
when it makes an attempt to load that native dependency.
The Visible Studio debug output window has solely this on the issue:
**System.DllNotFoundException:** 'nerdbank_qrcodes'
How can I debug into this?
Or alternatively, what am I doing mistaken? Right here is the structure of my nupkg:
D:PACKAGESNUGETNERDBANK.QRCODES .2.55-BETA-G209A879921
| .nupkg.metadata
| nerdbank.qrcodes.0.2.55-beta-g209a879921.nupkg
| nerdbank.qrcodes.0.2.55-beta-g209a879921.nupkg.sha512
| nerdbank.qrcodes.nuspec
| README.md
| THIRD_PARTY_DEPENDENCIES.txt
| THIRD_PARTY_LICENSES.yml
|
+---lib
| +---net8.0
| | Nerdbank.QRCodes.dll
| | Nerdbank.QRCodes.xml
| |
| +---net8.0-ios17.5
| | | Nerdbank.QRCodes.dll
| | | Nerdbank.QRCodes.xml
| | |
| | ---Nerdbank.QRCodes.sources
| | | manifest
| | |
| | ---nerdbank_qrcodes.xcframework
| | | Information.plist
| | |
| | +---ios-arm64
| | | ---nerdbank_qrcodes.framework
| | | Information.plist
| | | nerdbank_qrcodes
| | |
| | ---ios-arm64_x86_64-simulator
| | ---nerdbank_qrcodes.framework
| | Information.plist
| | nerdbank_qrcodes
| |
| ---net8.0-windows7.0
| Nerdbank.QRCodes.dll
| Nerdbank.QRCodes.xml
|
---runtimes
+---android-arm64
| ---native
| libnerdbank_qrcodes.so
|
+---android-x64
| ---native
| libnerdbank_qrcodes.so
|
+---linux-arm64
| ---native
| libnerdbank_qrcodes.so
|
+---linux-x64
| ---native
| libnerdbank_qrcodes.so
|
+---osx-arm64
| ---native
| libnerdbank_qrcodes.dylib
|
+---osx-x64
| ---native
| libnerdbank_qrcodes.dylib
|
+---win-arm64
| ---native
| nerdbank_qrcodes.dll
|
---win-x64
---native
nerdbank_qrcodes.dll
The native framework dll’s are specifically ready utilizing lipo
and install_name_tool
and chmod
as follows:
# copy Information.plist and the binary into the suitable .framework listing construction
# in order that when NativeBindings.targets references it with ResolvedFileToPublish, will probably be handled appropriately.
$RustTargetBaseDir = "$repoRoot/src/nerdbank-qrcodes/goal"
$RustDylibFileName = "libnerdbank_qrcodes.dylib"
$DeviceRustOutput = "$RustTargetBaseDir/aarch64-apple-ios/$Configuration/$RustDylibFileName"
$SimulatorX64RustOutput = "$RustTargetBaseDir/x86_64-apple-ios/$Configuration/$RustDylibFileName"
$SimulatorArm64RustOutput = "$RustTargetBaseDir/aarch64-apple-ios-sim/$Configuration/$RustDylibFileName"
$DeviceFrameworkDir = "$repoRoot/bin/$Configuration/gadget/nerdbank_qrcodes.framework"
$SimulatorFrameworkDir = "$repoRoot/bin/$Configuration/simulator/nerdbank_qrcodes.framework"
New-Merchandise -Path $DeviceFrameworkDir,$SimulatorFrameworkDir -ItemType Listing -Pressure | Out-Null
Write-Host "Making ready Apple iOS and iOS-simulator frameworks"
Copy-Merchandise $IntermediatePlistPath "$DeviceFrameworkDir/Information.plist"
Copy-Merchandise $IntermediatePlistPath "$SimulatorFrameworkDir/Information.plist"
Write-Host "Created Information.plist with model $model"
if ($IsMacOS) {
# Rename the binary that comprises the arm64 structure for gadget.
lipo -create -output $DeviceFrameworkDir/nerdbank_qrcodes $DeviceRustOutput
install_name_tool -id "@rpath/nerdbank_qrcodes.framework/nerdbank_qrcodes" "$DeviceFrameworkDir/nerdbank_qrcodes"
chmod +x "$DeviceFrameworkDir/nerdbank_qrcodes"
# Create a common binary that comprises each arm64 and x64 architectures for simulator.
lipo -create -output $SimulatorFrameworkDir/nerdbank_qrcodes $SimulatorX64RustOutput $SimulatorArm64RustOutput
install_name_tool -id "@rpath/nerdbank_qrcodes.framework/nerdbank_qrcodes" "$SimulatorFrameworkDir/nerdbank_qrcodes"
chmod +x "$SimulatorFrameworkDir/nerdbank_qrcodes"
}