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

  • SEARCH
  • Home
  • 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 7027571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:15:56+00:00 2026-05-28T00:15:56+00:00

I’m working to create bindings for Obj-C library so that I can work together

  • 0

I’m working to create bindings for Obj-C library so that I can work together with another team together on same project. To ensure this works, I’m attempting to create a simple obj-c library, define bindings, and use that object within MonoTouch. I have no build issue or even runtime exceptions, but my return value from calling any function is always null.

I started by created a new static library using Xcode and defined a ‘Calculator’ class. Below is the .h and .m

@interface Calculator : NSObject
- (NSString*)getMessage;
@end

@implementation Calculator
- (NSString*)getMessage
{
     return @"hey, look at me!";
}
@end

This built into the file ‘libXcodeLib.a’. I defined the following MonoTouch bindings for this class and methods:

 [BaseType(typeof(NSObject))]
 interface Calculator
 {
     [MonoTouch.Foundation.Export("getMessage")]
     string GetMessage();
 }

As well as an additional AssemblyInfo.cs for gcc_flags with the following:

[assembly: LinkWith ("libXcodeLib.a", LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, ForceLoad = true)]

And finally, here’s a look at the Makefile used to produce the .dll file

BTOUCH=/Developer/MonoTouch/usr/bin/btouch
all: XcodeLib.dll
XcodeLib.dll: Makefile ApiDefinition.cs AssemblyInfo.cs libXcodeLib.a
$(BTOUCH) -e ApiDefinition.cs AssemblyInfo.cs --out=XcodeLib.dll --link-with=libXcodeLib.a,libXcodeLib.a

And here is sample code invoking this method:

var calc = new MTBindings.Calculator();
var msg = calc.GetMessage();

At this point, why is msg NULL?

From all the reading I’ve done, I cannot see what I’m missing to make this work. Any newer or proven samples/tutorials would be greatly appreciated, I’m not sure how to simplify this more – and yet it still doesn’t work!

Thanks to the SO community – I hope 🙂

  • 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-28T00:15:56+00:00Added an answer on May 28, 2026 at 12:15 am

    I reviewed the package from Matt, and what I found was that his library was an ARM-only library. When run in the simulator, the code would not be linked in, and Objective-C likes to silently continue execution when messages are sent to null objects.

    This is what allows the following code in Objective-C to not crash:

    id foo = null;
    [foo.bar.baz saySomething:@”Hello”]

    Despite foo being null. In this case, it came back to basically not say anything when the code failed to load the Calculator class. All the messages were being happily sent, but the Objective-C runtime just kept on going.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.