简体   繁体   English

Xamarin.iOS绑定用于Swift库

[英]Xamarin.iOS binding for a swift library

I am creating a binding for a swift library to be used in a xamarin project. 我正在为在xamarin项目中使用的Swift库创建绑定。 When i consume the binding project in the ios project, I get the following error: 当我在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

I have added https://github.com/Flash3001/Xamarin.Swift to my project to reference swift libraries. 我已将https://github.com/Flash3001/Xamarin.Swift添加到我的项目中以引用swift库。

Have set both SmartLink and ForceLink to true 将SmartLink和ForceLink都设置为true

I have deleted the obj and bind folders in all projects. 我已经删除了所有项目中的obj和bind文件夹。 Did a clean and rebuild too. 做了一个清洁和重建。

I would appreciate any help to fix this error. 我会很乐意解决此错误。

This might not be the direct answer to your question but can definitely take you in the right direction, here is the Office UI Fabric Xamarin.iOS Swift binding project that you can use as reference, it does not use (need) the Xamarin.Swift but uses a msbuild script that uses swift-stdlib-tool which is the tool that Xcode uses to determine what swift libraries need to be bundled with your application. 这可能不是您问题的直接答案,但绝对可以将您带向正确的方向,这是Office UI Fabric Xamarin.iOS Swift绑定项目,您可以将其用作参考,它不使用(不需要) Xamarin.Swift但是使用了msbuild脚本,该脚本使用swift-stdlib-tool ,这是Xcode用来确定需要将哪些Swift库与应用程序捆绑在一起的工具。 The script [1] needs to be added to your final app .csproj as shown here . 脚本[1]需要如图所示被添加到您的最终应用的.csproj 这里

In your particular case it seems that you are missing MobiiiSDK.framework from your bundle. 在您的特定情况下,似乎您的软件包中缺少MobiiiSDK.framework

[1]: MSBuild script to bundle Swift libraries into your Xamarin iOS Application [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>

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM