MonoTouch Build: ld: symbol(s) not found for archi

2019-02-22 02:42发布

I have a MonoTouch project which builds and runs fine on i386/iOS Simulator. The project references a native (Obj-C) library, which I converted to a MonoTouch DLL by using the btouch process as described in Xamarin's BindingSample:

https://github.com/xamarin/monotouch-samples/tree/eb640165f0485ff59b2f80e73ccff382bf4f2083/BindingSample/src/binding

So my makefile builds all three architectures (i386, armv6 and armv7), then combines the three outputs to one 'Universal' library, and finally uses btouch to generate a MonoTouch DLL.

To be sure that my universal library contains all three architectures, I checked with lipo -info, and indeed, it contains i386, armv6 and armv7.

However, when I'm building for deployment on an actual iOS device, I get the following errors:

Undefined symbols for architecture armv7:
  "_ABAddressBookCreate", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABAddressBookCopyArrayOfAllPeople", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABAddressBookGetPersonCount", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABRecordCopyValue", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_kABPersonFirstNameProperty", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_kABPersonLastNameProperty", referenced from:
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
      -[ContactsTokenField setupSms] in libContactsTokenFieldViewUniversal.a(ContactsTokenField.o)
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABMultiValueGetCount", referenced from:
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABMultiValueCopyLabelAtIndex", referenced from:
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_ABMultiValueCopyValueAtIndex", referenced from:
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_kABPersonEmailProperty", referenced from:
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
  "_kABPersonPhoneProperty", referenced from:
      -[TITokenFieldView setupWithAddressType:prompt:] in libContactsTokenFieldViewUniversal.a(TITokenField.o)
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status

mtouch exited with code 1

What am I doing wrong?

1条回答
狗以群分
2楼-- · 2019-02-22 03:44

found the problem: the native library depended on the AddressBook framework, and I forgot to include it in the AssemblyInfo.cs of the API definition project:

[assembly: LinkWith ("libContactsTokenFieldViewUniversal.a", LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, ForceLoad = true, Frameworks="AddressBook Foundation")]
查看更多
登录 后发表回答