我正试图从我的Xamarin应用程序中调用Card.IO。当我尝试编译我的应用程序并在消息中引用“std :: terminate()”时,我得到“架构i386的未定义符号:”。该应用程序适用于iPhone,我不知道“i386”来自哪里 - 我可以找到的项目选项中的所有设置都设置为ARMv7,绑定中的LinkWith属性也是如此。
Card.IO的指南说明我需要在Xcode中将-lstdc++
添加到“其他链接器标志”但我不知道我应该在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.
答案 0 :(得分:2)
好的,感谢另一个SO post中的答案我通过编辑我的应用程序的项目选项,页面“iOS Build”,字段“Additional mtouch arguments”来设置值:
-cxx -gcc_flags "-lstdc++"