6

我有一个在 i386/iOS 模拟器上构建和运行良好的 MonoTouch 项目。该项目引用了一个本机 (Obj-C) 库,我使用 Xamarin 的 BindingSample 中描述的 btouch 过程将其转换为 MonoTouch DLL:

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

因此,我的 makefile 构建了所有三种架构(i386、armv6 和 armv7),然后将三个输出组合到一个“通用”库,最后使用 btouch 生成 MonoTouch DLL。

为了确保我的通用库包含所有三种体系结构,我检查了lipo -info,确实,它包含 i386、armv6 和 armv7。

但是,当我在实际的 iOS 设备上进行部署时,我收到以下错误:

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

我究竟做错了什么?

4

1 回答 1

8

发现问题:原生库依赖于AddressBook框架,忘记在API定义项目的AssemblyInfo.cs中包含:

[assembly: LinkWith ("libContactsTokenFieldViewUniversal.a", LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, ForceLoad = true, Frameworks="AddressBook Foundation")]
于 2012-06-19T16:40:26.170 回答