Interface Builder changed between Xcode 3.1 (OS X 10.5) and Xcode 3.2 (OS X 10.6). In Xcode 3.1, you would select your "App Delegate" in your Document window, then use the [+] button in the Class Outlet section of the Identity Inspector pane. See the MonoDevelop_HelloWorld_with_Leopard sample.
In Xcode 3.2, this changed. You now would select Tools → Library, select the Classes section, and select your class, e.g. AppDelegate. There would then be an Outlets tab at the bottom of the Library dialog. See the MonoDevelop_HelloWorld sample.
You're maybe using an encoding that is not added by default. Check the Internationalization page to learn how to add support for more encoding.
The member was likely removed by the linker, and thus doesn't exist in the assembly at runtime. There are several solutions to this:
Note that assemblies are linked so that the resulting executable is smaller; thus, disabling linking may result in a larger executable than is desirable.
If you get this error when loading a NIB file it means that the value XXXX was not found on your managed class. This means that you are missing a declaration like this:
[Connect]
TypeName XXXX {
get {
return (TypeName) GetNativeField ("XXXX");
}
set {
SetNativeField ("XXXX", value);
}
}
The above definition is automatically generated by MonoDevelop for any XIB files that you add to MonoDevelop in the NAME_OF_YOUR_XIB_FILE.designer.xib.cs file.
Additionally, the types containing the above code must be a subclass of NSObject. If the containing type is within a namespace, it should also have a [Register] attribute which provides a type name without a namespace (as Interface Builder doesn't support namespaces in types):
namespace MonoTouch.Samples.GLPaint {
// The [Register] attribute overrides the type name registered
// with the Objective-C runtime, in this case removing the namespace.
[Register ("AppDelegate")]
public class AppDelegate {/* ... */}
}
This error is generated if you define a class in your interface builder files but you do not provide the actual implementation for it in your C# code.
You need to add some code like this:
public partial class MyImageView : UIView {
public MyImageView (IntPtr handle) : base (handle {}
}
This error is produced at runtime when the code tries to instantiate an instance of the classes that you referenced from your Interface Builder file. This means that you forgot to add a constructor that takes a single IntPtr as a parameter.
The constructor with an IntPtr handle is used to bind managed objects with their unmanaged representations. To fix this, add the following line of code to the class Foo.Bar:
public Bar (IntPtr handle) : base (handle) { }
If you get this error in the designer generated files (*.xib.designer.cs), it means one of two things:
1) Missing partial class or base class
The designer-generated partial classes must have corresponding partial classes in user code that inherit from some subclass of NSObject, often UIViewController. Ensure that you have such a class for the type that is giving the error.
2) Default namespaces changed
The designer files are generated using your project's default namespace settings. If you have changed these settings, or renamed the project, the generated partial classes may no longer be in the same namespace as their user-code counterparts.
Namespace settings can be found in the Project Options dialog. The default namespace is found in the General->Main Settings section. If it is blank, the name of your project is used as the default. More advanced namespace settings can be found in the Source Code->.NET Naming Policies section.
You're creating an NSObject subclass on a thread that isn't the UI thread.
In the course of creating and releasing objects, the Objective-C runtime might choose to release objects when they are no longer needed. These are released to the thread's current auto-release pool. MonoTouch provides an autorelease pool for the main thread and any threads from the System.Threading.ThreadPool, but not for threads that you create manually using System.Threading.Thread.
When you create your own threads, if you are going to consume objects derives from NSObject, you should create an NSAutoReleasePool to prevent the leaking:
You need to create an NSAutoreleasePool to prevent the leaking:
var MyThreadStart ()
{
using (var pool = new NSAutoreleasePool()) {
// create NSObject subclasses...
}
}
If you want to track down where an object is being leaked by not having an auto release pool, you can drop down to GDB in XCode and set a breakpoint in the _NSAutoreleaseNoPool method and get a stack trace from it
Actions for interface builder files are connected to the widgets by reflection at runtime, so this warning is expected.
You can use "#pragma warning disable 0169" "#pragma warning enable 0169" around your actions if you want to suppress this warning just for these methods, or add 0169 to the "Ignore warnings" field in compiler options if you want to disable it for your whole project (not recommended).
If you see this error message, generally the problem is the absolute path to your project contains a space. This will be fixed in a future version of MonoTouch, but you can work around the issue by moving the project to a folder without spaces.
This happens when you do all of the following:
The problem is that Mono is picking up the OS X libsqlite3.dylib, not the iPhoneSimulator's libsqlite3.dylib file. Your app will work on the device, but just not your simulator.
The short term fix is to use Mac OS X Snow Leopard (10.6). A fix for Leopard (10.5) will be released with a future MonoTouch version.
This error means that the code-signing configuration for your certificate/bundle id does not match the provisioning profile installed on your device. Confirm you have the appropriate certificate selected in Project Options->iPhone Bundle Signing, and the correct bundle id specified in Project Options->iPhone Application
Ensure that you are using the latest MonoTouch version of MonoDevelop from http://monodevelop.com/Download/Mac_MonoTouch
If the issue is still present, please file a bug, attaching the "~/.config/MonoDevelop/log" log file.
If all else fails, you can try removing the code completion cache so that it is regenerated:
rm -r ~/.config/MonoDevelop/CodeCompletionData
Be careful that you type this command correctly or you could accidentally remove important files.
The popular Mac utilities QuickSilver, Google Toolbar and LaunchBar have clipboard features that corrupt MonoDevelop's memory. In their options, you can list MonoDevelop as a process they should not interfere with.
If you updated MonoDevelop due to a recent update, and when you try to start it again it complains about Mono 2.4 not being present, all you have to do is upgrade your Mono 2.4 installation.
Mono 2.4.2.3_6 fixes some important problems that prevented MonoDevelop from running reliably, sometimes hung MonoDevelop at startup or prevented the code completion database from being generated.
Once you install the new Mono, MonoDevelop will start as expected.
If you are receiving the following stack trace:
* Assertion at ../../../../mono/metadata/generic-sharing.c:704, condition `oti' not met Stacktrace: at System.Collections.Generic.List`1<object>..cctor () <0xffffffff> at System.Collections.Generic.List`1<object>..cctor () <0x0001c> at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
It means that you are linking a static library compiled with thumb code into your project. As of iPhone SDK release 3.1 (or higher at the time of this writing) Apple introduced a bug in their linker when linking non-Thumb code (MonoTouch) with Thumb code (your static library). You will need to link with a non-Thumb version of your static library to mitigate this issue.
The [] suffix indicates that you or the class library are calling a method on an array through a generic collection, such as IEnumerable<>, ICollection<> or IList<>. As a workaround, you can explicitely force the AOT compiler to include such method by calling the method yourself, and by making sure that this code is executed before the call that triggered the exception. In this case, you could write:
Foo [] array = null; int count = ((ICollection<Foo>) array).Count;
Which will force the AOT compiler to include the get_Count method.
Sometimes the MonoDevelop source editor becomes extremely slow, appearing to hang for several seconds between typing characters.
This issue is very rare and extremely hard to reproduce - it usually cannot be reproduced on the same machine after restarting MonoDevelop. For this reason we would appreciate it if you could perform several debugging steps before restarting MonoDevelop, and send the results to us.
Please attach the MD log, ~/.config/MonoDevelop/log (in future versions of MD it is ~/Library/Logs/MonoDevelop/MonoDevelop.log).
In order to support debugging, debug builds contain additional code. Projects built in release mode are a fraction of the size.
As of MonoTouch 1.3 the debug builds included debugging support for every single component of Mono (every method in every class of the frameworks).
With MonoTouch 1.4 we will introduce a finer grained method for debugging, the default will be to only provide debugging instrumentation for your code and your libraries, and not do this for all of the Mono assemblies (this will still be possible, but you will have to opt-in to debugging those assemblies).
Both Mono and MonoTouch installers hang if you have the iPhone Simulator running. This problem is not limited to Mono or MonoTouch, this is a consistent problem across any software that tries to install software on MacOS Snow Leopard if the iPhone Simulator is running at installation time.
Make sure you quit the iPhone simulator and retry the installation.
When you start debugging a device configuration, you will see the debugger show a dialog indicating that it is listening on a particular IP address. This IP address is also built into the application as a default setting. When you start the application in debug mode, it makes a connection to MonoDevelop, the debugger host. If it is unable to connect, the device will vibrate once.
There are several reasons the application may not be able to connect to the debugger:
If the device and the debugger host are on different networks, a firewall or private network may be preventing the application from connecting to the debugger host.
MonoDevelop may picked the wrong host IP address. MonoDevelop picks the first IP address on the machine, which, if you have multiple network interfaces, may not be the one you want. You can override the IP that MonoDevelop uses by quitting MonoDevelop and editing its settings file. This is in a hidden directory in in your home directory, ~/.config/MonoDevelop/MonoDevelopProperties.xml.
Look for the key "MonoTouch.Debugger.HostIP", and edit the value. If it is not present you will need to add it:
<Property key="MonoTouch.Debugger.HostIP" value="w.x.y.z"/>
where w.x.y.z is the IP you wish to use.
The debugger host's IP address may have changed. MonoDevelop has to embed the host's IP address in the application's default settings so that it knows what address to connect to. If the host's IP changes after you build the app, you need to rebuild and re-upload the app, or change the IP address entry in the app's settings on the device.
This error could be raised if you are trying to build with -nolink on the MonoTouch 1.4 style of releases. You can work around this error by specifying Extra Arguments in your monodevelop project configuration. Add the argument
-nosymbolstrip
and the problem should be resolved.