我正在为在xamarin项目中使用的Swift库创建绑定。当我在ios项目中使用绑定项目时,出现以下错误:
Dyld Error Message:
Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from:
/Users/USER/Library/Developer/CoreSimulator/Devices/73CDF7FB-D700-4F35-
AB8B-DD7F7B134C1E/data/Containers/Bundle/Application/9FB74CDE-93C3-
4EB7-9833- FA060281CE46/XXXXXXXX.iOS.app/Frameworks/MobiiiSDK.framework/MobiiiSDK
Reason: image not found
我已将https://github.com/Flash3001/Xamarin.Swift添加到项目中以引用Swift库。
已将SmartLink和ForceLink都设置为true
我已删除所有项目中的obj和bind文件夹。也进行了清理和重建。
我希望能帮助您解决此错误。
答案 0 :(得分:1)
这可能不是您问题的直接答案,但绝对可以将您带向正确的方向,这里是Office UI Fabric Xamarin.iOS Swift绑定项目,您可以将其用作参考,它不会使用(需要)Xamarin.Swift,但使用了一个使用swift-stdlib-tool
的msbuild脚本,该脚本是Xcode用来确定需要将哪些Swift库与应用程序捆绑在一起的工具。脚本[1]需要添加到最终应用程序.csproj中,如here所示。
在您的特定情况下,看来您的捆绑包中缺少MobiiiSDK.framework
。
[1]:MSBuild脚本将Swift库捆绑到您的Xamarin iOS应用程序中
<PropertyGroup>
<_SwiftySwiftMasterAfterTargets>_CodesignNativeLibraries</_SwiftySwiftMasterAfterTargets>
<_SwiftySwiftMasterDependsOnTargets>_SwiftySwiftCopySwiftDependencies</_SwiftySwiftMasterDependsOnTargets>
<_XcodeToolChainRelativeToSdkRoot>/../../../../../Toolchains/XcodeDefault.xctoolchain/</_XcodeToolChainRelativeToSdkRoot>
<_TargetPlatform Condition=" '$(Platform)' == 'iPhoneSimulator' ">iphonesimulator</_TargetPlatform>
<_TargetPlatform Condition=" '$(Platform)' == 'iPhone' ">iphoneos</_TargetPlatform>
<_SwiftySwiftRemoteMirror Condition=" '$(Configuration)' != 'Debug' "></_SwiftySwiftRemoteMirror>
<_SwiftySwiftRemoteMirror Condition=" '$(Configuration)' == 'Debug' ">--resource-library libswiftRemoteMirror.dylib</_SwiftySwiftRemoteMirror>
</PropertyGroup>
<Target Name="_SwiftySwiftMasterTarget" Condition="'$(_SwiftySwiftMasterDependsOnTargets)'!=''" AfterTargets="$(_SwiftySwiftMasterAfterTargets)" DependsOnTargets="$(_SwiftySwiftMasterDependsOnTargets);_DetectSigningIdentity" />
<Target Name="_SwiftySwiftCopySwiftDependencies" Condition="!Exists('$(_AppBundlePath)Frameworks/libswiftCore.dylib')">
<Message Text="Copying Swift Frameworks dependencies for $(_NativeExecutable) to the $(_AppBundlePath)Frameworks folder." />
<Exec Condition="'$(_CodeSigningKey)' != ''" SessionId="$(BuildSessionId)" Command="$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)usr/bin/swift-stdlib-tool --copy --verbose --sign '$(_CodeSigningKey)' --scan-executable '$(_NativeExecutable)' --scan-folder '$(_AppBundlePath)Frameworks/' --scan-folder '$(_AppBundlePath)PlugIns/' --platform '$(_TargetPlatform)' --toolchain '$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)' --destination '$(_AppBundlePath)Frameworks/' $(_SwiftySwiftRemoteMirror) --unsigned-destination '$(DeviceSpecificIntermediateOutputPath)/SwiftSupport' --strip-bitcode --strip-bitcode-tool '$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)usr/bin/bitcode_strip' --emit-dependency-info '$(DeviceSpecificIntermediateOutputPath)/SwiftStdLibToolInputDependencies.dep'" />
<Exec Condition="'$(_CodeSigningKey)' == ''" SessionId="$(BuildSessionId)" Command="$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)usr/bin/swift-stdlib-tool --copy --verbose --scan-executable '$(_NativeExecutable)' --scan-folder '$(_AppBundlePath)Frameworks/' --scan-folder '$(_AppBundlePath)PlugIns/' --platform '$(_TargetPlatform)' --toolchain '$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)' --destination '$(_AppBundlePath)Frameworks/' $(_SwiftySwiftRemoteMirror) --unsigned-destination '$(DeviceSpecificIntermediateOutputPath)/SwiftSupport' --strip-bitcode --strip-bitcode-tool '$(_SdkRoot)$(_XcodeToolChainRelativeToSdkRoot)usr/bin/bitcode_strip' --emit-dependency-info '$(DeviceSpecificIntermediateOutputPath)/SwiftStdLibToolInputDependencies.dep'" />
</Target>
<Target Name="_SwiftySwiftCopySwiftSupport" Condition="'$(ArchiveOnBuild)'=='true'" AfterTargets="Archive">
<Message Text="Copying SwiftSupport folder from $(DeviceSpecificIntermediateOutputPath)/SwiftSupport to $(ArchiveDir)/SwiftSupport folder." />
<Ditto
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(DittoExe)"
ToolPath="$(DittoPath)"
Source="$(DeviceSpecificIntermediateOutputPath)/SwiftSupport"
Destination="$(ArchiveDir)/SwiftSupport" />
</Target>
希望这会有所帮助。