melvin
melvin

Reputation: 71

xcode4 "dyld: Symbol not found: _OBJC_CLASS_$_AVCaptureDevice" error

my iphone app runs in IOS 4.3 simulator but not any other IOS 4.0+ simulator. Even though, it shall run there.

I got the following errors -

GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".Attaching to process 71564. dyld: Symbol not found: _OBJC_CLASS_$_AVCaptureDevice Referenced from: /Users/qianfan/Library/Application Support/iPhone Simulator/4.2/Applications/XXXX-XXXX/XXXX.app/XXXX Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/AVFoundation.framework/AVFoundation in /Users/qianfan/Library/Application Support/iPhone Simulator/4.2/Applications/XXXX-XXXX/XXXX.app/XXXX sharedlibrary apply-load-rules all (gdb)

My app is using (statically referencing) latest ZXing iphone code (two versions tested as of 2011-03-31 2001-04-24).

I believe AVCaptureDevice is existing in all iOS 4.0 + AND zxing is supporting ios 4.0 +. when I do:

Macintosh:zxing-trunk XXX$ grep _OBJC_CLASS_$_AVCaptureDevice /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/AVFoundation.framework/* Binary file /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/AVFoundation.framework/AVFoundation matches

Any suggestions? what I shall look for here? Thank you so much.

Upvotes: 7

Views: 5065

Answers (5)

litbe
litbe

Reputation: 461

A solution for my case:

Xcode -> target

  1. General -> Build settings -> under Mac catalyst deployment section, set Support mac catalyst to Yes.
  2. Build phases tab -> scroll down to section Link binary with libraries -> add AVKit.framework -> clean build folder and rebuild.

Upvotes: 1

Anonimys
Anonimys

Reputation: 696

  1. Rename file *.m -> *.mm
  2. Add Framework to Project (Proj -> Frameworks etc. -> +) AVFoundation.framowork contain sumbol AVCaptureDevice
  3. Clear Build -> Recompile

Repeat step 2 for other problem sumbol in project. Check needed Framework for include to proj you can found by several way: Example your problem class/method name: "OBJC_CLASS$_AVCaptureDevice" class AVCaptureDevice contain in AVFoundation

I. Copy sumbol name AVCaptureDevice -> Apple Developer documentation

enter image description here

II. Open problem *.mm file -> AVCaptureDevice -> Right Click -> Jump to definition

enter image description here

Upvotes: 0

Angus Forbes
Angus Forbes

Reputation: 982

I just want to mention that mmilo's answer (about changing the 'Required' to 'Optional') solved the problem for me. Simply click on the AVFoundation.framework (under the Frameworks folder in the Project view) and then make sure the Right most view window is open. That's where you can switch the "Target Membership" from Required to Optional.

My specific issue was the same as melvin's. I couldn't get my project to compile on the 4.2 simulator when using the 4.3 SDK because it couldn't find the AVCaptureDevice class.

Upvotes: 8

yetihehe
yetihehe

Reputation: 640

AVFoundation framework doesn't work in simulator. Only on devices.

Upvotes: 3

Alex Kremer
Alex Kremer

Reputation: 2311

It looks like your project is not being linked against AVFoundation.. maybe you link on Version level or something? That would explain why it builds on one but not the others.

Upvotes: 0

Related Questions