我正在尝试从我的 Xamarin 应用程序调用 Card.IO。当我尝试编译我的应用程序并在消息中引用“std::terminate()”时,我得到“架构 i386 的未定义符号: ”。该应用程序是为 iPhone 设计的,我不知道“i386”是从哪里来的——我能找到的项目选项中的所有设置都设置为 ARMv7,绑定中的 LinkWith 属性也是如此。
Card.IO 的指南指出我需要-lstdc++
在 Xcode 中添加到“其他链接器标志”,但我不知道应该将它放在 Xamarin Studio 的选项中的哪个位置
问题是:我如何使这个绑定工作?绑定有错误吗?是否有一些项目设置或以某种方式在我的应用程序中添加更多框架引用?
我使用Objective Sharpie生成下面的代码
using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace CardIO
{
[BaseType (typeof (NSObject))]
public partial interface CardIOCreditCardInfo {
[Export ("cardNumber")]
string CardNumber { get; set; }
[Export ("redactedCardNumber")]
string RedactedCardNumber { get; }
[Export ("expiryMonth")]
uint ExpiryMonth { get; set; }
[Export ("expiryYear")]
uint ExpiryYear { get; set; }
[Export ("cvv")]
string Cvv { get; set; }
[Export ("zip")]
string Zip { get; set; }
[Export ("scanned")]
bool Scanned { get; set; }
[Export ("cardType")]
CardIOCreditCardType CardType { get; }
[Static, Export ("displayStringForCardType:usingLanguageOrLocale:")]
string DisplayStringForCardType (CardIOCreditCardType cardType, string languageOrLocale);
[Static, Export ("logoForCardType:")]
NSObject LogoForCardType (CardIOCreditCardType cardType);
}
[Model]
[BaseType (typeof (NSObject))]
public partial interface CardIOPaymentViewControllerDelegate {
[Export ("userDidCancelPaymentViewController:")]
void UserDidCancelPaymentViewController (CardIOPaymentViewController paymentViewController);
[Export ("userDidProvideCreditCardInfo:inPaymentViewController:")]
void UserDidProvideCreditCardInfo (CardIOCreditCardInfo info, CardIOPaymentViewController paymentViewController);
}
[BaseType (typeof (UINavigationController))]
public partial interface CardIOPaymentViewController {
[Export ("initWithPaymentDelegate:")]
IntPtr Constructor (CardIOPaymentViewControllerDelegate aDelegate);
[Export ("initWithPaymentDelegate:scanningEnabled:")]
IntPtr Constructor (CardIOPaymentViewControllerDelegate aDelegate, bool scanningEnabled);
[Export ("appToken")]
string AppToken { get; set; }
[Export ("languageOrLocale")]
string LanguageOrLocale { get; set; }
[Export ("keepStatusBarStyle")]
bool KeepStatusBarStyle { get; set; }
[Export ("navigationBarStyle")]
UIBarStyle NavigationBarStyle { get; set; }
[Export ("navigationBarTintColor")]
UIColor NavigationBarTintColor { get; set; }
[Export ("disableBlurWhenBackgrounding")]
bool DisableBlurWhenBackgrounding { get; set; }
[Export ("collectExpiry")]
bool CollectExpiry { get; set; }
[Export ("collectCVV")]
bool CollectCvv { get; set; }
[Export ("collectZip")]
bool CollectZip { get; set; }
[Export ("showsFirstUseAlert")]
bool ShowsFirstUseAlert { get; set; }
[Export ("useCardIOLogo")]
bool UseCardIolOgo { get; set; }
[Export ("disableManualEntryButtons")]
bool DisableManualEntryButtons { get; set; }
[Export ("paymentDelegate")]
CardIOPaymentViewControllerDelegate PaymentDelegate { get; set; }
[Export ("canReadCardWithCamera")]
bool CanReadCardWithCamera { get; }
[Export ("libraryVersion")]
string LibraryVersion { get; }
}
}
我还将 Card.IO 网站中列出的框架添加到 .linkswith 文件中:
[assembly: LinkWith ("libCardIO.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true
, Frameworks="AVFoundation AudioToolbox CoreMedia CoreVideo MobileCoreServices OpenGLES QuartzCore Security UIKit")]
然后我在我的应用程序中向新创建的绑定项目添加了一个项目引用,但它没有编译。我在 Xamarin 的输出控制台中收到此错误:
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -Wl,-no_pie -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=6.1 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk /Users/Sten/Dropbox/Code/Projects/Tabit/TabitOne_iPhone/TabitOne/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.cache.OHBLJlHbpZ74bpnhszg9JrCN8A8=.o -o /var/folders/bb/2tbfzn4n2dq6rsmtpv_jlmbr0000gq/T/tmp59582304.tmp/TabitOne -framework CFNetwork -framework AssetsLibrary -framework Accounts -framework CoreBluetooth -framework CoreTelephony -framework EventKit -framework EventKitUI -framework Foundation -framework CoreMotion -framework GameKit -framework GLKit -framework iAd -framework MapKit -framework MediaPlayer -framework MessageUI -framework NewsstandKit -framework OpenGLES -framework Social -framework StoreKit -framework Twitter -framework UIKit -framework PassKit -framework AddressBookUI -framework AudioToolbox -framework SystemConfiguration -framework AddressBook -framework AVFoundation -framework QuartzCore -framework CoreData -framework CoreGraphics -framework CoreImage -framework CoreLocation -framework CoreText -framework ImageIO -framework MobileCoreServices -framework Security -framework CoreMedia -framework CoreMIDI -framework CoreVideo -framework ExternalAccessory -framework AdSupport -framework QuickLook -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise -force_load /var/folders/bb/2tbfzn4n2dq6rsmtpv_jlmbr0000gq/T/tmp59582304.tmp/libCardIO.a
**Undefined symbols for architecture i386:**
"**std::terminate()**", referenced from:
-[CardIOGPURenderer dealloc] in libCardIO.a(CardIOGPURenderer.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnalytics.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOGPURenderer.o)
Dwarf Exception Unwind Info (__eh_frame) in libCardIO.a(CardIOAnimation.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
error MT5202: Native linking failed. Please review the build log.