简体   繁体   中英

Link-error creating a Cocoa Touch Framework with nested libraries

I am stucked in creating a Cocoa Touch framework

在此处输入图片说明

receiving this error

Undefined symbols for architecture armv7:
  "_AVMediaTypeVideo", referenced from:
      _avf_read_header in libavdevice.a(avfoundation.o)
  "_AVMediaTypeMuxed", referenced from:
      _avf_read_header in libavdevice.a(avfoundation.o)
  "_OBJC_CLASS_$_AVCaptureDeviceInput", referenced from:
      objc-class-ref in libavdevice.a(avfoundation.o)
  "_CMSampleBufferGetImageBuffer", referenced from:
      _avf_read_header in libavdevice.a(avfoundation.o)
      _avf_read_packet in libavdevice.a(avfoundation.o)
  "_OBJC_CLASS_$_AVCaptureSession", referenced from:
      objc-class-ref in libavdevice.a(avfoundation.o)

...

  "_LoggerAudio", referenced from:
  -[KxMovieDecoder setSelectedAudioStream:] in KxMovieDecoder.o
  -[KxMovieDecoder openAudioStream:] in KxMovieDecoder.o
  -[KxMovieDecoder handleAudioFrame] in KxMovieDecoder.o
  -[KxMovieDecoder decodeFrames:] in KxMovieDecoder.o

ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

In the project i use several other system dylibs and frameworks and other manually added static libraries with their relative headers.

The project is for ios8 only, non-64.

The libraries are all listed in Target > General >Linked Frameworks and Libraries. The headers are included correctly.

The same files compiled and linked are executed correctly in another (normal application, non library) project

I tried adding a pch also adding all the required libraries and nothing changed.

Dynamic library work only for ios 8. If you need to use the dynamic library your project , add the your frameworks both Linked Frameworks and Libraries and Embedded Binaries in General Tab . Its will be work.

You can change the static library instead of dynamic library. Build setting -> Mach-O -> Static libarary, as well as change the deployment target as iOS 7.0. After changed these two done in your framework is work on iOS 7.0 and later.

Here step to create static cocoa touch framework in Xcode 6.

Open Xcode and create a new static framework project by clicking File\\New\\Project and selecting iOS\\Framework and Library\\Cocoa Touch framework.

Name the product FrameWorkName and save the project to an empty directory.

Automatically umbrella header created for our framework. In this header , you should import all the public headers of our framework using the statements like #import

A static framework project is made up of header files and implementation files, which are compiled to make the framework itself. You can create the class by using the Cocoa Touch class.

Verifying Your Build Settings Go to the Build Settings of your project Target and confirm or set the “Architectures” to “Standard Architectures.” These are arm64 and armv7, and are likely the default. As well as, Also we need to set the few architectures in setting, because iOS apps need to run on many different architectures.

armv7: Used in the oldest iOS 7-supporting devices armv7s: As used in iPhone 5 and 5C arm64: For the 64-bit ARM processor in iPhone 5S i386: For the 32-bit simulator x86_64: Used in 64-bit simulator

This means that builds are as fast as they can be. When you archive an app or build in release mode, then Xcode will build for all ARM architectures, thus allowing the app to run on most devices.

Mach-O setting: Static library:

Final Build project:

Click here ( you got more details.)

Aggregate target to combine the device and simulator framework by using lipo

lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo

Click here you have get the step for create universal framework

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM