I'm attempting to call Card.IO from my Xamarin app. I get "Undefined symbols for architecture i386:" when I try to compile my app and it cites "std::terminate()" in the message. The app is intended for iPhone, I don't know where did the "i386" come from - all settings in project options that I can find are set to ARMv7, so is the LinkWith attribute in the binding.
Card.IO's guide states I need to add -lstdc++ to "other linker flags" in Xcode but I don't know where should I put this in Xamarin Studio's options
Question is: how do I make this binding work? Is there an error in the binding? Is there some project setting or somehow adding more framework references in my app?
I used Objective Sharpie to generate the code below
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; }
}
}
I also added the frameworks listed in Card.IO's site to the .linkswith file:
[assembly: LinkWith ("libCardIO.a", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true
, Frameworks="AVFoundation AudioToolbox CoreMedia CoreVideo MobileCoreServices OpenGLES QuartzCore Security UIKit")]
Then I added a project reference in my app to the newly created binding project but it doesn't compile. I get this error in Xamarin's output console:
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.
Ok, thanks to the answer in another SO post I got this to work by editing my app's project options, page "iOS Build", field "Additional mtouch arguments" where I put the value:
-cxx -gcc_flags "-lstdc++"
Related
I am learning and I am trying to change the parameter name of my autogenerated partial class using [Display()] attribute but I am getting this error message.
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'Student_Age' could not be found (are you missing a using directive or an assembly reference?) EFScuffolding C:\Users\kusha\source\repos\EFModel\EFScuffolding\Models\Students.cs 20 Active
This is my autogenerated code for Student Class
namespace EFDemo.Models
{
using System;
using System.Collections.Generic;
public partial class Student
{
public int StudentID { get; set; }
public string Student_Name { get; set; }
public string Student_Major { get; set; }
public Nullable<int> Student_Age { get; set; }
}
}
This the class I am using to modify the parameters for display
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using EFScuffolding.Models;
namespace EFDemo.Models
{
[MetadataType(typeof(StudentMetaData))]
public partial class Student
{
}
public class StudentMetaData
{
[Required]
public int StudentID { get; set; }
[Required]
[Display(Student_Age = "Student Name")]
public string Student_Name { get; set; }
[Required]`enter code here`
[Display(Student_Major = "Student Major")]
public string Student_Major { get; set; }
[Required]
[Display(Student_Age = "Student Age")]
public Nullable<int> Student_Age { get; set; }
}
}
I am using MVC 5 ,EF6 and Visual Studio 17. Am I missing anything in the code.
Your not using the DisplayAttribute correctly. You need to set its Name property to the text you want to display
[Display(Name = "Student Name")] // not Student_Age = "Student Name"
public string Student_Name { get; set; }
and ditto for the other 2 properties
However, in asp.net-mvc, use view models, not partial classes. Refer What is ViewModel in MVC?
I'm porting a data model from EF4 to EF6 Code First. I'm getting the following message when the database creation is attempted. I'm at a loss to understand what is causing this. I don't have any Context, AstNode or JSParser entities. It is also not looking in the Models namespace:
var context = QPDataContext.Create();
var session = context.DataSessions.FirstOrDefault(ds => ds.DataSessionId = sessionId);
Throws this exception:
{"One or more validation errors were detected during model generation:
QPWebRater.DAL.Context: : EntityType 'Context' has no key defined. Define the key for this EntityType.
QPWebRater.DAL.AstNode: : EntityType 'AstNode' has no key defined. Define the key for this EntityType.
QPWebRater.DAL.JSParser: : EntityType 'JSParser' has no key defined. Define the key for this EntityType.
(many more similar errors snipped).
"}
Here is my database context (I've simplified it a bit):
QPWebRater.DAL.QPDataContext.cs:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Core;
using System.Data.Entity.Validation;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using Microsoft.Ajax.Utilities;
using QPWebRater.Models;
using QPWebRater.Utilities;
namespace QPWebRater.DAL
{
public class QPDataContext : DbContext
{
public QPDataContext()
: base("DefaultConnection")
{
Database.SetInitializer<QPDataContext>(new CreateDatabaseIfNotExists<QPDataContext>());
}
public static QPDataContext Create()
{
return new QPDataContext();
}
public DbSet<DataSession> DataSession { get; set; }
public DbSet<Document> Documents { get; set; }
public DbSet<Driver> Drivers { get; set; }
public DbSet<Location> Locations { get; set; }
public DbSet<Lookup> Lookups { get; set; }
public DbSet<Quote> Quotes { get; set; }
public DbSet<Vehicle> Vehicles { get; set; }
public DbSet<Violation> Violations { get; set; }
}
}
QPWebRater.Models.DatabaseModels.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace QPWebRater.Models
{
public partial class DataSession
{
public DataSession()
{
this.Vehicles = new HashSet<Vehicle>();
this.Drivers = new HashSet<Driver>();
...
}
public string DataSessionId { get; set; }
public System.DateTime Timestamp { get; set; }
...
}
public partial class Document
{
public int DocumentId { get; set; }
public int QuoteId { get; set; }
public string DocumentType { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public virtual Quote Quote { get; set; }
}
public partial class Driver
{
public Driver()
{
this.Violations = new HashSet<Violation>();
}
public int DriverId { get; set; }
public string DataSessionId { get; set; }
...
}
}
I solved this by examining all of the DbSet definitions. I had pared down the data model while also upgrading it. I had removed the Lookup model class but neglected to also remove the DbSet<Lookup> Lookups { get; set; } property.
This resulted in the class being resolved as Microsoft.Ajax.Utilities.Lookup. At runtime, EntityFramework tried to add a corresponding database table which failed miserably. If you are running into a similar problem then double check the generic types in your DbSet properties.
I'm trying to make a binding for StickNFind to use in a Xamarin-based project.
The problematic class is LeDeviceManager, it inherits CBCentralManagerDelegate, which is an abstract class and the UpdateState(m) method is not a part of the binding.
Here's the Obj-C header for this class:
interface LeDeviceManager : NSObject <CBCentralManagerDelegate>
#property (nonatomic,strong) NSMutableArray *devList;
#property (nonatomic) CBCentralManager *btmgr;
#property (nonatomic,strong) id <LeDeviceManagerDelegate> delegate;
- (id) initWithSupportedDevices: (NSArray *) devCls delegate: (id <LeDeviceManagerDelegate>) del;
- (void) startScan;
- (void) stopScan;
#end
And this is the binding I've come up with, with Objective Sharpie's heavy assistance:
[Model, BaseType (typeof(CBCentralManagerDelegate))]
public partial interface LeDeviceManager
{
[Export ("devList", ArgumentSemantic.Retain)]
NSMutableArray DevList { get; set; }
[Export ("btmgr")]
CBCentralManager Btmgr { get; set; }
[Export ("delegate", ArgumentSemantic.Retain)]
LeDeviceManagerDelegate Delegate { get; set; }
[Export ("initWithSupportedDevices:delegate:")]
IntPtr Constructor (NSObject[] devCls, LeDeviceManagerDelegate del);
[Export ("startScan")]
void StartScan ();
[Export ("stopScan")]
void StopScan ();
[Export ("UpdatedState")]
[New] // Added as suggested by another SO post, also tried [Abstract]
void UpdatedState(CBCentralManager mgr);
}
And I get this error:
Error CS0533: StickNFind.LeDeviceManager.UpdatedState(MonoTouch.CoreBluetooth.CBCentralManager)' hides inherited abstract memberMonoTouch.CoreBluetooth.CBCentralManagerDelegate.UpdatedState(MonoTouch.CoreBluetooth.CBCentralManager)' (CS0533) (SNF_Binding)
How do I fix this:
Hello can you try this instead?
[Protocol] // Added Protocol attribute
[Model]
[BaseType (typeof(NSObject))] //Changed BaseType to NSObject
public partial interface LeDeviceManager : ICBCentralManagerDelegate
{
[Export ("devList", ArgumentSemantic.Retain)]
NSMutableArray DevList { get; set; }
[Export ("btmgr")]
CBCentralManager Btmgr { get; set; }
[Export ("delegate", ArgumentSemantic.Retain)]
LeDeviceManagerDelegate Delegate { get; set; }
[Export ("initWithSupportedDevices:delegate:")]
IntPtr Constructor (NSObject[] devCls, LeDeviceManagerDelegate del);
[Export ("startScan")]
void StartScan ();
[Export ("stopScan")]
void StopScan ();
[Export ("updatedState")] [New] // Notice I changed UpdatedState to updatedState lowercase u
void UpdatedState(CBCentralManager mgr);
}
I highly recommend reading Binding Protocols section of this doc
So I have created a class library with the following:
I then referenced the DLL into my project and when I click on it to explore what classes I have accessible to me, I see this:
as you can see there are no classes accessible, there's nothing. So I cannot go into controllers and add a new one because technically I have no models or context class....
Thoughts?
Example of what a model class looks like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UFACoreLibrary.Models
{
class LocationAssignment
{
public int id { get; set; }
public int locationId { get; set; }
public string type { get; set; }
public int typeId { get; set; }
public virtual Location Location { get; set; }
}
}
Thats an example of what one of the classes in the core library looks like, in case its a code issue.
Also All I am doing is building the project and using the DLL generated.
Unfortunately, by default Visual Studio will not add the keyword public to classes it fills in when you use the wizard. You'll need to add public to make the classes visible outside the assembly (e.g. public class LocationAssignment).
I have an interface in a DLL and am implementing it in a Console App for Testing
My Interface is as Follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Gemini.Data.Interfaces
{
public interface IUser
{
IEnumerable<IUserDetails> UserProfiles { get; set; }
string AdUserName { get; set; }
}
public interface IUserDetails
{
int UserId { get; set; }
string DisplayUserName { get; set; }
string OfficeCode { get; set; }
string UserEmail { get; set; }
string AdLogin { get; set; }
bool? LastActiveUser { get; set; }
Gemini.Data.App_Consts.Access_Rights UserAccess { get; set; }
bool IsPM { get; set; }
bool IsSPM { get; set; }
bool IsVdbUser { get; set; }
DateTime? LastModified { get; set; }
DateTime? LastLoginUse { get; set; }
int? LastModifiedBy { get; set; }
}
}
and when I try to use it in the Testing App I get the following
The type or namespace name 'IUser' does not exist in the namespace 'Gemini.Data.Interfaces' (are you missing an assembly reference?)
the Console App is as Follows
using System;
using System.Collections.Generic;
using Gemini.Data.Interfaces;
namespace ConsoleApplication2
{
public class User : Gemini.Data.Interfaces.IUser
{
private IEnumerable<IUserDetails> _UserProfiles = null;
#region IUser Members
public IEnumerable<IUserDetails> UserProfiles
{
get { return _UserProfiles; }
set { _UserProfiles = value; }
}
public string AdUserName { get; set; }
#endregion
}
class Program
{
static void Main(string[] args)
{
User u = new User();
Gemini.Data.Main.UserDetails ud = new Gemini.Data.Main.UserDetails(u, "Qpirate");
}
}
}
Visual Studio seems to reference the Interfaces and I can call Go To Definition on the Classes.
Anyone know of something else I can try?
I have already checked that the console app its targeting the same .NET Framework as the DLL.
The same issue happened to me once, and i found out that the assembly name, and console app name were same in my case.
To troubleshoot, i would suggest first make sure that assembly name are different for dll, and console app.
If that does not solve, try specifying different namespaces (both default namespace in project tab, and rename existing namespaces).
If that also does not solve, try to first merger the code of dll into app, and then move one by one. I hope codebase is small in your case.
I eventually just deleted the old Solution and started again, but one thing i did notice was that when i created a console app the Target Framework was ".NET Framework Client Profile"