Bindings for MapBox

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bindings for MapBox

Dennis Welu
Been struggling to create bindings for MapBox

Created a binding project (attached).
MapBoxBindings.zip

Set up binding code, including the linkwith.cs file:

    [assembly: LinkWith ("libMapView.a", LinkTarget.ArmV7 | LinkTarget.Simulator,
                     Frameworks = "CoreFoundation CoreLocation QuartzCore UIKit Foundation CoreGraphics",
                     LinkerFlags = "-lz -lsqlite3", ForceLoad = true, IsCxx = true)]

When I build my project with the iPhoneSimulator configuration, I get:

    missing required architecture i386 in file /var/folders/0t/z2shp7y529d6zp4_ynqrq6180000gn/T/tmpaa7bdd3.tmp/libMapView.a (2 slices)

When I build it with the iPhone configuration, it builds. But when running it crashes after executing a few lines of related code...nasty stack trace etc.

I'm guessing there may be two different problems here. But I'm looking for any ideas/gotchas folks might have. I've reviewed various posts on creating bindings and tracking down dependencies etc. Obviously I haven't gotten it all sorted out yet... Any ideas would be appreciated!

Thanks!

Dennis
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Miguel de Icaza-2

When I build my project with the iPhoneSimulator configuration, I get:

    missing required architecture i386 in file
/var/folders/0t/z2shp7y529d6zp4_ynqrq6180000gn/T/tmpaa7bdd3.tmp/libMapView.a
(2 slices)

The libMapView.a that you added to the project only contains code for the ARM platform.

You need to create a "fat" binary, one that contains both the code for the ARM platform, as well as code for the x86 platform.   You can either request the upstream distribution to give you the fat binary, or you can build the library yourself by using the "lipo" command to bundle multiple architecture-specific binaries into a single file.

Miguel

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
Right on. Followed the nice instructions here: http://docs.xamarin.com/ios/Guides/Advanced_Topics/Native_Interop

for using lipo. Solved the i386 issue nicely.

Now get the same result on simulator and ipad, will continue to pursue that I'm guessing something wrong in my bindings or implementation of a derived class, quite possibly the latter. I'll update this thread if I find something helpful to report. :-)

Thanks Miguel!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Jeff Stedfast
Hi Dennis,

For what it's worth, you don't need to create a fat binary to contain all architectures. You can also do the following:

 [assembly: LinkWith ("libMapView-armv7.a", LinkTarget.ArmV7,
                  Frameworks = "CoreFoundation CoreLocation QuartzCore UIKit Foundation CoreGraphics",
                  LinkerFlags = "-lz -lsqlite3", ForceLoad = true, IsCxx = true)]

[assembly: LinkWith ("libMapView-i386.a", LinkTarget.Simulator,
                  Frameworks = "CoreFoundation CoreLocation QuartzCore UIKit Foundation CoreGraphics",
                  LinkerFlags = "-lz -lsqlite3", ForceLoad = true, IsCxx = true)]


In other words, you can create a new attribute for each architecture. You just need to name the libraries differently (like including the arch name).

Hope that helps,

Jeff

On Mon, Nov 5, 2012 at 10:44 AM, Dennis Welu <[hidden email]> wrote:
Right on. Followed the nice instructions here:
http://docs.xamarin.com/ios/Guides/Advanced_Topics/Native_Interop
<http://docs.xamarin.com/ios/Guides/Advanced_Topics/Native_Interop>

for using lipo. Solved the i386 issue nicely.

Now get the same result on simulator and ipad, will continue to pursue that
I'm guessing something wrong in my bindings or implementation of a derived
class, quite possibly the latter. I'll update this thread if I find
something helpful to report. :-)

Thanks Miguel!



--
View this message in context: http://monotouch.2284126.n4.nabble.com/Bindings-for-MapBox-tp4657589p4657615.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Miguel de Icaza-2

For what it's worth, you don't need to create a fat binary to contain all architectures. You can also do the following:

Oh, nice trick!

Would you mind updating our reference pages with it?

Miguel

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
In reply to this post by Jeff Stedfast
Thanks Jeff! That's a good thing.

The 2nd part of the problem is hurting my head and I can't seem to break through. Getting error

        [CgMobilePOC3.UI.Touch.Views.EsriMapSource setDelegate:]: unrecognized selector sent to instance 0x14376150

when trying to set my derived delegate like this:

        public class EsriTileSourceDelegate : RMTileSource
        …

        public class EsriMapSource : RMAbstractWebMapSource
        {
                public EsriMapSource ()
                {
                        Delegate = new EsriTileSourceDelegate();  // <---- Badness here
                }
        }

and from the ApiDefinition.cs bindings file:

        [BaseType (typeof (NSObject))]
        [Model]
        interface RMTileSource {
                …
        }

        [BaseType (typeof (NSObject))]
        interface RMAbstractMercatorTileSource {
                [Export ("delegate"), NullAllowed]
                NSObject WeakDelegate { get; set; }

                [Wrap ("WeakDelegate")]
                RMTileSource Delegate { get; set; }
        }

        [BaseType (typeof (RMAbstractMercatorTileSource))]
        interface RMAbstractWebMapSource {
                ...
        }

Any ideas? I'll take a drink for anyone that has an idea.

Dennis
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
Ok I did get this working.

I ended up having to copy the delegate protocol definitions into the a base binding class. I'm not sure, but I think they were supposed to generate into the class automatically, but they didn't. Then I read the bottom of this page where it talks about inheriting protocols and how you used to have to copy the definition in for inherited protocols (but apparently not any more). In my case, it wasn't exactly protocol inheritance but similar. For the record this was my basic situation:

// the delegate definition
[BaseType (typeof (NSObject))]
interface RMTileSource

// this is where the weak and strong typed delegate props are defined for RMTileSource, but I had to
// copy the RMTileSource protocol binding definitions into this interface too
[BaseType (typeof (NSObject))]
interface RMAbstractMercatorTileSource

[BaseType (typeof (RMAbstractMercatorTileSource))]
interface RMAbstractWebMapSource

and then in my consuming project

// this is where I can override the RMTileSource methods as needed
class MyWebSource : RMAbstractWebMapSource

Thanks Miguel and Jeff for the help along the way.

Dennis

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
A little further info found out...fwiw.

Not an objective C expert and it shows, realizing now that the class RMAbstractMercatorTileSource actually just derives from NSObject<RMTileSource> but does not declare a weak reference, whereas another class RMMapView actually does have a weak delegate declared like this:

    @property (nonatomic, assign) IBOutlet id <RMMapViewDelegate>delegate;

and in that case the WeakDelegate/Delegate binding works fine.
Dmk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dmk
Dennis, is there a way I can use your bindings in my project?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
For sure. I'm actually just in the process of prepping a pull request to the monotouch-bindings project. In the meantime you can get the raw materials here: https://github.com/DennisWelu/monotouch-bindings/tree/master/Route-Me

A couple things to note. First, I ended up using the Alpstein fork of the Route-Me project for my work, which is the fork that MapBox is based on. The performance head to head for what I was doing was better on the Alpstein fork. The other thing is that the bindings don't cover 100% of the API but there's a good chunk there and because Route-Me is the basis for MapBox it shares a core portion of the API and should basically work for MapBox too (and other Route-Me based libraries). The thing you'll have to do if you want to use mapbox is make sure to build the MapBox dll into libMapView.a and replace the one that's there.

Dennis
Dmk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dmk
Dennis, 
Thank you! I'll take a look at it!

On Tue, Jan 8, 2013 at 9:24 AM, Dennis Welu [via MonoTouch] <[hidden email]> wrote:
For sure. I'm actually just in the process of prepping a pull request to the monotouch-bindings project. In the meantime you can get the raw materials here: https://github.com/DennisWelu/monotouch-bindings/tree/master/Route-Me

A couple things to note. First, I ended up using the Alpstein fork of the Route-Me project for my work, which is the fork that MapBox is based on. The performance head to head for what I was doing was better on the Alpstein fork. The other thing is that the bindings don't cover 100% of the API but there's a good chunk there and because Route-Me is the basis for MapBox it shares a core portion of the API and should basically work for MapBox too (and other Route-Me based libraries). The thing you'll have to do if you want to use mapbox is make sure to build the MapBox dll into libMapView.a and replace the one that's there.

Dennis


If you reply to this email, your message will be added to the discussion below:
http://monotouch.2284126.n4.nabble.com/Bindings-for-MapBox-tp4657589p4657923.html
To unsubscribe from Bindings for MapBox, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Roy Goode
In reply to this post by Dennis Welu
I just wanted to thank Dennis publicly on the mailing list for providing these bindings. I am intending to use these bindings in a free tourist guide app that I'm currently working on.


On 8 January 2013 14:24, Dennis Welu <[hidden email]> wrote:
For sure. I'm actually just in the process of prepping a pull request to the
monotouch-bindings project. In the meantime you can get the raw materials
here: https://github.com/DennisWelu/monotouch-bindings/tree/master/Route-Me

A couple things to note. First, I ended up using the Alpstein fork of the
Route-Me project for my work, which is the fork that MapBox is based on. The
performance head to head for what I was doing was better on the Alpstein
fork. The other thing is that the bindings don't cover 100% of the API but
there's a good chunk there and because Route-Me is the basis for MapBox it
shares a core portion of the API and should basically work for MapBox too
(and other Route-Me based libraries). The thing you'll have to do if you
want to use mapbox is make sure to build the MapBox dll into libMapView.a
and replace the one that's there.

Dennis



--
View this message in context: http://monotouch.2284126.n4.nabble.com/Bindings-for-MapBox-tp4657589p4657923.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu

All our welcome. Lord knows I've benefitted more from community code than have contributed over the years. Hopefully this helps!

Updated the binding project last night, added a small sample, and submitted the pull request. It should be less "raw" now.

On Jan 10, 2013 5:15 AM, "Roy Goode [via MonoTouch]" <[hidden email]> wrote:
I just wanted to thank Dennis publicly on the mailing list for providing these bindings. I am intending to use these bindings in a free tourist guide app that I'm currently working on.


On 8 January 2013 14:24, Dennis Welu <[hidden email]> wrote:
For sure. I'm actually just in the process of prepping a pull request to the
monotouch-bindings project. In the meantime you can get the raw materials
here: https://github.com/DennisWelu/monotouch-bindings/tree/master/Route-Me

A couple things to note. First, I ended up using the Alpstein fork of the
Route-Me project for my work, which is the fork that MapBox is based on. The
performance head to head for what I was doing was better on the Alpstein
fork. The other thing is that the bindings don't cover 100% of the API but
there's a good chunk there and because Route-Me is the basis for MapBox it
shares a core portion of the API and should basically work for MapBox too
(and other Route-Me based libraries). The thing you'll have to do if you
want to use mapbox is make sure to build the MapBox dll into libMapView.a
and replace the one that's there.

Dennis



--
View this message in context: http://monotouch.2284126.n4.nabble.com/Bindings-for-MapBox-tp4657589p4657923.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch



If you reply to this email, your message will be added to the discussion below:
http://monotouch.2284126.n4.nabble.com/Bindings-for-MapBox-tp4657589p4657930.html
To unsubscribe from Bindings for MapBox, click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

markboettcher
Dennis,

First I want to give you a big thanks for creating the bindings for Route-Me. We're in the painful process of porting an existing Android app done using MonoDroid to iOS. We used OSMDroid for the Droid version, mainly because OSM has been ported to a number of platforms.

Not sure if this is the right place to ask this, but I have a question. I am not a Mac person, so at this point everything I do on the Mac is a bit of a struggle. I downloaded and somehow managed to build the Alpstein branch of route-me on a MacBook we use for Xamarin iOS development. The resulting libMapView.a was 1 byte different in size from the one you use in your binding example. Mine didn't work of course. The binding project built just fine, but when I used the resulting DLL in my project, no map shows up.

My guess is that something needs to be set differently either in XCode preferences or in the Route-Me project used to make libMapView. Would it be possible to get a copy of the proj you used to build libMapView and tell me what if any changes I need in XCode prefs?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bindings for MapBox

Dennis Welu
Hi Mark, glad to hear you're getting some use out of it.

In regards to the problem you've described, I can say that I did not have to set any special settings in xcode. Actually, I built the library in xcode just to be sure it was building without error, but to create the .a file I used some terminal command lines. I should probably have included those in the bindings readme, but here's the brief instructions I use:

1) Make sure RouteMe mapview.xcode project builds in Xcode.
2) from command line, need to build the project twice: once for simulator/i86 architecture, once for arm v7 devices. Using Terminal, and from the MapView folder, run these two commands:

xcodebuild -project MapView.xcodeproj -target MapView -sdk iphonesimulator -configuration Release clean build 
xcodebuild -project MapView.xcodeproj -target MapView -sdk iphoneos -arch armv7 -configuration Release clean build

3) To take the output of these and combine them into a single .a file. In the 'build' subfolder run this:

lipo -create -output libMapView.a ./release-iphonesimulator/libMapView.a ./release-iphoneos/libMapView.a

Now copy the ".a" file into its location in the RouteMe.Touch folder of the solution where it is included as a file in this special MonoTouch bindings project.

If you haven't already tried it, I would take the sample that is included out there on github (https://github.com/mono/monotouch-bindings/tree/master/Route-Me/sample), get that running, then test your freshly built archive with it.

The difference of 1 byte is interesting but probably doesn't mean much. The version posted out there right now was built with Aplstein/Route-Me from several months ago and I see there's changes since then, so if you've pulled more recent stuff it just might be what it is. (On top of that, I think I had one small harmless addition to the objective-C code I forgot to take out before building the posted file).

Hope that helps!

Dennis
Loading...