[MonoTouch] A monotouch wrapper for the Sparrow 2D library

fmuaddib fmuaddib at gmail.com
Fri Feb 25 07:08:08 EST 2011


Ok, thanks! Now I've compiled with the renamed "libSparrow.a_simulator"
and the building was fine, but once started it shows the background
image and the button but then it crashes with the following message:

SparrowTest[1094:207] Objective-C exception thrown. Name:
NSInvalidArgumentException Reason:  -[SPDelayedInvocation
onAtlasButtonTriggered:]: unrecognized selector sent to instance
0xce2b680

2011/2/25 Duane Wandless <duane at wandless.net>:
> The error from the logs is this:
> ld: library not found for -lSparrow
>
> You need to rename one of the files libSparrow.a_simulator or
> libSparrow.a_iPhone to libSparrow.a.  Depending on if you are compiling for
> the device or the simulator.
> Duane
>
> On Fri, Feb 25, 2011 at 6:27 AM, fmuaddib <fmuaddib at gmail.com> wrote:
>>
>> Thank you! Unfortunately it's still not working. Monodevelop returns
>> me the following error:
>>
>> Error 1: mtouch failed with the following message:
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:
>> In function 'monotouch_debug_connect':
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1779:
>> warning: implicit declaration of function 'select'
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:
>> In function 'main':
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1821:
>> warning: implicit declaration of function 'chdir'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1838:
>> warning: implicit declaration of function
>> 'monotouch_enable_debug_tracking'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1914:
>> warning: implicit declaration of function 'dup2'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1921:
>> warning: implicit declaration of function 'mini_get_debug_options'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:1925:
>> warning: implicit declaration of function
>> 'mono_debugger_agent_parse_options'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:2054:
>> warning: implicit declaration of function 'getpagesize'
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:2057:
>> warning: cast from pointer to integer of different size
>>
>> /var/folders/D+/D+mYihQFF+8G-ojrmxtT9k+++TI/-Tmp-/tmp773ce479.tmp/main.m:2057:
>> warning: initialization makes pointer from integer without a cast
>> ld: library not found for -lSparrow
>> collect2: ld returned 1 exit status
>>  (1) (SparrowTest)
>>
>>
>>
>> 2011/2/21 Duane Wandless <duane at wandless.net>:
>> > I have updated so the demo works with the AddEventListner.
>> > Thanks for letting me know it wasn't working.
>> > Duane
>> >
>> > On Mon, Feb 21, 2011 at 10:41 AM, fmuaddib <fmuaddib at gmail.com> wrote:
>> >>
>> >> Thank you, that is fixed now! It must be a monodevelop limitation (all
>> >> the "using" statements in the other partial classes should be
>> >> automatically parsed and included before compilation to avoid such
>> >> errors IMHO).
>> >>
>> >> But I still got four errors:
>> >>
>> >> Game.cs(37,37): Error CS1502: The best overloaded method match for
>> >> `Sparrow.SPEventDispatcher.AddEventListener(Sparrow.EventDispatch,
>> >> string, bool)' has some invalid arguments (CS1502) (SparrowTest)
>> >> Game.cs(37,37): Error CS1503: Argument `#1' cannot convert
>> >> `MonoTouch.ObjCRuntime.Selector' expression to type
>> >> `Sparrow.EventDispatch' (CS1503) (SparrowTest)
>> >> Game.cs(45,45): Error CS1502: The best overloaded method match for
>> >> `Sparrow.SPEventDispatcher.AddEventListener(Sparrow.EventDispatch,
>> >> string, bool)' has some invalid arguments (CS1502) (SparrowTest)
>> >> Game.cs(45,45): Error CS1503: Argument `#1' cannot convert
>> >> `MonoTouch.ObjCRuntime.Selector' expression to type
>> >> `Sparrow.EventDispatch' (CS1503) (SparrowTest)
>> >>
>> >> Maybe those are related to your new event listener method. Let me
>> >> know, I'm eager to compile. :)
>> >>
>> >> Emanuele
>> >>
>> >> 2011/2/18 Duane Wandless <duane at wandless.net>:
>> >> > That is a limitation with MonoDevelop.  Whenever MD auto generates
>> >> > the
>> >> > MainWindowIPhone.xib.designer.cs file you have to add a using Sparrow
>> >> > to
>> >> > that file.  There might be away to modify the XIB so MD will generate
>> >> > the
>> >> > using clause.  But I haven't tried.  The XIB doesn't change that
>> >> > often.
>> >> > So do a build, get the error, add the using clause, build again.
>> >> >  Slightly
>> >> > annoying but you don't have to do it very often.
>> >> > I forgot to put that in the README file.
>> >> > Duane
>> >> >
>> >> > On Fri, Feb 18, 2011 at 5:48 AM, fmuaddib <fmuaddib at gmail.com> wrote:
>> >> >>
>> >> >> This is the error I got (twice) compiling the Sparrow wrapper:
>> >> >> MainWindowIPhone.xib.designer.cs(25,25): Error CS0246: The type or
>> >> >> namespace name `SPView' could not be found. Are you missing a using
>> >> >> directive or an assembly reference? (CS0246) (SparrowTest)
>> >> >>
>> >> >> 2011/2/18 fmuaddib <fmuaddib at gmail.com>:
>> >> >> > I have some problems with the dependencies. Can you put the
>> >> >> > projects
>> >> >> > in a Mondevelop Solution (.sln)?
>> >> >> >
>> >> >> > 2011/2/17 Duane Wandless <duane at wandless.net>:
>> >> >> >> Emanuele, I did modify AddEventListner to be more .NET like.
>> >> >> >>
>> >> >> >> To add an event listner:
>> >> >> >> image.AddEventListener (doTouch, SPEvents.Touch);
>> >> >> >> To remove:
>> >> >> >> image.RemoveEventListner (doTouch, SPEvents.Touch);
>> >> >> >> ---
>> >> >> >> void doTouch (SPEvent e)
>> >> >> >> {
>> >> >> >>
>> >> >> >> Works very nicely.  Have you tried using the bindings?
>> >> >> >> Duane
>> >> >> >> On Thu, Feb 17, 2011 at 1:14 PM, fmuaddib <fmuaddib at gmail.com>
>> >> >> >> wrote:
>> >> >> >>>
>> >> >> >>> Great idea, maybe it could be even more simplified thank the
>> >> >> >>> obj-c
>> >> >> >>> version thanks to c# predicates. I think that the monotouch
>> >> >> >>> platform
>> >> >> >>> is the best for something fast and efficient like sparrow.
>> >> >> >>> Managing
>> >> >> >>> iOS graphics in monotouch can be much simplier than in obj-c,
>> >> >> >>> like
>> >> >> >>> the
>> >> >> >>> Monotouch.Dialog wrapper did for the cocoa interfaces without
>> >> >> >>> having
>> >> >> >>> to write dozens of delegates and controllers!!
>> >> >> >>>
>> >> >> >>> If you need an hand let me know.
>> >> >> >>> Emanuele
>> >> >> >>>
>> >> >> >>> 2011/2/6 Miguel de Icaza <miguel at novell.com>:
>> >> >> >>> > Hello,
>> >> >> >>> >
>> >> >> >>> >> I started the bindings for Sparrow.  It looks like a good
>> >> >> >>> >> API.
>> >> >> >>> >>  The
>> >> >> >>> >> MonoTouch project is the beginnings of the Demo app which
>> >> >> >>> >> works
>> >> >> >>> >> nicely.
>> >> >> >>> >> https://github.com/trustme/Sparrow
>> >> >> >>> >
>> >> >> >>> > This looks nice!
>> >> >> >>> >
>> >> >> >>> > May I suggest that in SPEventDispatcher you flag the
>> >> >> >>> > AddEventListener
>> >> >> >>> > as internal, and expose a method that takes a delegate
>> >> >> >>> > instead?
>> >> >> >>> >
>> >> >> >>> > That way users do not have to know about selectors, instances
>> >> >> >>> > and
>> >> >> >>> > flagging things with [Export], they would do:
>> >> >> >>> >
>> >> >> >>> > AddEventListener (OnBoundaryChange, "boundaryChange", true);
>> >> >> >>> >
>> >> >> >>> > The implementation looks like this:
>> >> >> >>> >
>> >> >> >>> > object AddEventListener (NSAction action, string evenType,
>> >> >> >>> > bool
>> >> >> >>> > retain)
>> >> >> >>> > {
>> >> >> >>> >    var dispatcher = new Dispatcher (action);
>> >> >> >>> >    RealAddEventListener (Dispatcher.InvokeSelector,
>> >> >> >>> > dispatcher,
>> >> >> >>> > eventType, retain);
>> >> >> >>> >    return dispatcher;
>> >> >> >>> > }
>> >> >> >>> >
>> >> >> >>> > [Register ("__SparrowClassDispatcher")]
>> >> >> >>> > class Dispatcher : NSObject {
>> >> >> >>> >    public static Selector InvokeSelector = new Selector
>> >> >> >>> > ("invoke");
>> >> >> >>> >    NSAction action;
>> >> >> >>> >    [Export ("invoke")]
>> >> >> >>> >    public Dispatcher (NSAction action) { this.action = action;
>> >> >> >>> > }
>> >> >> >>> >
>> >> >> >>> >    [Export ("apply")]
>> >> >> >>> >    [Preserve (Conditional = true)]
>> >> >> >>> >    public void Apply () { action (); }
>> >> >> >>> > }
>> >> >> >>> >
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >
>> >> >
>> >
>> >
>
>


More information about the MonoTouch mailing list