Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:15:01+00:00 2026-05-30T11:15:01+00:00

I can’t even get the simplest kind of binding library to work – I

  • 0

I can’t even get the simplest kind of binding library to work – I must be doing something fundamentally wrong…

I created an Xcode project called “TestLib” that looks like this:

//  TestLib.h
#import <Foundation/Foundation.h>
@interface TestLib : NSObject
{
    NSString *status;
}
@property (nonatomic,retain) NSString *status;
@end

//  TestLib.m
#import "TestLib.h"
@implementation TestLib
@synthesize status;
- (id)init
{
    self = [super init];
    if (self) {
        [self setStatus:@"initialized"];
    }

    return self;
}
@end

The project is here: http://dl.dropbox.com/u/31924320/TestLib.tar.gz

I compiled this into “libTestLib.a”.

Then I created the simplest binding library I could (along with a “single view application” to test it), which simply initializes the TestLib class and calls the getter for the status property. I added the library (libTestLib.a) into the binding library so it has the LinkWith file / assembly directive. The ApiDefinition.cs file looks like this:

namespace TestLibBinder
{
      [BaseType(typeof(NSObject))]
      interface TestLib
      {
            [Export("status")]
            string Status { get; set; }
      }
}

That project is here: http://dl.dropbox.com/u/31924320/BindingTest.tar.gz

Unfortunately I get a null reference back from the library when I try to get the Status property…

        public override void ViewDidLoad ()
        {
              base.ViewDidLoad ();

              TestLib testLib = new TestLib();  // succeeds!
              string status = testLib.Status;  // got a null reference

              if (status != null)
                    label.Text = status;
              else
                    label.Text = "binding failed";                  
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:15:03+00:00Added an answer on May 30, 2026 at 11:15 am

    I got this to work by stepping away from the Binding Library project approach and instead basing my code on the BindingSample in the xamarin sample suite.

    Anyone who wants to build a C# binding to objective-C code using MonoTouch should really start by reviewing the Makefile in that project. The approach it outlines is:

    1. Explicitly compile the Objective-C code for the three architectures (ARM6, ARM7, i386)
    2. Use lipo to create a single universal static library
    3. Use btouch to create the DLL and include the static library through the assembly directive (LinkWith) – see AssemblyInfo.cs in that
      project – as well as in the btouch commandline through the –link-with
      option.

    I personally found the process of creating the ApiDefinition.cs wrapper to be fairly straightforward, but there are some common mistakes – e.g. forgetting the trailing colon on a selector that takes one parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone tell me why this doesn't work? <?php $lang = $_get[lang]; if (($lang
Can some one Guide me to work with these things... What is Model popup
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can't work out a way to make an array of buttons in android. This
Can i get the source code for a WAMP stack installer somewhere? Any help
Can find why i get this error can someone help? package Android.data; public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.