Xamarin - 在引用Objective-C Binding时无法构建App

时间:2014-01-27 20:53:29

标签: objective-c xamarin.ios xamarin

这是我的构建错误(启用-v -v -v):

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  -ObjC -lsqlite3 -lc++ -Wl,-pie  -miphoneos-version-min=5.0 -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk  /MyPath/obj/iPhone/Debug/mtouch-cache/MyApp.exe.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.XNA.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoGame.Framework.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/OpenTK.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Core.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Xml.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Runtime.Serialization.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.Core.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoTouch.FacebookConnect.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Microsoft.WindowsAzure.Storage.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Xml.Linq.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/GoogleAnalytics.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Microsoft.WindowsAzure.Messaging.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoTouch.Dialog-1.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Json.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Newtonsoft.Json.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.GooglePlay.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/PlayGameServices.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.Tapjoy.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Tapjoy.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/main.armv7.o -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libFacebookSDK.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libarclite.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libGoogleAnalytics.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/WindowsAzureMessaging.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/PlayGameServices.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/GooglePlus.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/GoogleOpenSource.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/TapjoyPublisherLibrary.a -o /MyPath/bin/iPhone/Debug/MyAppiOS.app/MyApp -framework CFNetwork -framework AVFoundation -framework Accelerate -framework AddressBook -framework AudioToolbox -framework QuartzCore -framework CoreBluetooth -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework Foundation -framework GameKit -framework ImageIO -framework MobileCoreServices -framework Security -framework SystemConfiguration -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework StoreKit -framework AssetsLibrary -framework CoreTelephony -framework EventKit -framework EventKitUI -framework CoreMotion -framework GLKit -framework iAd -framework MapKit -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Twitter -framework UIKit -framework AddressBookUI -framework ExternalAccessory -framework QuickLook -weak_framework Social -weak_framework PassKit -weak_framework SpriteKit -weak_framework JavaScriptCore -weak_framework MultipeerConnectivity -weak_framework GameController -weak_framework MediaAccessibility -weak_framework SafariServices -weak_framework AdSupport -weak_framework Accounts -lz -liconv -u _mono_pmip -u _xamarin_init_nsthread -u _xamarin_get_block_descriptor -u _monotouch_get_locale_country_code -u _monotouch_log -u _monotouch_start_wwan -u _monotouch_timezone_get_data -u _monotouch_timezone_get_names -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonosgen-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-sgen-debug.a
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  -ObjC -lsqlite3 -lc++ -Wl,-pie  -miphoneos-version-min=5.0 -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk  /MyPath/obj/iPhone/Debug/mtouch-cache/MyApp.exe.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.XNA.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoGame.Framework.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/OpenTK.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Core.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Xml.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Runtime.Serialization.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.Core.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoTouch.FacebookConnect.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Microsoft.WindowsAzure.Storage.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Xml.Linq.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/GoogleAnalytics.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Microsoft.WindowsAzure.Messaging.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/MonoTouch.Dialog-1.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/System.Json.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Newtonsoft.Json.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.GooglePlay.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/PlayGameServices.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Blendgine.Tapjoy.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/Tapjoy.dll.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /MyPath/obj/iPhone/Debug/mtouch-cache/main.armv7.o -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libFacebookSDK.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libarclite.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/libGoogleAnalytics.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/WindowsAzureMessaging.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/PlayGameServices.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/GooglePlus.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/GoogleOpenSource.a -force_load /MyPath/obj/iPhone/Debug/mtouch-cache/TapjoyPublisherLibrary.a -o /MyPath/bin/iPhone/Debug/MyAppiOS.app/MyApp -framework CFNetwork -framework AVFoundation -framework Accelerate -framework AddressBook -framework AudioToolbox -framework QuartzCore -framework CoreBluetooth -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework Foundation -framework GameKit -framework ImageIO -framework MobileCoreServices -framework Security -framework SystemConfiguration -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework StoreKit -framework AssetsLibrary -framework CoreTelephony -framework EventKit -framework EventKitUI -framework CoreMotion -framework GLKit -framework iAd -framework MapKit -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Twitter -framework UIKit -framework AddressBookUI -framework ExternalAccessory -framework QuickLook -weak_framework Social -weak_framework PassKit -weak_framework SpriteKit -weak_framework JavaScriptCore -weak_framework MultipeerConnectivity -weak_framework GameController -weak_framework MediaAccessibility -weak_framework SafariServices -weak_framework AdSupport -weak_framework Accounts -lz -liconv -u _mono_pmip -u _xamarin_init_nsthread -u _xamarin_get_block_descriptor -u _monotouch_get_locale_country_code -u _monotouch_log -u _monotouch_start_wwan -u _monotouch_timezone_get_data -u _monotouch_timezone_get_names -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonosgen-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-sgen-debug.a
Undefined symbols for architecture armv7:
  "_EVP_add_alg_module", referenced from:
      _OPENSSL_load_builtin_modules in PlayGameServices.a(conf_mall.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error MT5210: Native linking failed, undefined symbol: _EVP_add_alg_module. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
error MT5202: Native linking failed. Please review the build log.

所以我的绑定项目添加了三个* .a库。以下是我设置的LinkWith属性的示例(我对所有三个属性都做了相同的操作,但当然使用了不同的.a文件):

[assembly: LinkWith ("PlayGameServices.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, 
    Frameworks = "AddressBook AssetsLibrary CoreData CoreGraphics CoreLocation CoreMotion CoreText Foundation MediaPlayer QuartzCore Security SystemConfiguration UIKit", LinkerFlags = "-lc++", IsCxx = true,
    ForceLoad = true)]

以下是该库的示例Xcode项目的屏幕截图,其中包含框架列表:

frameworks

我确定不需要XCTest。我错过了什么?

1 个答案:

答案 0 :(得分:6)

部分原因是它不提供二进制API兼容性,您的代码(或库)无法绑定到iOS安装的 openssl 版本(即它是私有库)。

一些图书馆通常会包含他们自己的openssl副本。

从上面我的 guess ForceLoad正在加载所有内容(按要求),但静态库(PlayGameServices.a)可能缺少某些符号。如果未加载所有内容(即没有ForceLoad),则可能不会报告此类错误。要对此进行测试,您可以尝试使用forceload进行ObjC。

您可能还想尝试使用SmartLink = true并设置ForceLoad = false。这应该会减少您的应用程序大小,因为它不会加载每个符号,可能会解决静态库中的问题(缺少符号)。