tystol / MonoTouch.ZBar

3 stars 5 forks source link

Wrapper Type missing #2

Open eclipsed4utoo opened 11 years ago

eclipsed4utoo commented 11 years ago

I'm trying to integrate this into an existing Xamarin.iOS application that I have. I literally copied and pasted the code from the sample into my project(a few changes because it's in an UITableViewSource instead of a UIViewController), added reference for Zbar.dll, and added the 'libzbar.a' to the project. When running in debug on an iPod Touch running iOS 5.1.1, I get the following error message...

Wrapper type 'ZBar.ZBarReaderViewController' is missing its native ObjectiveC class 'ZBarReaderViewController'.

It happens on this line of code...

var barcodeReader = new ZBarReaderViewController();

I forked the current 'master' branch and built it. Not really sure where to start on this.

tystol commented 11 years ago

Hmm, Im not familiar with that error message, but I havnt actually used or tested this since the move/rename from MonoDevelop/MonoTouch to Xamarin.iOS, could be due to some differences there.

However, 1 thing: The libzbar.a only needs to be supplied to compile ZBar.dll. It gets embedded within the dll within that process. So then your actual app projects just reference ZBar.dll like any pure .NET dll.

Sorry I cant be of more help, I havnt swapped my dev environment over to all the new Xamarin.iOS tools yet so cant test this either.

eclipsed4utoo commented 11 years ago

I was able to fix this issue. Not really sure what I did to fix it, but here is what I changed, and it now works:

  1. Removed 'libzbar.a' from my project.
  2. The clone of the code did not include the 'libzbar.a' file, and when I added it the first time, Xamarin Studio didn't create the 'linkwith' sub file. So I included the file again and made sure the 'linkwith' file was present.
  3. The 'libzbar.a' file was taken from here. I used that because I am targeting armv7, so I needed the libzbar library that also targeted armv7.
  4. I added to the LinkWith code to include additional frameworks that were needed to build with the new 'libzbar.a'. The build issues were in my project, not MonoTouch.ZBar. But I had to add the LinkWith stuff to MonoTouch.ZBar for it to work.
  5. I also had to build in Release mode instead of Debug for MonoTouch.ZBar. Not sure why it wouldn't work when the DLL was build in Debug.

It seems that you include the 'linkwith' file in the repo, but Xamarin Studio didn't put the two together when I added the 'libzbar.a' file.

tystol commented 11 years ago

Thanks for the detailed steps! Until I get a chance to test this myself, I'll just link this issue from the readme file for the benefits of others.

It does sound like some change in behaviour due to Xamarin Studio. MonoDevelop did use to handle it fine when dropping in the zbar lib into the project. Out of curiosity, did you try building via the makefile at all? Did that not work either?

eclipsed4utoo commented 11 years ago

I did not try building with the make file.