[docs] xamarin now requires markdown+yaml (#2258)

* markdown, yaml, api links, accessibility (for images)

ensure iOS docs conform to xamarin docpub standards

* markdown formatting fixes
This commit is contained in:
Craig Dunn 2017-07-12 18:29:47 -07:00 коммит произвёл Sebastien Pouliot
Родитель 76d9e43f53
Коммит 27b28b4bf9
8 изменённых файлов: 976 добавлений и 991 удалений

Просмотреть файл

@ -5,14 +5,14 @@ XAMARIN_ANALYSIS_DOC = xamarin-analysis-doc-tool/bin/Debug
diff:
-diff -u $(WEBSITE_DOCS)/guides/ios/troubleshooting/mtouch-errors/index.md mtouch-errors.md
-diff -u $(WEBSITE_DOCS)/guides/ios/advanced_topics/binding_objective-c/binding_objc_libs/index.md binding_objc_libs.md
-diff -u $(WEBSITE_DOCS)/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide/index.md binding_types_reference_guide.md
-diff -u $(WEBSITE_DOCS)/guides/cross-platform/macios/binding/objective-c-libraries/index.md binding_objc_libs.md
-diff -u $(WEBSITE_DOCS)/guides/cross-platform/macios/binding/binding-types-reference/index.md binding_types_reference_guide.md
-diff -u $(WEBSITE_DOCS)/guides/ios/troubleshooting/xamarin-ios-analysis/index.md xamarin-ios-analysis.md
all: xamarin-analysis-doc
cp mtouch-errors.md $(WEBSITE_DOCS)/guides/ios/troubleshooting/mtouch-errors/index.md
cp binding_objc_libs.md $(WEBSITE_DOCS)/guides/ios/advanced_topics/binding_objective-c/binding_objc_libs/index.md
cp binding_types_reference_guide.md $(WEBSITE_DOCS)/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide/index.md
cp binding_objc_libs.md $(WEBSITE_DOCS)/guides/cross-platform/macios/binding/objective-c-libraries/index.md
cp binding_types_reference_guide.md $(WEBSITE_DOCS)/guides/cross-platform/macios/binding/binding-types-reference/index.md
cp xamarin-ios-analysis.md $(WEBSITE_DOCS)/guides/ios/troubleshooting/xamarin-ios-analysis/index.md
xamarin-analysis-doc:

Просмотреть файл

@ -1,16 +1,21 @@
id:{8A832A76-A770-1A7C-24BA-B3E6F57617A0}
title:Binding Objective-C Libraries
samplecode:[Binding Sample](/samples/BindingSample/)
---
id: 8A832A76-A770-1A7C-24BA-B3E6F57617A0
title: Binding Objective-C Libraries
samplecode:
- title: "Binding Sample"
url: /samples/BindingSample/
dateupdated: 2017-06-26
---
[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)
[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)
[//]: # (Modifications outside of xamarin-macios/master will be lost on future updates)
When working on iOS, you might encounter cases where you want to
When working with Xamarin.iOS or Xamarin.Mac, you might encounter cases where you want to
consume a third-party Objective-C library. In those situations, you
can use Xamarin.iOS's Binding Projects to create a C# binding to the
can use Xamarin Binding Projects to create a C# binding to the
native Objective-C libraries. The project uses the same tools that we
use to bring the iOS APIs to C#.
use to bring the iOS and Mac APIs to C#.
This document describes how to bind Objective-C APIs, if you are
binding just C APIs, you should use the standard .NET mechanism for
@ -20,31 +25,51 @@ Details on how to statically link a C library are available on the
page.
See our companion [Binding Types Reference
Guide](/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide).
Guide](/guides/cross-platform/macios/binding/binding-types-reference/).
Additionally, if you want to learn more about what happens under the hood, check our
[Binding Details](/guides/ios/advanced_topics/binding_objective-c/binding_details)
[Binding Overview](/guides/cross-platform/macios/binding/overview/)
page.
**Sample Code**
Bindings can be built for both iOS and Mac libraries.
This page describes how to work on an iOS binding, however
Mac bindings are very similar.
**Sample Code for iOS**
You can use the
[BindingSample](https://github.com/xamarin/monotouch-samples/tree/master/BindingSample)
[iOS Binding Sample](https://github.com/xamarin/monotouch-samples/tree/master/BindingSample)
project to experiment with bindings.
<div class="note">Note: This is only supported in Xamarin Studio on Mac.</div>
<a name="Getting_Started" class="injected"></a>
# Getting Started
<ide name="xs">
<p>The easiest way to create a binding is to create a Xamarin.iOS Binding Project. You can do this from Xamarin Studio on Mac by selecting the project type, <b>iOS Binding Project</b>: <br/><img src="Images/00.png" /></p>
</ide>
[[ide name="xs"]]
<ide name="vs">
<p>The easiest way to create a binding is to create a Xamarin.iOS Binding Project. You can do this from Visual Studio on Windows by selecting the project type, <b>iOS Binding Project</b>: <br/><img src="Images/00VS.png" /></p>
</ide>
The easiest way to create a binding is to create a Xamarin.iOS Binding Project.
You can do this from Xamarin Studio on Mac by selecting the project type,
**iOS > Library > Bindings Library**:
[![](Images/00-sml.png "Do this from Xamarin Studio on Mac by selecting the project type, iOS Library Bindings Library")](Images/00.png)
[[/ide]]
[[ide name="vs"]]
The easiest way to create a binding is to create a Xamarin.iOS Binding Project.
You can do this from Visual Studio on Windows by selecting the project type,
**Visual C# > iOS > Bindings Library (iOS)**:
[![](Images/00VS-sml.png "iOS Bindings Library iOS")](Images/00VS.png)
> ⚠️ Note: Binding Projects for **Xamarin.Mac** are only supported in
> Visual Studio for Mac.
[[/ide]]
The generated project contains a small template that you can edit, it
contains two files: `ApiDefinition.cs` and `StructsAndEnums.cs`.
@ -58,9 +83,7 @@ limited to C# interfaces and C# delegate declarations. The
definitions that are required by the interfaces and delegates. This
includes enumeration values and structures that your code might use.
<a name="Binding_an_API" class="injected"></a>
<a name="Binding_an_API" />
# Binding an API
To do a comprehensive binding, you will want to understand the Objective-C
@ -114,14 +137,14 @@ To produce a complete binding, you will typically deal with four
components:
- The API definition file (`ApiDefinition.cs` in the template).
- Optional: any enums, types, structs required by the API definition file (`StructsAndEnums.cs` in the template).
- Optional: extra sources that might expand the generated binding, or provide a more C# friendly API (any C# files that you add to the project).
- Optional: any enums, types, structs required by the API definition file (`StructsAndEnums.cs` in the template).
- Optional: extra sources that might expand the generated binding, or provide a more C# friendly API (any C# files that you add to the project).
- The native library that you are binding.
This chart shows the relationship between the files:
[ ![](Images/Screen_Shot_2012-02-08_at_3.33.07_PM.png)](Images/Screen_Shot_2012-02-08_at_3.33.07_PM.png)
[ ![](Images/Screen_Shot_2012-02-08_at_3.33.07_PM.png "This chart shows the relationship between the files")](Images/Screen_Shot_2012-02-08_at_3.33.07_PM.png)
The API Definition file: will only contain namespaces and interface
definitions (with any members that an interface can contain) and
@ -178,7 +201,7 @@ the extension ".a". When you do this, Xamarin Studio will add two
files: the `.a` file and an automatically populated C# file that
contains information about what the native library contains:
[ ![](Images/Screen_Shot_2012-02-08_at_3.45.06_PM.png)](Images/Screen_Shot_2012-02-08_at_3.45.06_PM.png)
[ ![](Images/Screen_Shot_2012-02-08_at_3.45.06_PM.png "Native libraries by convention start with the word lib and end with the extension .a")](Images/Screen_Shot_2012-02-08_at_3.45.06_PM.png)
The contents of the `libMagicChord.linkwith.cs` file has information about how
this library can be used and instructs your IDE to package this binary into
@ -201,7 +224,7 @@ Sometimes you might find that you need a few enumeration values, delegate
definitions or other types. Do not place those in the API definitions file, as
this is merely a contract
<a name="The_API_definition_file" class="injected"></a>
<a name="The_API_definition_file" />
# The API definition file
@ -220,7 +243,7 @@ But since we are using the interface as a skeleton to generate a class
we had to resort to decorating various parts of the contract with
attributes to drive the binding.
<a name="Binding_Methods" class="injected"></a>
<a name="Binding_Methods" />
## Binding Methods
The simplest binding you can do is to bind a method. Just declare a
@ -275,7 +298,7 @@ When exporting a reference type, with the `[Export]` keyword you can also
specify the allocation semantics. This is necessary to ensure that no data is
leaked.
<a name="Binding_Properties" class="injected"></a>
<a name="Binding_Properties" />
## Binding Properties
Just like methods, Objective-C properties are bound using the
@ -310,7 +333,7 @@ This then binds "isMenuVisible" and "setMenuVisible:". Optionally, a property ca
```
[Category, BaseType(typeof(UIView))]
interface UIView_MyIn
{
{
[Export ("name")]
string Name();
@ -400,7 +423,7 @@ interface MyMutableTree {
}
```
<a name="Binding_Constructors" class="injected"></a>
<a name="Binding_Constructors" />
## Binding Constructors
@ -408,10 +431,10 @@ interface MyMutableTree {
The **btouch-native** tool will automatically generate fours
constructors in your class, for a given class `Foo`, it generates:
- `Foo ()`: the default constructor (maps to Objective-C's "init" constructor)
- `Foo (NSCoder)`: the constructor used during deserialization of NIB files (maps to Objective-C's "initWithCoder:" constructor).
- `Foo (IntPtr handle)`: the constructor for handle-based creation, this is invoked by the runtime when the runtime needs to expose a managed object from an unmanaged object.
- `Foo (NSEmptyFlag)`: this is used by derived classes to prevent double initialization.
- `Foo ()`: the default constructor (maps to Objective-C's "init" constructor)
- `Foo (NSCoder)`: the constructor used during deserialization of NIB files (maps to Objective-C's "initWithCoder:" constructor).
- `Foo (IntPtr handle)`: the constructor for handle-based creation, this is invoked by the runtime when the runtime needs to expose a managed object from an unmanaged object.
- `Foo (NSEmptyFlag)`: this is used by derived classes to prevent double initialization.
For constructors that you define, they need to be declared using the
@ -425,7 +448,7 @@ use:
IntPtr Constructor (CGRect frame);
```
<a name="Binding_Protocols" class="injected"></a>
<a name="Binding_Protocols" />
## Binding Protocols
@ -524,7 +547,7 @@ consume protocols:
// Interface that contains only the required methods
interface IMyProtocol: INativeObject, IDisposable {
[Export (“say:”)]
[Export ("say:")]
void Say (string msg);
}
@ -562,7 +585,7 @@ the methods.
If you want to use the protocol definitions in your API, you will need
to write skeleton empty interfaces in your API definition. If you
want to use the MyProtocol in an API, you would need to do this:
```
[BaseType (typeof (NSObject))]
[Model, Protocol]
@ -593,12 +616,12 @@ exist, that is why you need to provide an empty interface.
Whenever you implement one of the interfaces generated for
the protocols, like this:
```
class MyDelegate : NSObject, IUITableViewDelegate {
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
}
```
@ -609,17 +632,17 @@ exported with the proper name, so it is equivalent to this:
```
class MyDelegate : NSObject, IUITableViewDelegate {
[Export (“getRowHeight:”)]
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
[Export ("getRowHeight:")]
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
}
```
It does not matter if the interface is implemented
implicitly or explicitly.
implicitly or explicitly.
<a name="Binding_Class_Extensions" class="injected"></a>
<a name="Binding_Class_Extensions" />
## Binding Class Extensions
@ -636,8 +659,8 @@ For example, in Xamarin.iOS we bound the extension methods that are defined on
```
[BaseType (typeof (UIResponder))]
interface UIView {
[Bind ("drawAtPoint:withFont:")]
SizeF DrawString ([Target] string str, CGPoint point, UIFont font);
[Bind ("drawAtPoint:withFont:")]
SizeF DrawString ([Target] string str, CGPoint point, UIFont font);
}
```
@ -654,12 +677,12 @@ For example, in Xamarin.iOS we bound the extension methods that are defined on
```
[Category, BaseType (typeof (NSString))]
interface NSStringDrawingExtensions {
[Export ("drawAtPoint:withFont:")]
CGSize DrawString (CGPoint point, UIFont font);
[Export ("drawAtPoint:withFont:")]
CGSize DrawString (CGPoint point, UIFont font);
}
```
<a name="Binding_Objective-C_Argument_Lists" class="injected"></a>
<a name="Binding_Objective-C_Argument_Lists" />
## Binding Objective-C Argument Lists
@ -672,7 +695,7 @@ An Objective-C message looks like this:
```
- (void) appendWorkers:(XWorker *) firstWorker, ...
NS_REQUIRES_NIL_TERMINATION ;
NS_REQUIRES_NIL_TERMINATION ;
```
To invoke this method from C# you will want to create a signature like
@ -705,7 +728,7 @@ public void AppendWorkers(params Worker[] workers)
}
```
<a name="Binding_Fields" class="injected"></a>
<a name="Binding_Fields" />
## Binding Fields
@ -776,14 +799,14 @@ interface LonelyClass {
}
```
<a name="Binding_Notifications" class="injected"></a>
<a name="Binding_Enums" class="injected"></a>
## Binding Enums
You can add `enum` directly in your binding files to makes it easier
to use them inside API definitions - without using a different source
file (that needs to be compiled in both the bindings and the final
file (that needs to be compiled in both the bindings and the final
project).
Example:
@ -813,7 +836,7 @@ enum NSRunLoopMode {
[Field ("NSRunLoopCommonModes")]
Common,
[Field (null)]
Other = 1000
}
@ -821,7 +844,7 @@ enum NSRunLoopMode {
interface MyType {
[Export ("performForMode:")]
void Perform (NSString mode);
[Wrap ("Perform (mode.GetConstant ())")]
void Perform (NSRunLoopMode mode);
}
@ -835,8 +858,8 @@ However this would limit subclassing the type as the nicer API alternative
uses a `[Wrap]` attribute. Those generated methods are not `virtual`, i.e.
you won't be able to override them - which may, or not, be a good choice.
An alternative is to mark the original, `NSString`-based, definition as
`[Protected]`. This will allow subclassing to work, when required, and
An alternative is to mark the original, `NSString`-based, definition as
`[Protected]`. This will allow subclassing to work, when required, and
the wrap'ed version will still work and call the overriden method.
@ -884,6 +907,8 @@ CAScroll [] SupportedScrollModes { get; set; }
Please see [[BindAs] documentation](/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide#BindAsAttribute) to see supported conversion types.
<a name="Binding_Notifications" />
## Binding Notifications
@ -891,11 +916,11 @@ Notifications are messages that are posted to the
`NSNotificationCenter.DefaultCenter` and are used as a mechanism to
broadcast messages from one part of the application to
another. Developers subscribe to notifications typically using the
[NSNotificationCenter](http://iosapi.xamarin.com/?link=T%3aMonoTouch.Foundation.NSNotificationCenter)'s
[AddObserver](http://iosapi.xamarin.com/?link=T%3aMonoTouch.Foundation.NSNotificationCenter%2fM%2fAddObserver)
[NSNotificationCenter](/api/type/Foundation.NSNotificationCenter/)'s
[AddObserver](/api/type/Foundation.NSNotificationCenter/M/AddObserver/)
method. When an application posts a message to the notification
center, it typically contains a payload stored in the
[NSNotification.UserInfo](http://iosapi.xamarin.com/?link=P%3aMonoTouch.Foundation.NSNotification.UserInfo)
[NSNotification.UserInfo](/api/property/Foundation.NSNotification.UserInfo/)
dictionary. This dictionary is weakly typed, and getting information
out of it is error prone, as users typically need to read in the
documentation which keys are available on the dictionary and the types
@ -942,7 +967,7 @@ public class MyClass {
Users of your code can then easily subscribe to notifications posted
to the
[NSDefaultCenter](http://iosapi.xamarin.com/?link=P%3aMonoTouch.Foundation.NSNotificationCenter.DefaultCenter)
[NSDefaultCenter](/api/property/Foundation.NSNotificationCenter.DefaultCenter/)
by using code like this:
```
@ -960,7 +985,7 @@ token.Dispose ();
Or you can call
[NSNotification.DefaultCenter.RemoveObserver](http://iosapi.xamarin.com/?link=M%3aMonoTouch.Foundation.NSNotificationCenter.RemoveObserver(MonoTouch.Foundation.NSObject))
[NSNotification.DefaultCenter.RemoveObserver](/api/member/Foundation.NSNotificationCenter.RemoveObserver/p/Foundation.NSObject/)
and pass the token. If your notification contains parameters, you
should specify a helper `EventArgs` interface, like this:
@ -987,7 +1012,7 @@ interface MyScreenChangedEventArgs {
The above will generate a `MyScreenChangedEventArgs` class with the
`ScreenX` and `ScreenY` properties that will fetch the data from the
[NSNotification.UserInfo](http://iosapi.xamarin.com/?link=P%3aMonoTouch.Foundation.NSNotification.UserInfo)
[NSNotification.UserInfo](/api/property/Foundation.NSNotification.UserInfo/)
dictionary using the keys "ScreenXKey" and "ScreenYKey" respectively
and apply the proper conversions. The `[ProbePresence]` attribute is
used for the generator to probe if the key is set in the `UserInfo`,
@ -1002,7 +1027,7 @@ var token = MyClass.NotificationsObserveScreenChanged ((notification) => {
});
```
<a name="Binding_Categories" class="injected"></a>
<a name="Binding_Categories" />
## Binding Categories
@ -1103,7 +1128,7 @@ interface SocialNetworking {
}
```
<a name="Binding_Blocks" class="injected"></a>
<a name="Binding_Blocks" />
## Binding Blocks
@ -1182,18 +1207,18 @@ Example:
```
[Export ("loadfile:completed:")]
[Async]
void LoadFile (string file, Action<string> completed);
[Async]
void LoadFile (string file, Action<string> completed);
```
The above code will generate both the LoadFile method, as
well as:
```
[Export ("loadfile:completed:")]
Task<string> LoadFileAsync (string file);
Task<string> LoadFileAsync (string file);
```
<a name="Surfacing_Strong_Types"></a>
@ -1230,7 +1255,7 @@ there are scenarios where the value might not be set.
To do this, you need to do a few things:
* Create a strongly typed class, that subclasses
[DictionaryContainer](http://iosapi.xamarin.com/?link=T%3aMonoTouch.Foundation.DictionaryContainer) and provides the various getters and setters for each property.
[DictionaryContainer](/api/type/Foundation.DictionaryContainer/) and provides the various getters and setters for each property.
* Declare overloads for the methods taking `NSDictionary` to take the new strongly typed version.
You can create the strongly typed class either manually, or use the
@ -1248,8 +1273,8 @@ public class XyzOptions : DictionaryContainer {
#if !COREBUILD
public XyzOptions () : base (new NSMutableDictionary ()) {}
public XyzOptions (NSDictionary dictionary) : base (dictionary){}
public nfloat? Volume {
public nfloat? Volume {
get { return GetFloatValue (XyzOptionsKeys.VolumeKey); }
set { SetNumberValue (XyzOptionsKeys.VolumeKey, value); }
}
@ -1262,7 +1287,7 @@ public class XyzOptions : DictionaryContainer {
```
You then should provide a wrapper method that surfaces the high-level
API, on top of the low-level API.
API, on top of the low-level API.
```
[BaseType (typeof (NSObject))]
@ -1353,14 +1378,14 @@ field (that is not the name of the property with the suffix `Key`),
you can decorate the property with an `Export` attribute with the name
that you want to use.
<a name="Type_mappings" class="injected"></a>
<a name="Type_mappings" />
# Type mappings
This section covers how Objective-C types are mapped to C# types.
<a name="Simple_Types" class="injected"></a>
This section covers how Objective-C types are mapped to C# types.
<a name="Simple_Types" />
## Simple Types
@ -1570,7 +1595,7 @@ Objective-C and CocoaTouch world to the Xamarin.iOS world:
</tbody>
</table>
<a name="Arrays" class="injected"></a>
<a name="Arrays" />
## Arrays
@ -1605,7 +1630,7 @@ the actual type of the objects contained in the array.
In cases where you can not track down the actual most derived type contained
in the array, you can use `NSObject []` as the return value.
<a name="Selectors" class="injected"></a>
<a name="Selectors" />
## Selectors
@ -1687,7 +1712,7 @@ class DialogPrint : UIViewController {
}
```
<a name="Strings" class="injected"></a>
<a name="Strings" />
## Strings
@ -1706,7 +1731,7 @@ annotate the parameter with the
[[PlainString]](/guides/ios/advanced_topics/binding_objective-c/binding_types_reference_guide#PlainString)
attribute.
<a name="out/ref_parameters" class="injected"></a>
<a name="out/ref_parameters" />
## out/ref parameters
@ -1735,7 +1760,7 @@ void Something (nint foo, out NSError error);
void SomeString (ref NSObject byref);
```
<a name="Memory_management_attributes" class="injected"></a>
<a name="Memory_management_attributes" />
## Memory management attributes
@ -1756,12 +1781,12 @@ semantics available are:
- Retain:
<a name="Style_Guidelines" class="injected"></a>
<a name="Style_Guidelines" />
## Style Guidelines
<a name="Using_[Internal]" class="injected"></a>
<a name="Using_[Internal]" />
### Using [Internal]
@ -1778,7 +1803,7 @@ generator, for example some advanced scenarios might expose types that
are not bound and you want to bind in your own way, and you want to
wrap those types yourself in your own way.
<a name="Event_Handlers_and_Callbacks" class="injected"></a>
<a name="Event_Handlers_and_Callbacks" />
# Event Handlers and Callbacks
@ -1814,11 +1839,11 @@ Considering the following setup:
```
[BaseType (typeof (NSObject))]
interface MyClass {
[Export ("delegate", ArgumentSemantic.Assign)][NullAllowed]
NSObject WeakDelegate { get; set; }
[Export ("delegate", ArgumentSemantic.Assign)][NullAllowed]
NSObject WeakDelegate { get; set; }
[Wrap ("WeakDelegate")][NullAllowed]
MyClassDelegate Delegate { get; set; }
[Wrap ("WeakDelegate")][NullAllowed]
MyClassDelegate Delegate { get; set; }
}
[BaseType (typeof (NSObject))]
@ -1830,8 +1855,8 @@ interface MyClassDelegate {
To wrap the class you must:
- In your host class, add to your `[BaseType]` declaration the type that is acting as its delegate and the C# name that you exposed. In our example above those are "typeof (MyClassDelegate)" and "WeakDelegate" respectively.
- In your delegate class, on each method that has more than two parameters, you need to specify the type that you want to use for the automatically generated EventArgs class.
- In your host class, add to your `[BaseType]` declaration the type that is acting as its delegate and the C# name that you exposed. In our example above those are "typeof (MyClassDelegate)" and "WeakDelegate" respectively.
- In your delegate class, on each method that has more than two parameters, you need to specify the type that you want to use for the automatically generated EventArgs class.
The binding generator is not limited to wrapping only a single event
@ -1908,7 +1933,7 @@ DefaultValue will hardcode a return value, while
`[DefaultValueFromArgument]` is used to specify which input argument
will be returned.
<a name="Enumerations_and_Base_Types" class="injected"></a>
<a name="Enumerations_and_Base_Types" />
# Enumerations and Base Types
@ -1919,7 +1944,7 @@ this, put your enumerations and core types into a separate file and
include this as part of one of the extra files that you provide to
btouch.
<a name="Linking_the_Dependencies" class="injected"></a>
<a name="Linking_the_Dependencies" />
# Linking the Dependencies
@ -1962,7 +1987,7 @@ does not preserve the metadata required to support categories (the
linker/compiler dead code elimination strips it) which you need at
runtime for Xamarin.iOS.
<a name="Assisted_References" class="injected"></a>
<a name="Assisted_References" />
# Assisted References
@ -2020,7 +2045,7 @@ class Demo {
}
```
<a name="Inheriting_Protocols" class="injected"></a>
<a name="Inheriting_Protocols" />
# Inheriting Protocols

Просмотреть файл

@ -1,5 +1,8 @@
id:{C6618E9D-07FA-4C84-D014-10DAC989E48D}
title:Binding Types Reference Guide
---
id: C6618E9D-07FA-4C84-D014-10DAC989E48D
title: Binding Types Reference Guide
dateupdated: 2017-06-26
---
[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)
[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)
@ -12,7 +15,7 @@ Xamarin.iOS and Xamarin.Mac API contracts are written in C# mostly as interface
definitions that define the way that Objective-C code is surfaced to C#. The
process involves a mix of interface declarations plus some basic type
definitions that the API contract might require. For an introduction to binding
types, see our companion guide [Binding Objective-C Libraries](/guides/ios/advanced_topics/binding_objective-c/binding_objc_libs/).
types, see our companion guide [Binding Objective-C Libraries](/guides/cross-platform/macios/binding/objective-c-libraries/).
# Type Definitions
@ -58,7 +61,7 @@ interface UITextField : UITextInput {
You can control many other aspects of the code generation by applying other
attributes to the interface as well as configuring the BaseType attribute.
<a name="Generating_Events" class="injected"></a>
<a name="Generating_Events" />
## Generating Events
@ -169,8 +172,7 @@ public partial class UIImagePickerImagePickedEventArgs : EventArgs {
It then exposes the following in the UIImagePickerController class:
```
public event EventHandler<uiimagepickerimagepickedeventargs> FinishedPickingImage { add; remove; }
</uiimagepickerimagepickedeventargs>
public event EventHandler<UIImagePickerImagePickedEventArgs> FinishedPickingImage { add; remove; }
```
Model methods that return a value are bound differently. Those require both a
@ -197,7 +199,7 @@ directs the generator to return the value of the specified
parameter in the call or the `NoDefaultValue` parameter that
instructs the generator that there is no default value.
<a name="BaseTypeAttribute" class="injected"></a>
<a name="BaseTypeAttribute" />
## BaseTypeAttribute
@ -217,9 +219,6 @@ public class BaseTypeAttribute : Attribute {
}
```
<a name="BaseType.Name" class="injected"></a>
### BaseType.Name
You use the `Name` property to control the name that this type will bind to in
@ -242,8 +241,6 @@ The specified name is specified is used as the value for the generated
name is used as the value for the `Register` attribute in the generated
output.
<a name="BaseType.Events_and_BaseType.Delegates" class="injected"></a>
### BaseType.Events and BaseType.Delegates
@ -263,8 +260,8 @@ weakly-typed delegate that you want to wrap, and the Events array contains one
type for each type that you want to associate with it.
```
[BaseType (typeof (NSObject),
Delegates=new string [] { "WeakDelegate" },
[BaseType (typeof (NSObject),
Delegates=new string [] { "WeakDelegate" },
Events=new Type [] {typeof(UIAccelerometerDelegate)})]
public interface UIAccelerometer {
}
@ -275,7 +272,7 @@ public interface UIAccelerometerDelegate {
}
```
<a name="BaseType.KeepRefUntil" class="injected"></a>
<a name="BaseType.KeepRefUntil" />
### BaseType.KeepRefUntil
@ -293,9 +290,9 @@ Xamarin.iOS:
```
[BaseType (typeof (NSObject), KeepRefUntil="Dismissed")]
[BaseType (typeof (UIView),
KeepRefUntil="Dismissed",
Delegates=new string [] { "WeakDelegate" },
[BaseType (typeof (UIView),
KeepRefUntil="Dismissed",
Delegates=new string [] { "WeakDelegate" },
Events=new Type [] {typeof(UIActionSheetDelegate)})]
public interface UIActionSheet {
}
@ -308,7 +305,7 @@ public interface UIActionSheetDelegate {
}
```
<a name="DisableDefaultCtorAttribute" class="injected"></a>
<a name="DisableDefaultCtorAttribute" />
## DisableDefaultCtorAttribute
@ -319,7 +316,7 @@ the generator from producing the default constructor.
Use this attribute when you need the object to be initialized with one of the
other constructors in the class.
<a name="PrivateDefaultCtorAttribute" class="injected"></a>
<a name="PrivateDefaultCtorAttribute" />
## PrivateDefaultCtorAttribute
@ -329,9 +326,7 @@ default constructor as private. This means that you can still instantiate object
of this class internally from your extension file, but it just wont be
accessible to users of your class.
<a name="CategoryAttribute" class="injected"></a>
<a name="CategoryAttribute" />
## CategoryAttribute
Use this attribute on a type definition to bind Objective-C
@ -402,7 +397,7 @@ interface FooObject_Extensions {
}
```
This is incorrect because in order to use the `BoolMethod` extension you need an instance of `FooObject` but you are binding an ObjC **static** extension, this is a side effect due to the fact of how C# extension methods are implemented.
This is incorrect because in order to use the `BoolMethod` extension you need an instance of `FooObject` but you are binding an ObjC **static** extension, this is a side effect due to the fact of how C# extension methods are implemented.
The only way to use the above definitions is by the following ugly code:
@ -424,9 +419,7 @@ interface FooObject {
We will issue a warning (BI1117) whenever we find a `[Static]` member inside a `[Category]` definition. If you really want to have `[Static]` members inside your `[Category]` definitions you can silence the warning by using `[Category (allowStaticMembers: true)]` or by decorating either your member or `[Category]` interface definition with `[Internal]`.
<a name="StaticAttribute" class="injected"></a>
<a name="StaticAttribute" />
## StaticAttribute
When this attribute is applied to a class it will just generate a static
@ -451,9 +444,7 @@ public partial class CBAdvertisement {
}
```
<a name="Model_Definitions" class="injected"></a>
<a name="Model_Definitions" />
# Model Definitions
###Protocol definitions/Model
@ -467,9 +458,9 @@ This in general means that when you subclass a class that
has been flagged with the `ModelAttribute`, you should not call
the base method. Calling that method will throw an
exception, you are supposed to implement the entire behavior
on your subclass for any methods you override. <a name="AbstractAttribute" class="injected"></a>
on your subclass for any methods you override.
<a name="AbstractAttribute" />
## AbstractAttribute
By default, members that are part of a protocol are not mandatory. This
@ -495,7 +486,7 @@ public interface UITableViewDataSource {
}
```
<a name="DefaultValueAttribute" class="injected"></a>
<a name="DefaultValueAttribute" />
## DefaultValueAttribute
@ -575,14 +566,11 @@ parameter.
See
also: [NoDefaultValueAttribute](#NoDefaultValueAttribute), [DefaultValueAttribute](#DefaultValueAttribute)
See also: [NoDefaultValueAttribute](#NoDefaultValueAttribute), [DefaultValueAttribute](#DefaultValueAttribute)
## IgnoredInDelegateAttribute
Sometimes it makes sense not to expose an event or delegate property from a
Sometimes it makes sense not to expose an event or delegate property from a
Model class into the host class so adding this attribute will instruct the
generator to avoid the generation of any method decorated with it.
@ -592,15 +580,12 @@ generator to avoid the generation of any method decorated with it.
public interface UIImagePickerControllerDelegate {
[Export ("imagePickerController:didFinishPickingImage:editingInfo:"), EventArgs ("UIImagePickerImagePicked")]
void FinishedPickingImage (UIImagePickerController picker, UIImage image, NSDictionary editingInfo);
[Export ("imagePickerController:didFinishPickingImage:"), IgnoredInDelegate)] // No event generated for this method
void FinishedPickingImage (UIImagePickerController picker, UIImage image);
}
```
<a name="IgnoredInDelegateAttribute" class="injected"></a>
## DelegateNameAttribute
@ -625,14 +610,10 @@ declaration:
public delegate float NSAnimationProgress (MonoMac.AppKit.NSAnimation animation, float progress);
```
<a name="EventArgsAttribute" class="injected"></a>
## DelegateApiNameAttribute
This attribute is used to allow the generator to change the name of the property generated
in the host class. Sometimes it is useful when the name of the FooDelegate class method
in the host class. Sometimes it is useful when the name of the FooDelegate class method
makes sense for the Delegate class, but would look odd in the host class as a property.
Also this is really useful (and needed) when you have two or more overload methods that makes
@ -657,9 +638,7 @@ declaration in the host class:
public Func<NSAnimation, float, float> ComputeAnimationCurve { get; set; }
```
<a name="DelegateApiNameAttribute" class="injected"></a>
## EventArgsAttribute
For events that take more than one parameter (in Objective-C the convention
@ -693,13 +672,10 @@ public partial class UIImagePickerImagePickedEventArgs : EventArgs {
It then exposes the following in the UIImagePickerController class:
```
public event EventHandler<uiimagepickerimagepickedeventargs> FinishedPickingImage { add; remove; }
</uiimagepickerimagepickedeventargs>
public event EventHandler<UIImagePickerImagePickedEventArgs> FinishedPickingImage { add; remove; }
```
<a name="EventNameAttribute" class="injected"></a>
<a name="EventNameAttribute" />
## EventNameAttribute
This attribute is used to allow the generator to change the name of an event
@ -723,7 +699,7 @@ var webView = new UIWebView (...);
webView.LoadFinished += delegate { Console.WriteLine ("done!"); }
```
<a name="ModelAttribute" class="injected"></a>
<a name="ModelAttribute" />
## ModelAttribute
@ -744,7 +720,7 @@ class.
Specifies that the method on the model does not provide a
default return value.
This works with the Objective-C runtime by responding
This works with the Objective-C runtime by responding
"false" to the Objective-C runtime request to determine if the
specified selector is implemented in this class.
@ -777,7 +753,7 @@ using the Model attribute.
interface MyProtocol {
// Use [Abstract] when the method is defined in the @required section
// of the protocol definition in Objective-C
[Abstract]
[Abstract]
[Export ("say:")]
void Say (string msg);
@ -801,7 +777,7 @@ class MyProtocol : IMyProtocol {
// Interface that contains only the required methods
interface IMyProtocol: INativeObject, IDisposable {
[Export (“say:”)]
[Export ("say:")]
void Say (string msg);
}
@ -809,7 +785,7 @@ interface IMyProtocol: INativeObject, IDisposable {
static class IMyProtocol_Extensions {
public static void Optional (this IMyProtocol this, string msg);
}
}
}
```
The **class implementation** provides a complete abstract class that you can override individual methods of and get full type safety. But due to C# not supporting multiple inheritance, there are scenarios where you might require a different base class, but still want to implement an interface.
@ -840,7 +816,7 @@ would need to do this:
interface MyProtocol {
// Use [Abstract] when the method is defined in the @required section
// of the protocol definition in Objective-C
[Abstract]
[Abstract]
[Export ("say:")]
void Say (string msg);
@ -879,10 +855,10 @@ exported with the proper name, so it is equivalent to this:
```
class MyDelegate : NSObject, IUITableViewDelegate {
[Export ("getRowHeight:")]
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
[Export ("getRowHeight:")]
nint IUITableViewDelegate.GetRowHeight (nint row) {
return 1;
}
}
```
@ -911,7 +887,7 @@ interface Robot : SpeakProtocol {
}
```
<a name="Member_Definitions" class="injected"></a>
<a name="Member_Definitions" />
# Member Definitions
@ -919,7 +895,7 @@ interface Robot : SpeakProtocol {
The attributes in this section are applied to individual members of a type:
properties and method declarations.
<a name="AlignAttribute" class="injected"></a>
<a name="AlignAttribute" />
## AlignAttribute
@ -940,7 +916,7 @@ public interface GLKBaseEffect {
}
```
<a name="AppearanceAttribute" class="injected"></a>
<a name="AppearanceAttribute" />
## AppearanceAttribute
@ -983,8 +959,6 @@ public partial class UIToolbar {
}
```
<a name="" class="injected"></a>
## AutoReleaseAttribute (Xamarin.iOS 5.4)
@ -1006,9 +980,6 @@ sort of background downloader that is always alive and waiting for work, the
images would never be released.
<a name="ForcedTypeAttribute" class="injected"></a>
## ForcedTypeAttribute
The `ForcedTypeAttribute` is used to enforce the creation of a managed type even
@ -1021,7 +992,7 @@ of the native method, for example take the following Objective-C definition from
`- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request`
It clearly states that it will return an `NSURLSessionDownloadTask` instance, but yet it
**returns** a `NSURLSessionTask`, which is a superclass and thus not convertible to
**returns** a `NSURLSessionTask`, which is a superclass and thus not convertible to
`NSURLSessionDownloadTask`. Since we are in a type-safe context an `InvalidCastException`
will happen.
@ -1043,11 +1014,9 @@ by default `[ForcedType (owns: true)]`. The owns parameter is used to follow
the [Ownership Policy](https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html)
for **Core Foundation** objects.
The `ForcedTypeAttribute` is only valid on `parameters`, `properties` and `return value`.
The `ForcedTypeAttribute` is only valid on `parameters`, `properties` and `return value`.
<a name="BindAsAttribute" class="injected"></a>
## BindAsAttribute
@ -1159,10 +1128,6 @@ CAScroll? [] GetScrollModes (CGRect [] rects) { ... }
The `rects` parameter will be encapsulated into a `NSArray` that contains an `NSValue` for each `CGRect` and in return you will get an array of `CAScroll?` which has been created using the values of the returned `NSArray` containing `NSStrings`.
<a name="BindAttribute" class="injected"></a>
## BindAttribute
The `Bind` attribute has two uses one when applied to a method or property
@ -1257,14 +1222,14 @@ Task<FileLoading> LoadFile (string file);
```
If the last parameter of the callback is an `NSError`, then
then the generated `Async` method will check if the value is not
the generated `Async` method will check if the value is not
null, and if that is the case, the generated async method will
set the task exception.
```
[Export ("upload:onComplete:")]
[Async]
void Upload (string file, Action<tstring,NSError> onComplete);
void Upload (string file, Action<string,NSError> onComplete);
```
The above generates the following async method:
@ -1274,7 +1239,7 @@ Task<string> UploadAsync (string file);
```
And on error, the resulting Task will have the exception
set to an `NSErrorException` that wraps the resulting `NSError`.
set to an `NSErrorException` that wraps the resulting `NSError`.
### AsyncAttribute.ResultType
@ -1282,7 +1247,7 @@ set to an `NSErrorException` that wraps the resulting `NSError`.
Use this property to specify the value for the returning
`Task` object. This parameter takes an existing type, thus it
needs to be defined in one of your core api definitions.
needs to be defined in one of your core api definitions.
### AsyncAttribute.ResultTypeName
@ -1290,7 +1255,7 @@ needs to be defined in one of your core api definitions.
Use this property to specify the value for the returning
`Task` object. This parameter takes the name of your desired
type name, the generator will produce a series of properties,
one for each parameter that the callback takes. <a name="AsyncAttribute.MethodName"></a>
one for each parameter that the callback takes.
### AsyncAttribute.MethodName
@ -1299,7 +1264,7 @@ one for each parameter that the callback takes. <a name="AsyncAttribute.MethodNa
Use this property to customize the name of the generated
async methods. The default is to use the name of the method
and append the text "Async", you can use this to change this default. <a name="DisableZeroCopyAttribute" class="injected"></a>
and append the text "Async", you can use this to change this default.
## DisableZeroCopyAttribute
@ -1327,7 +1292,7 @@ The following shows two such properties in Objective-C:
@property(nonatomic,assign) NSString *name2;
```
<a name="DisposeAttribute" class="injected"></a>
<a name="DisposeAttribute" />
## DisposeAttribute
@ -1335,7 +1300,7 @@ The following shows two such properties in Objective-C:
When you apply the `DisposeAttribute` to a class, you provide a code snippet
that will be added to the `Dispose()` method implementation of the class.
Since the `Dispos`e method is automatically generated by the `bmac-native` and `btouch-native`
Since the `Dispose` method is automatically generated by the `bmac-native` and `btouch-native`
tools, you need to use the `Dispose` attribute to inject some code in the
generated `Dispose` method implementation.
@ -1348,7 +1313,7 @@ interface DatabaseConnection {
}
```
<a name="ExportAttribute" class="injected"></a>
<a name="ExportAttribute" />
## ExportAttribute
@ -1380,12 +1345,12 @@ public class ExportAttribute : Attribute {
The [selector](http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocSelectors.html) and it represents the underlying Objective-C name
of the method or property that is being bound.
<a name="ExportAttribute.ArgumentSemantic" class="injected"></a>
<a name="ExportAttribute.ArgumentSemantic" />
### ExportAttribute.ArgumentSemantic
<a name="FieldAttribute" class="injected"></a>
<a name="FieldAttribute" />
## FieldAttribute
@ -1446,6 +1411,7 @@ wrapper that exposes the underlying functionality.
For example:
```
[Internal]
[Export ("setValue:forKey:");
void _SetValueForKey (NSObject value, NSObject key);
@ -1453,7 +1419,7 @@ void _SetValueForKey (NSObject value, NSObject key);
[Internal]
[Export ("getValueForKey:")]
NSObject _GetValueForKey (NSObject key);
```
Then, in your supporting file, you could have some code like this:
@ -1475,7 +1441,7 @@ This attribute flags the backing field for a property to be annotated with
the .NET `[ThreadStatic]` attribute. This is useful if the field is a thread
static variable.
<a name="MarshalNativeExceptions_(Xamarin.iOS_6.0.6)" class="injected"></a>
<a name="MarshalNativeExceptions_(Xamarin.iOS_6.0.6)" />
## MarshalNativeExceptions (Xamarin.iOS 6.0.6)
@ -1490,7 +1456,7 @@ if a signature isn't supported when native linking of an app that uses the
binding fails with a missing monotouch_*_objc_msgSend* symbol), but more can be
added at request.
<a name="NewAttribute" class="injected"></a>
<a name="NewAttribute" />
## NewAttribute
@ -1501,7 +1467,7 @@ generate the "new" keyword in front of the declaration.
It is used to avoid compiler warnings when the same method or property name
is introduced in a subclass that already existed in a base class.
<a name="NotificationAttribute" class="injected"></a>
<a name="NotificationAttribute" />
## NotificationAttribute
@ -1542,11 +1508,11 @@ public class MyClass {
Users of your code can then easily subscribe to notifications posted
to the
[NSDefaultCenter](http://iosapi.xamarin.com/?link=P%3aMonoTouch.Foundation.NSNotificationCenter.DefaultCenter)
[NSDefaultCenter](/api/property/Foundation.NSNotificationCenter.DefaultCenter/)
by using code like this:
```
var token = MyClass.Notifications.ObserverDidStart ((notification) => {
var token = MyClass.Notifications.ObserverDidStart ((notification) => {
Console.WriteLine ("Observed the 'DidStart' event!");
});
```
@ -1554,7 +1520,7 @@ var token = MyClass.Notifications.ObserverDidStart ((notification) => {
Or to set a specific object to observe. If you pass `null` to `objectToObserve` this method will behave just like its other peer.
```
var token = MyClass.Notifications.ObserverDidStart (objectToObserve, (notification) => {
var token = MyClass.Notifications.ObserverDidStart (objectToObserve, (notification) => {
Console.WriteLine ("Observed the 'DidStart' event on objectToObserve!");
});
```
@ -1567,7 +1533,7 @@ token.Dispose ();
```
Or you can call [NSNotification.DefaultCenter.RemoveObserver](http://iosapi.xamarin.com/?link=M%3aMonoTouch.Foundation.NSNotificationCenter.RemoveObserver(MonoTouch.Foundation.NSObject))
Or you can call [NSNotification.DefaultCenter.RemoveObserver](/api/member/Foundation.NSNotificationCenter.RemoveObserver/p/Foundation.NSObject//)
and pass the token. If your notification contains parameters, you
should specify a helper `EventArgs` interface, like this:
@ -1594,7 +1560,7 @@ interface MyScreenChangedEventArgs {
The above will generate a `MyScreenChangedEventArgs` class with the
`ScreenX` and `ScreenY` properties that will fetch the data from the
[NSNotification.UserInfo](http://iosapi.xamarin.com/?link=P%3aMonoTouch.Foundation.NSNotification.UserInfo)
[NSNotification.UserInfo](/api/property/Foundation.NSNotification.UserInfo/)
dictionary using the keys **ScreenXKey** and **ScreenYKey**
respectively and apply the proper conversions. The `[ProbePresence]`
attribute is used for the generator to probe if the key is set in the
@ -1616,7 +1582,7 @@ sometimes uses string constants. By default the `[Export]` attribute
in your provided `EventArgs` class will use the specified name as a
public symbol to be looked up at runtime. If this is not the case,
and instead it is supposed to be looked up as a string constant then
pass the `ArgumentSemantic.Assign` value to the Export attribute. <a name="NullAllowedAttribute" class="injected"></a>
pass the `ArgumentSemantic.Assign` value to the Export attribute.
**New in Xamarin.iOS 8.4**
@ -1679,7 +1645,7 @@ void SetImage ([NullAllowed] UIImage image, State forState);
Use this attribute to instruct the binding generator that the binding for
this particular method should be flagged with an "override" keyword.
<a name="PreSnippetAttribute" class="injected"></a>
<a name="PreSnippetAttribute" />
## PreSnippetAttribute
@ -1695,7 +1661,7 @@ Example:
void Demo ();
```
<a name="PrologueSnippetAttribute" class="injected"></a>
<a name="PrologueSnippetAttribute" />
## PrologueSnippetAttribute
@ -1711,7 +1677,7 @@ Example:
void Demo ();
```
<a name="PostGetAttribute" class="injected"></a>
<a name="PostGetAttribute" />
## PostGetAttribute
@ -1735,10 +1701,10 @@ Example:
public interface NSOperation {
[Export ("addDependency:")][PostGet ("Dependencies")]
void AddDependency (NSOperation op);
[Export ("removeDependency:")][PostGet ("Dependencies")]
void RemoveDependency (NSOperation op);
[Export ("dependencies")]
NSOperation [] Dependencies { get; }
}
@ -1749,7 +1715,7 @@ adding or removing dependencies from the `NSOperation` object, ensuring that we
have a graph that represents the actual loaded objects, preventing both memory
leaks as well as memory corruption.
<a name="PostSnippetAttribute" class="injected"></a>
<a name="PostSnippetAttribute" />
## PostSnippetAttribute
@ -1765,7 +1731,7 @@ Example:
void Demo ();
```
<a name="ProxyAttribute" class="injected"></a>
<a name="ProxyAttribute" />
## ProxyAttribute
@ -1776,7 +1742,7 @@ differentiated from user bindings. The effect of this attribute is to flag the
object as being a `DirectBinding` object. For a scenario in Xamarin.Mac, you can see
the [discussion on this bug](https://bugzilla.novell.com/show_bug.cgi?id=670844).
<a name="RetainListAttribute" class="injected"></a>
<a name="RetainListAttribute" />
## RetainListAttribute
@ -1800,7 +1766,7 @@ class to the API.
For an example see [foundation.cs](https://github.com/mono/maccore/blob/master/src/foundation.cs) and [NSNotificationCenter.cs](https://github.com/mono/maccore/blob/master/src/Foundation/NSNotificationCenter.cs)
<a name="ReleaseAttribute_(Xamarin.iOS_6.0)" class="injected"></a>
<a name="ReleaseAttribute_(Xamarin.iOS_6.0)" />
## ReleaseAttribute (Xamarin.iOS 6.0)
@ -1822,7 +1788,7 @@ Additionally this attribute is propagated to the generated code, so that
the Xamarin.iOS runtime knows it must retain the object upon returning to
Objective-C from such a function.
<a name="SealedAttribute" class="injected"></a>
<a name="SealedAttribute" />
## SealedAttribute
@ -1832,7 +1798,7 @@ attribute is not specified, the default is to generate a virtual method (either
a virtual method, an abstract method or an override depending on how other
attributes are used).
<a name="StaticAttribute" class="injected"></a>
<a name="StaticAttribute" />
## StaticAttribute
@ -1841,7 +1807,7 @@ When the `Static` attribute is applied to a method or property this generates a
static method or property. If this attribute is not specified, then the
generator produces an instance method or property.
<a name="TransientAttribute" class="injected"></a>
<a name="TransientAttribute" />
## TransientAttribute
@ -1852,7 +1818,7 @@ attribute is applied to a property, the generator does not create a backing
field for this property, which means that the managed class does not keep a
reference to the object.
<a name="WrapAttribute" class="injected"></a>
<a name="WrapAttribute" />
## WrapAttribute
@ -1912,7 +1878,7 @@ to declare his intent and that he does not have to manually decorate the method
with `Export`, since we did that work in the binding for the user:
```
// This is the strong case,
// This is the strong case,
class MyDelegate : DemoDelegate {
override void Demo DoDemo () {}
}
@ -1922,7 +1888,7 @@ var strongDemo = new Demo ();
demo.Delegate = new MyDelegate ();
```
<a name="Parameter_Attributes" class="injected"></a>
<a name="Parameter_Attributes" />
Another use of the `Wrap` attribute is to support strongly typed version
of methods. For example:
@ -1951,7 +1917,6 @@ interface FooExplorer {
}
```
# Parameter Attributes
This section describes the attributes that you can apply to the parameters in
@ -2015,7 +1980,7 @@ Allows the following code to be written:
foo.LoadFiles (new NSUrl (url1), new NSUrl (url2), new NSUrl (url3));
This has the added advantage that it does not require users
to create an array purely for passing elements.
to create an array purely for passing elements.
## PlainString
@ -2045,7 +2010,7 @@ void SetText (string theText);
void LogMessage ([PlainString] string theText);
```
<a name="RetainAttribute" class="injected"></a>
<a name="RetainAttribute" />
## RetainAttribute
@ -2070,7 +2035,7 @@ public class RetainAttribute {
}
```
<a name="RetainListAttribute" class="injected"></a>
<a name="RetainListAttribute" />
## RetainListAttribute
@ -2131,7 +2096,7 @@ methods on it will throw an exception).
If the object passed was not created, or if there was
already an outstanding managed representation of the object,
the forced dispose does not take place. <a name="Global_Attributes" class="injected"></a>
the forced dispose does not take place. <a name="Global_Attributes" />
# Property Attributes
@ -2157,11 +2122,11 @@ interface MyString {
IntPtr Constructor (string value);
[Export ("value")]
string Value {
get;
string Value {
get;
[NotImplemented ("Not available on MyString, use MyMutableString to set")]
set;
[NotImplemented ("Not available on MyString, use MyMutableString to set")]
set;
}
}
@ -2193,7 +2158,7 @@ enum NSRunLoopMode {
[Field ("NSRunLoopCommonModes")]
Common,
[Field (null)]
Other = 1000
}
@ -2272,14 +2237,13 @@ Call (NSRunLoopModeExtensions.GetValue (constant)); // will return 1000
If no `null` value is present then an `ArgumentNullException` will be thrown.
# Global Attributes
Global attributes are either applied using the `[assembly:]` attribute modifier
like the `LinkWithAttribute` or can be used anywhere, like the `Lion` and `Since`
attributes.
<a name="LinkWithAttribute" class="injected"></a>
<a name="LinkWithAttribute" />
## LinkWithAttribute
@ -2331,14 +2295,14 @@ into the resulting assembly, allowing users to ship a single DLL that contains
both the unmanaged dependencies as well as the command line flags necessary to
properly consume the library from Xamarin.iOS.
It' s also possible to not provide a `libraryName`, in which case the
It's also possible to not provide a `libraryName`, in which case the
`LinkWith` attribute can be used to only specify additional linker flags:
``` csharp
[assembly: LinkWith (LinkerFlags = "-lsqlite3")]
```
<a name="LinkWithAttribute_Constructors" class="injected"></a>
<a name="LinkWithAttribute_Constructors" />
### LinkWithAttribute Constructors
@ -2365,7 +2329,7 @@ Examples:
[assembly: LinkWith ("libDemo.a", LinkTarget.Thumb | LinkTarget.Simulator, SmartLink = true, ForceLoad = true, IsCxx = true);
```
<a name="LinkWithAttribute.ForceLoad" class="injected"></a>
<a name="LinkWithAttribute.ForceLoad" />
### LinkWithAttribute.ForceLoad
@ -2374,7 +2338,7 @@ The `ForceLoad` property is used to decide whether or not the `-force_load` link
flag is used for linking the native library. For now, this should always be
true.
<a name="LinkWithAttribute.Frameworks" class="injected"></a>
<a name="LinkWithAttribute.Frameworks" />
### LinkWithAttribute.Frameworks
@ -2385,7 +2349,7 @@ containing a space-delimited list of the required platform frameworks. For
example, if you are binding a library that requires `CoreGraphics` and `CoreText`,
you would set the `Frameworks` property to `"CoreGraphics CoreText"`.
<a name="LinkWithAttribute.IsCxx" class="injected"></a>
<a name="LinkWithAttribute.IsCxx" />
### LinkWithAttribute.IsCxx
@ -2394,7 +2358,7 @@ Set this property to true if the resulting executable needs to be compiled
using a C++ compiler instead of the default, which is a C compiler. Use this if
the library that you are binding was written in C++.
<a name="LinkWithAttribute.LibraryName" class="injected"></a>
<a name="LinkWithAttribute.LibraryName" />
### LinkWithAttribute.LibraryName
@ -2407,7 +2371,7 @@ Earlier versions of Xamarin.iOS checked the `LinkTarget` property to determine
the platform your library supported, but this is now auto-detected, and the
`LinkTarget` property is ignored.
<a name="LinkWithAttribute.LinkerFlags" class="injected"></a>
<a name="LinkWithAttribute.LinkerFlags" />
### LinkWithAttribute.LinkerFlags
@ -2419,7 +2383,7 @@ application.
For example, if the native library requires libxml2 and zlib, you would set
the `LinkerFlags` string to `"-lxml2 -lz"`.
<a name="LinkWithAttribute.LinkTarget" class="injected"></a>
<a name="LinkWithAttribute.LinkTarget" />
### LinkWithAttribute.LinkTarget
@ -2428,7 +2392,6 @@ Earlier versions of Xamarin.iOS checked the `LinkTarget` property to determine
the platform your library supported, but this is now auto-detected, and the
`LinkTarget` property is ignored.
<a name="LinkWithAttribute.NeedsGccExceptionHandling" class="injected"></a>
### LinkWithAttribute.NeedsGccExceptionHandling
@ -2436,7 +2399,7 @@ the platform your library supported, but this is now auto-detected, and the
Set this property to true if the library that you are linking requires the
GCC Exception Handling library (gcc_eh)
<a name="LinkWithAttribute.SmartLink" class="injected"></a>
<a name="LinkWithAttribute.SmartLink" />
### LinkWithAttribute.SmartLink
@ -2444,7 +2407,7 @@ GCC Exception Handling library (gcc_eh)
The `SmartLink` property should be set to true to let Xamarin.iOS determine
whether `ForceLoad` is required or not.
<a name="LinkWithAttribute.WeakFrameworks" class="injected"></a>
<a name="LinkWithAttribute.WeakFrameworks" />
### LinkWithAttribute.WeakFrameworks
@ -2463,7 +2426,7 @@ Good candidates for weak linking would be `Frameworks` like Accounts,
`CoreBluetooth`, `CoreImage`, `GLKit`, `NewsstandKit` and `Twitter` since they are only
available in iOS 5.
<a name="SinceAttribute_(iOS)_and_LionAttribute_(MacOS_X)" class="injected"></a>
<a name="SinceAttribute_(iOS)_and_LionAttribute_(MacOS_X)" />
## SinceAttribute (iOS) and LionAttribute (MacOS X)
@ -2506,8 +2469,8 @@ public interface UITableViewController {
[Export ("tableView", ArgumentSemantic.Retain)]
UITableView TableView { get; set; }
[Since (3,2)]
[Export ("clearsSelectionOnViewWillAppear")]
[Since (3,2)]
[Export ("clearsSelectionOnViewWillAppear")]
bool ClearsSelectionOnViewWillAppear { get; set; }
```
@ -2517,7 +2480,7 @@ used in iOS is that iOS is revised very often, while major OS X releases happen
rarely and it is easier to remember the operating system by their codename than
by their version number
<a name="AdviceAttribute" class="injected"></a>
<a name="AdviceAttribute" />
## AdviceAttribute
@ -2532,7 +2495,7 @@ better API.
The information from this attribute is shown in the documentation
and tools can be developed to give user suggestions on how to improve
his code. <a name="ZeroCopyStringsAttribute" class="injected"></a>
his code. <a name="ZeroCopyStringsAttribute" />
## ZeroCopyStringsAttribute
@ -2583,10 +2546,10 @@ With Xamarin.iOS 8.0 we introduced support for easily creating
Strongly Typed classes that wrap `NSDictionaries`.
While it has always been possible to use the
[DictionaryContainer](http://iosapi.xamarin.com/?link=T%3aMonoTouch.Foundation.DictionaryContainer)
[DictionaryContainer](/api/type/Foundation.DictionaryContainer/)
data type together with a manual API, it is now a lot simpler to do
this. For a walkthrough, see [Surfacing Strong
Types](/guides/ios/advanced_topics/binding_objc_libs#Surfacing_Strong_Types).
this. For more information, see [Surfacing Strong
Types](/guides/cross-platform/macios/binding/objective-c-libraries/#Surfacing_Strong_Types_for_weak_NSDictionary_parameters).
<a name="StrongDictionar"/>
@ -2594,7 +2557,7 @@ Types](/guides/ios/advanced_topics/binding_objc_libs#Surfacing_Strong_Types).
When this attribute is applied to an interface, the generator will
produce a class with the same name as the interface that derives from
[DictionaryContainer](http://iosapi.xamarin.com/?link=T%3aFoundation.DictionaryContainer)
[DictionaryContainer](/api/type/Foundation.DictionaryContainer/)
and turns each property defined in the interface into a strongly typed
getter and setter for the dictionary.
@ -2731,6 +2694,3 @@ definition:
<td>NSArray containing NSNumbers with the value</td>
</tr>
</tbody>

Просмотреть файл

@ -1,5 +1,8 @@
id:{505F978C-9553-49A8-9632-0D6D8A0A0287}
title:Xamarin.iOS/Xamarin.Mac binding errors
---
id: 505F978C-9553-49A8-9632-0D6D8A0A0287
title: "Xamarin.iOS/Xamarin.Mac binding errors"
dateupdated: 2017-06-26
---
[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)
[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)
@ -10,7 +13,7 @@ title:Xamarin.iOS/Xamarin.Mac binding errors
E.g. parameters, environment
<!-- 0xxx: the generator itself, e.g. parameters, environment -->
<h3><a name="BI0000"/>BI0000: Unexpected error - Please fill a bug report at https://bugzilla.xamarin.com</h3>
### <a name="BI0000"/>BI0000: Unexpected error - Please fill a bug report at https://bugzilla.xamarin.com
An unexpected error condition occurred. Please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with as much information as possible, including:
@ -20,19 +23,19 @@ An unexpected error condition occurred. Please [file a bug report](https://bugzi
The easiest way to get exact version information is to use the **Xamarin Studio** menu, **About Xamarin Studio** item, **Show Details** button and copy/paste the version informations (you can use the **Copy Information** button).
<h3><a name='BI0001'/>BI0001: The .NET runtime could not load the {mi.ReturnType.Name} type. Message: {ex.Message}</h3>
### <a name='BI0001'/>BI0001: The .NET runtime could not load the {mi.ReturnType.Name} type. Message: {ex.Message}
<h3><a name='BI0026'/>BI0026: Could not parse the command line argument '{argument}': {message}</h3>
### <a name='BI0026'/>BI0026: Could not parse the command line argument '{argument}': {message}
<h3><a name='BI0068'/>BI0068: Invalid value for target framework: *.</h3>
### <a name='BI0068'/>BI0068: Invalid value for target framework: *.
An invalid target framework was passed using the --target-framework argument. Please specify a valid target framework.
<h3><a name='BI0070'/>BI0070: Invalid target framework: *. Valid target frameworks are: *.</h3>
### <a name='BI0070'/>BI0070: Invalid target framework: *. Valid target frameworks are: *.
An invalid target framework was passed using the --target-framework argument. Please specify a valid target framework.
<h3><a name='BI0086'/>BI0086: A target framework (--target-framework) must be specified when building for *.</h3>
### <a name='BI0086'/>BI0086: A target framework (--target-framework) must be specified when building for *.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS) with a test case.
@ -41,169 +44,169 @@ This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug repo
<!-- 1xxx: code generation -->
<!-- 10xx: errors -->
<h3><a name='BI1001'/>BI1001: Do not know how to make a trampoline for *</h3>
### <a name='BI1001'/>BI1001: Do not know how to make a trampoline for *
<h3><a name='BI1002'/>BI1002: Unknown kind * in method '*'</h3>
### <a name='BI1002'/>BI1002: Unknown kind * in method '*'
<h3><a name='BI1003'/>BI1003: The delegate method *.* needs to take at least one parameter</h3>
### <a name='BI1003'/>BI1003: The delegate method *.* needs to take at least one parameter
<h3><a name='BI1004'/>BI1004: The delegate method *.* is missing the [EventArgs] attribute (has * parameters)</h3>
### <a name='BI1004'/>BI1004: The delegate method *.* is missing the [EventArgs] attribute (has * parameters)
<h3><a name='BI1005'/>BI1005: EventArgs in *.* attribute should not include the text `EventArgs' at the end</h3>
### <a name='BI1005'/>BI1005: EventArgs in *.* attribute should not include the text `EventArgs' at the end
<h3><a name='BI1006'/>BI1006: The delegate method *.* is missing the [DelegateName] attribute (or EventArgs)</h3>
### <a name='BI1006'/>BI1006: The delegate method *.* is missing the [DelegateName] attribute (or EventArgs)
<h3><a name='BI1007'/>BI1007: Unknown attribute * on *</h3>
### <a name='BI1007'/>BI1007: Unknown attribute * on *
<h3><a name='BI1008'/>BI1008: [IsThreadStatic] is only valid on properties that are also [Static]</h3>
### <a name='BI1008'/>BI1008: [IsThreadStatic] is only valid on properties that are also [Static]
<h3><a name='BI1009'/>BI1009: No selector specified for method `*.*'</h3>
### <a name='BI1009'/>BI1009: No selector specified for method `*.*'
<h3><a name='BI1010'/>BI1010: No Export attribute on *.* property</h3>
### <a name='BI1010'/>BI1010: No Export attribute on *.* property
<h3><a name='BI1011'/>BI1011: Do not know how to extract type */* from an NSDictionary</h3>
### <a name='BI1011'/>BI1011: Do not know how to extract type */* from an NSDictionary
<h3><a name='BI1012'/>BI1012: No Export or Bind attribute defined on *.*</h3>
### <a name='BI1012'/>BI1012: No Export or Bind attribute defined on *.*
<h3><a name='BI1013'/>BI1013: Unsupported type for Fields (string), you probably meant NSString</h3>
### <a name='BI1013'/>BI1013: Unsupported type for Fields (string), you probably meant NSString
<h3><a name='BI1014'/>BI1014: Unsupported type for Fields: *</h3>
### <a name='BI1014'/>BI1014: Unsupported type for Fields: *
<h3><a name='BI1015'/>BI1015: In class * You specified the Events property, but did not bind those to names with Delegates</h3>
### <a name='BI1015'/>BI1015: In class * You specified the Events property, but did not bind those to names with Delegates
<h3><a name='BI1016'/>BI1016: The delegate method *.* is missing the [DefaultValue] attribute</h3>
### <a name='BI1016'/>BI1016: The delegate method *.* is missing the [DefaultValue] attribute
<h3><a name='BI1017'/>BI1017: Do not know how to make a signature for *</h3>
### <a name='BI1017'/>BI1017: Do not know how to make a signature for *
<h3><a name='BI1018'/>BI1018: No [Export] attribute on property *.*</h3>
### <a name='BI1018'/>BI1018: No [Export] attribute on property *.*
<h3><a name='BI1019'/>BI1019: Invalid [NoDefaultValue] attribute on method `*.*'</h3>
### <a name='BI1019'/>BI1019: Invalid [NoDefaultValue] attribute on method `*.*'
<h3><a name='BI1020'/>BI1020: Unsupported type * used on exported method *.*</h3>
### <a name='BI1020'/>BI1020: Unsupported type * used on exported method *.*
<h3><a name='BI1021'/>BI1021: Unsupported type for read/write Fields: *</h3>
### <a name='BI1021'/>BI1021: Unsupported type for read/write Fields: *
<h3><a name='BI1022'/>BI1022: Model classes can not be categories</h3>
### <a name='BI1022'/>BI1022: Model classes can not be categories
<h3><a name='BI1023'/>BI1023: The number of Events (Type) and Delegates (string) must match for `*`</h3>
### <a name='BI1023'/>BI1023: The number of Events (Type) and Delegates (string) must match for `*`
<h3><a name='BI1024'/>BI1024: No selector specified for property '*.*'</h3>
### <a name='BI1024'/>BI1024: No selector specified for property '*.*'
<h3><a name='BI1025'/>BI1025: [Static] and [Protocol] are mutually exclusive (*)</h3>
### <a name='BI1025'/>BI1025: [Static] and [Protocol] are mutually exclusive (*)
<h3><a name='BI1026'/>BI1026: `*`: Enums attributed with [*] must have an underlying type of `long` or `ulong`</h3>
### <a name='BI1026'/>BI1026: `*`: Enums attributed with [*] must have an underlying type of `long` or `ulong`
<h3><a name='BI1027'/>BI1027: Support for ZeroCopy strings is not implemented. Strings will be marshalled as NSStrings.</h3>
### <a name='BI1027'/>BI1027: Support for ZeroCopy strings is not implemented. Strings will be marshalled as NSStrings.
<h3><a name='BI1028'/>BI1028: Internal sanity check failed, please file a bug report (http://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1028'/>BI1028: Internal sanity check failed, please file a bug report (http://bugzilla.xamarin.com) with a test case.
<h3><a name='BI1029'/>BI1029: Internal error: invalid enum mode for type '*'</h3>
### <a name='BI1029'/>BI1029: Internal error: invalid enum mode for type '*'
<h3><a name='BI1030'/>BI1030: * cannot have [BaseType(typeof(*))] as it creates a circular dependency</h3>
### <a name='BI1030'/>BI1030: * cannot have [BaseType(typeof(*))] as it creates a circular dependency
<h3><a name='BI1031'/>BI1031: The [Target] attribute is not supported for the Unified API (found on the member '*.*'). For Objective-C categories, create an api definition interface with the [Category] attribute instead.</h3>
### <a name='BI1031'/>BI1031: The [Target] attribute is not supported for the Unified API (found on the member '*.*'). For Objective-C categories, create an api definition interface with the [Category] attribute instead.
<h3><a name='BI1034'/>BI1034: The [Protocolize] attribute is set on the property *.*, but the property's type (*) is not a protocol.</h3>
### <a name='BI1034'/>BI1034: The [Protocolize] attribute is set on the property *.*, but the property's type (*) is not a protocol.
<h3><a name='BI1035'/>BI1035: The property * on class * is hiding a property from a parent class * but the selectors do not match.</h3>
### <a name='BI1035'/>BI1035: The property * on class * is hiding a property from a parent class * but the selectors do not match.
<h3><a name='BI1036'/>BI1036: The last parameter in the method '*.*' must be a delegate (it's '*').</h3>
### <a name='BI1036'/>BI1036: The last parameter in the method '*.*' must be a delegate (it's '*').
<h3><a name='BI1037'/>BI1037: The selector * on type * is found multiple times with both read only and write only versions, with no read/write version.</h3>
### <a name='BI1037'/>BI1037: The selector * on type * is found multiple times with both read only and write only versions, with no read/write version.
<h3><a name='BI1038'/>BI1038: The selector * on type * is found multiple times with different return types.</h3>
### <a name='BI1038'/>BI1038: The selector * on type * is found multiple times with different return types.
<h3><a name='BI1039'/>BI1039: The selector * on type * is found multiple times with different argument length * : *.</h3>
### <a name='BI1039'/>BI1039: The selector * on type * is found multiple times with different argument length * : *.
<h3><a name='BI1040'/>BI1040: The selector * on type * is found multiple times with different argument out states on argument *.</h3>
### <a name='BI1040'/>BI1040: The selector * on type * is found multiple times with different argument out states on argument *.
<h3><a name='BI1041'/>BI1041: The selector * on type * is found multiple times with different argument types on argument * - * : *.</h3>
### <a name='BI1041'/>BI1041: The selector * on type * is found multiple times with different argument types on argument * - * : *.
<h3><a name='BI1042'/>BI1042: Missing '[Field (LibraryName=value)]' for {field_pi.Name} (e.g."__Internal")</h3>
### <a name='BI1042'/>BI1042: Missing '[Field (LibraryName=value)]' for {field_pi.Name} (e.g."__Internal")
<h3><a name='BI1043'/>BI1043: Repeated overload {mi.Name} and no [DelegateApiNameAttribute] provided to generate property name on host class.</h3>
### <a name='BI1043'/>BI1043: Repeated overload {mi.Name} and no [DelegateApiNameAttribute] provided to generate property name on host class.
<h3><a name='BI1044'/>BI1044: Repeated name '{apiName.Name}' provided in [DelegateApiNameAttribute].</h3>
### <a name='BI1044'/>BI1044: Repeated name '{apiName.Name}' provided in [DelegateApiNameAttribute].
<h3><a name='BI1045'/>BI1045: Only a single [DefaultEnumValue] attribute can be used inside enum {type.Name}.</h3>
### <a name='BI1045'/>BI1045: Only a single [DefaultEnumValue] attribute can be used inside enum {type.Name}.
<h3><a name='BI1046'/>BI1046: The [Field] constant {fa.SymbolName} cannot only be used once inside enum {type.Name}.</h3>
### <a name='BI1046'/>BI1046: The [Field] constant {fa.SymbolName} cannot only be used once inside enum {type.Name}.
<h3><a name='BI1047'/>BI1047: Unsupported platform: *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1047'/>BI1047: Unsupported platform: *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.
<h3><a name='BI1048'/>BI1048: Unsupported type * decorated with [BindAs].</h3>
### <a name='BI1048'/>BI1048: Unsupported type * decorated with [BindAs].
<h3><a name='BI1049'/>BI1049: Could not unbox type * from * container used on * member decorated with [BindAs].</h3>
### <a name='BI1049'/>BI1049: Could not unbox type * from * container used on * member decorated with [BindAs].
<h3><a name='BI1050'/>BI1050: [BindAs] cannot be used inside Protocol or Model types. Type: *</h3>
### <a name='BI1050'/>BI1050: [BindAs] cannot be used inside Protocol or Model types. Type: *
<h3><a name='BI1051'/>BI1051: Internal error: Don't know how to get attributes for *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1051'/>BI1051: Internal error: Don't know how to get attributes for *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.
<h3><a name='BI1052'/>BI1052: Internal error: Could not find the type * in the assembly *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1052'/>BI1052: Internal error: Could not find the type * in the assembly *. Please file a bug report (http://bugzilla.xamarin.com) with a test case.
<h3><a name='BI1053'/>BI1053: Internal error: unknown target framework '*'.</h3>
### <a name='BI1053'/>BI1053: Internal error: unknown target framework '*'.
<h3><a name='BI1054'/>BI1054: Internal error: can't convert type '*' (unknown assembly). Please file a bug report (https://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1054'/>BI1054: Internal error: can't convert type '*' (unknown assembly). Please file a bug report (https://bugzilla.xamarin.com) with a test case.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with a test case.
<h3><a name='BI1055'/>BI1055: Internal error: failed to convert type '*'. Please file a bug report (https://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1055'/>BI1055: Internal error: failed to convert type '*'. Please file a bug report (https://bugzilla.xamarin.com) with a test case.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with a test case.
<h3><a name='BI1056'/>BI1056: Internal error: failed to instantiate mock attribute '*' (could not convert type constructor argument #*). Please file a bug report (https://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1056'/>BI1056: Internal error: failed to instantiate mock attribute '*' (could not convert type constructor argument #*). Please file a bug report (https://bugzilla.xamarin.com) with a test case.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with a test case.
<h3><a name='BI1057'/>BI1057: Internal error: failed to instantiate mock attribute '*' (could not convert constructor type #* (*)). Please file a bug report (https://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1057'/>BI1057: Internal error: failed to instantiate mock attribute '*' (could not convert constructor type #* (*)). Please file a bug report (https://bugzilla.xamarin.com) with a test case.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with a test case.
<h3><a name='BI1058'/>BI1058: Internal error: could not find a constructor for the mock attribute '*'. Please file a bug report (https://bugzilla.xamarin.com) with a test case.</h3>
### <a name='BI1058'/>BI1058: Internal error: could not find a constructor for the mock attribute '*'. Please file a bug report (https://bugzilla.xamarin.com) with a test case.
This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=iOS&component=Tools) with a test case.
<h3><a name='BI1059'/>BI1059: Found * * attributes on the member *. At most one was expected.</h3>
### <a name='BI1059'/>BI1059: Found * * attributes on the member *. At most one was expected.
<h3><a name='BI1060'/>BI1060: The * protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model].</h3>
### <a name='BI1060'/>BI1060: The * protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model].
<h3><a name='BI1061'/>BI1061: The attribute '{attribute}' found on '{member}' is not a valid binding attribute. Please remove this attribute.</h3>
### <a name='BI1061'/>BI1061: The attribute '{attribute}' found on '{member}' is not a valid binding attribute. Please remove this attribute.
# BI11xx: warnings
<!-- 11xx: warnings -->
<h3><a name='BI1101'/>BI1101: Trying to use a string as a [Target]</h3>
### <a name='BI1101'/>BI1101: Trying to use a string as a [Target]
<h3><a name='BI1102'/>BI1102: Using the deprecated EventArgs for a delegate signature in *.*, please use DelegateName instead</h3>
### <a name='BI1102'/>BI1102: Using the deprecated EventArgs for a delegate signature in *.*, please use DelegateName instead
<h3><a name='BI1103'/>BI1103: '*' does not live under a namespace; namespaces are a highly recommended .NET best practice</h3>
### <a name='BI1103'/>BI1103: '*' does not live under a namespace; namespaces are a highly recommended .NET best practice
<h3><a name='BI1104'/>BI1104: Could not load the referenced library '*': *.</h3>
### <a name='BI1104'/>BI1104: Could not load the referenced library '*': *.
<h3><a name='BI1105'/>BI1105: Potential selector/argument mismatch [Export ("*")] has * arguments and *.* has * arguments</h3>
### <a name='BI1105'/>BI1105: Potential selector/argument mismatch [Export ("*")] has * arguments and *.* has * arguments
<h3><a name='BI1106'/>BI1106: The parameter * in the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*)</h3>
### <a name='BI1106'/>BI1106: The parameter * in the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*)
<h3><a name='BI1107'/>BI1107: The return type of the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).</h3>
### <a name='BI1107'/>BI1107: The return type of the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).
<h3><a name='BI1108'/>BI1108: The [Protocolize] attribute is applied to the return type of the method *.*, but the return type (*) isn't a model and can thus not be protocolized. Please remove the [Protocolize] attribute.</h3>
### <a name='BI1108'/>BI1108: The [Protocolize] attribute is applied to the return type of the method *.*, but the return type (*) isn't a model and can thus not be protocolized. Please remove the [Protocolize] attribute.
<h3><a name='BI1109'/>BI1109: The return type of the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).</h3>
### <a name='BI1109'/>BI1109: The return type of the method *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).
<h3><a name='BI1110'/>BI1110: The property *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).</h3>
### <a name='BI1110'/>BI1110: The property *.* exposes a model (*). Please expose the corresponding protocol type instead (*.I*).
<h3><a name='BI1111'/>BI1111: Interface '*' on '*' is being ignored as it is not a protocol. Did you mean '*' instead?</h3>
### <a name='BI1111'/>BI1111: Interface '*' on '*' is being ignored as it is not a protocol. Did you mean '*' instead?
<h3><a name='BI1112'/>BI1112: Property * should be renamed to 'Delegate' for BaseType.Events and BaseType.Delegates to work.</h3>
### <a name='BI1112'/>BI1112: Property * should be renamed to 'Delegate' for BaseType.Events and BaseType.Delegates to work.
<h3><a name='BI1113'/>BI1113: BaseType.Delegates were set but no properties could be found. Do ensure that the WrapAttribute is used on the right properties.</h3>
### <a name='BI1113'/>BI1113: BaseType.Delegates were set but no properties could be found. Do ensure that the WrapAttribute is used on the right properties.
<h3><a name='BI1114'/>BI1114: Binding error: test unable to find property: * on *.</h3>
### <a name='BI1114'/>BI1114: Binding error: test unable to find property: * on *.
<h3><a name='BI1115'/>BI1115: The parameter '*' in the delegate '*' does not have a [CCallback] or [BlockCallback] attribute. Defaulting to [CCallback].</h3>
### <a name='BI1115'/>BI1115: The parameter '*' in the delegate '*' does not have a [CCallback] or [BlockCallback] attribute. Defaulting to [CCallback].
<h3><a name='BI1116'/>BI1116: The parameter '*' in the delegate '*' does not have a [CCallback] or [BlockCallback] attribute. Defaulting to [CCallback]. Declare a custom delegate instead of using System.Action / System.Func and add the attribute on the corresponding parameter.</h3>
### <a name='BI1116'/>BI1116: The parameter '*' in the delegate '*' does not have a [CCallback] or [BlockCallback] attribute. Defaulting to [CCallback]. Declare a custom delegate instead of using System.Action / System.Func and add the attribute on the corresponding parameter.
<!-- 2xxx: reserved -->
<!-- 3xxx: reserved -->

Просмотреть файл

@ -1,5 +1,8 @@
id:{5B26339F-A202-4E41-9229-D0BC9E77868E}
title:Xamarin.Mac errors
---
id: 5B26339F-A202-4E41-9229-D0BC9E77868E
title: Xamarin.Mac errors
dateupdated: 2017-06-26
---
[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)
[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)
@ -9,7 +12,7 @@ title:Xamarin.Mac errors
E.g. parameters, environment, missing tools.
<h3><a name="MM0000">MM0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com</h3>
### <a name="MM0000">MM0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
An unexpected error condition occurred. Please [file a bug report](https://bugzilla.xamarin.com/enter_bug.cgi?product=Xamarin.Mac) with as much information as possible, including:
@ -19,142 +22,142 @@ An unexpected error condition occurred. Please [file a bug report](https://bugzi
The easiest way to get exact version information is to use the **Xamarin Studio** menu, **About Xamarin Studio** item, **Show Details** button and copy/paste the version informations (you can use the **Copy Information** button).
<h3><a name="MM0001">MM0001: This version of Xamarin.Mac requires Mono {0} (the current Mono version is {1}). Please update the Mono.framework from http://mono-project.com/Downloads</h3>
### <a name="MM0001">MM0001: This version of Xamarin.Mac requires Mono {0} (the current Mono version is {1}). Please update the Mono.framework from http://mono-project.com/Downloads
<h3><a name="MM0003">MM0003: Application name '{0}.exe' conflicts with an SDK or product assembly (.dll) name.</h3>
### <a name="MM0003">MM0003: Application name '{0}.exe' conflicts with an SDK or product assembly (.dll) name.
<h3><a name="MM0007">MM0007: The root assembly '{0}' does not exist</h3>
### <a name="MM0007">MM0007: The root assembly '{0}' does not exist
<h3><a name="MM0008">MM0008: You should provide one root assembly only, found {0} assemblies: '{1}'</h3>
### <a name="MM0008">MM0008: You should provide one root assembly only, found {0} assemblies: '{1}'
<h3><a name="MM0010">MM0010: Could not parse the command line arguments: {0}</h3>
### <a name="MM0010">MM0010: Could not parse the command line arguments: {0}
<!-- 0013 is unused -->
<h3><a name="MM0016">MM0016: The option '{0}' has been deprecated.</h3>
### <a name="MM0016">MM0016: The option '{0}' has been deprecated.
<h3><a name="MM0017">MM0017: You should provide a root assembly</h3>
### <a name="MM0017">MM0017: You should provide a root assembly
<h3><a name="MM0018">MM0018: Unknown command line argument: '{0}'</h3>
### <a name="MM0018">MM0018: Unknown command line argument: '{0}'
<h3><a name="MM0020">MM0020: The valid options for '{0}' are '{1}'.</h3>
### <a name="MM0020">MM0020: The valid options for '{0}' are '{1}'.
<h3><a name="MM0023">MM0023: Application name '{0}.exe' conflicts with another user assembly.</h3>
### <a name="MM0023">MM0023: Application name '{0}.exe' conflicts with another user assembly.
<h3><a name="MM0026">MM0026: Could not parse the command line argument '{0}': {1}</h3>
### <a name="MM0026">MM0026: Could not parse the command line argument '{0}': {1}
<h3><a name="MM0043">MM0043: The Boehm garbage collector is not supported. The SGen garbage collector has been selected instead.</h3>
### <a name="MM0043">MM0043: The Boehm garbage collector is not supported. The SGen garbage collector has been selected instead.
<h3><a name="MM0050">MM0050: You cannot provide a root assembly if --no-root-assembly is passed.</h3>
### <a name="MM0050">MM0050: You cannot provide a root assembly if --no-root-assembly is passed.
<h3><a name="MM0051">MM0051: An output directory (--output) is required if --no-root-assembly is passed.</h3>
### <a name="MM0051">MM0051: An output directory (--output) is required if --no-root-assembly is passed.
<h3><a name="MM0053">MM0053: Cannot disable new refcount with the Unified API.</h3>
### <a name="MM0053">MM0053: Cannot disable new refcount with the Unified API.
<h3><a name="MM0056">MM0056: Cannot find Xcode in any of our default locations. Please install Xcode, or pass a custom path using --sdkroot=<path></h3>
### <a name="MM0056">MM0056: Cannot find Xcode in any of our default locations. Please install Xcode, or pass a custom path using --sdkroot=<path>
<h3><a name="MM0059">MM0059: Could not find the currently selected Xcode on the system: {0};</h3>
### <a name="MM0059">MM0059: Could not find the currently selected Xcode on the system: {0};
<h3><a name="MM0060">MM0060: Could not find the currently selected Xcode on the system. 'xcode-select --print-path' returned '{0}', but that directory does not exist.</h3>
### <a name="MM0060">MM0060: Could not find the currently selected Xcode on the system. 'xcode-select --print-path' returned '{0}', but that directory does not exist.
<h3><a name="MM0068">MM0068: Invalid value for target framework: {0}.</h3>
### <a name="MM0068">MM0068: Invalid value for target framework: {0}.
<h3><a name="MM0079">MM0079: Internal Error - No executable was copied into the app bundle. Please contact 'support@xamarin.com'</h3>
### <a name="MM0079">MM0079: Internal Error - No executable was copied into the app bundle. Please contact 'support@xamarin.com'
<h3><a name="MM0080">MM0080: Disabling NewRefCount, --new-refcount:false, is deprecated.</h3>
### <a name="MM0080">MM0080: Disabling NewRefCount, --new-refcount:false, is deprecated.
<!-- 0088 used by mtouch -->
<!-- 0089 used by mtouch -->
<h3><a name="MM0097">MM0097: machine.config file '{0}' can not be found.</h3>
### <a name="MM0097">MM0097: machine.config file '{0}' can not be found.
<h3><a name="MM0098">MM0098: AOT compilation is only available on Unified</h3>
### <a name="MM0098">MM0098: AOT compilation is only available on Unified
<h3><a name="MM0099">MM0099: Internal error {0}. Please file a bug report with a test case (http://bugzilla.xamarin.com).</h3>
### <a name="MM0099">MM0099: Internal error {0}. Please file a bug report with a test case (http://bugzilla.xamarin.com).
<h3><a name="MM0114">MM0114: Hybrid AOT compilation requires all assemblies to be AOT compiled.</h3>
### <a name="MM0114">MM0114: Hybrid AOT compilation requires all assemblies to be AOT compiled.
# MM1xxx: file copy / symlinks (project related)
<h3><a name="MM1034">MM1034: Could not create symlink '{file}' -> '{target}': error {number}</h3>
### <a name="MM1034">MM1034: Could not create symlink '{file}' -> '{target}': error {number}
## MM14xx: Product assemblies
<h3><a name="MM1401">MM1401: The required '{0}' assembly is missing from the references</h3>
### <a name="MM1401">MM1401: The required '{0}' assembly is missing from the references
<h3><a name="MM1402">MM1402: The assembly '{0}' is not compatible with this tool</h3>
### <a name="MM1402">MM1402: The assembly '{0}' is not compatible with this tool
<h3><a name="MM1403">MM1403: {0} '{1}' could not be found. Target framework '{0}' is unusable to package the application.</h3>
### <a name="MM1403">MM1403: {0} '{1}' could not be found. Target framework '{0}' is unusable to package the application.
<h3><a name="MM1404">MM1404: Target framework '{0}' is invalid.</h3>
### <a name="MM1404">MM1404: Target framework '{0}' is invalid.
<h3><a name="MM1405">MM1405: useFullXamMacFramework must always target framework .NET 4.5, not '{0}' which is invalid</h3>
### <a name="MM1405">MM1405: useFullXamMacFramework must always target framework .NET 4.5, not '{0}' which is invalid
<h3><a name="MM1406">MM1406: Target framework '{0}' is invalid when targetting Xamarin.Mac 4.5 .NET framwork.</h3>
### <a name="MM1406">MM1406: Target framework '{0}' is invalid when targetting Xamarin.Mac 4.5 .NET framwork.
<h3><a name="MM1407">MM1407: Mismatch between Xamarin.Mac reference '{0}' and target framework selected '{1}'.</h3>
### <a name="MM1407">MM1407: Mismatch between Xamarin.Mac reference '{0}' and target framework selected '{1}'.
## MM15xx: Assembly gathering (not requiring linker) errors
<h3><a name="MM1501">MM1501: Can not resolve reference: {0}</h3>
### <a name="MM1501">MM1501: Can not resolve reference: {0}
## MachO.cs
<h3><a name="MM1600">MM1600: Not a Mach-O dynamic library (unknown header '0x{0}'): {1}.</h3>
### <a name="MM1600">MM1600: Not a Mach-O dynamic library (unknown header '0x{0}'): {1}.
<h3><a name="MM1601">MM1601: Not a static library (unknown header '{0}'): {1}.</h3>
### <a name="MM1601">MM1601: Not a static library (unknown header '{0}'): {1}.
<h3><a name="MM1602">MM1602: Not a Mach-O dynamic library (unknown header '0x{0}'): {1}.</h3>
### <a name="MM1602">MM1602: Not a Mach-O dynamic library (unknown header '0x{0}'): {1}.
<h3><a name="MM1603">MM1603: Unknown format for fat entry at position {0} in {1}.</h3>
### <a name="MM1603">MM1603: Unknown format for fat entry at position {0} in {1}.
<h3><a name="MM1604">MM1604: File of type {0} is not a MachO file ({1}).</h3>
### <a name="MM1604">MM1604: File of type {0} is not a MachO file ({1}).
# MM2xxx: Linker
## MM20xx: Linker (general) errors
<h3><a name="MM2001">MM2001: Could not link assemblies</h3>
### <a name="MM2001">MM2001: Could not link assemblies
<h3><a name="MM2002">MM2002: Can not resolve reference: {0}</h3>
### <a name="MM2002">MM2002: Can not resolve reference: {0}
<h3><a name="MM2003">MM2003: Option '{0}' will be ignored since linking is disabled</h3>
### <a name="MM2003">MM2003: Option '{0}' will be ignored since linking is disabled
<h3><a name="MM2004">MM2004: Extra linker definitions file '{0}' could not be located.</h3>
### <a name="MM2004">MM2004: Extra linker definitions file '{0}' could not be located.
<h3><a name="MM2005">MM2005: Definitions from '{0}' could not be parsed.</h3>
### <a name="MM2005">MM2005: Definitions from '{0}' could not be parsed.
<h3><a name="MM2006">MM2006: Native library '{0}' was referenced but could not be found.</h3>
### <a name="MM2006">MM2006: Native library '{0}' was referenced but could not be found.
<h3><a name="MM2007">MM2007: Xamarin.Mac Unified API against a full .NET profile does not support linking. Pass the -nolink flag.</h3>
### <a name="MM2007">MM2007: Xamarin.Mac Unified API against a full .NET profile does not support linking. Pass the -nolink flag.
<h3><a name="MM2009">MM2009: Referenced by {0}.{1} ** This message is related to MM2006 **</h3>
### <a name="MM2009">MM2009: Referenced by {0}.{1} ** This message is related to MM2006 **
<h3><a name="MM2010">MM2010: Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler</h3>
### <a name="MM2010">MM2010: Unknown HttpMessageHandler `{0}`. Valid values are HttpClientHandler (default), CFNetworkHandler or NSUrlSessionHandler
<h3><a name="MM2011">MM2011: Unknown TLSProvider `{0}. Valid values are default or appletls</h3>
### <a name="MM2011">MM2011: Unknown TLSProvider `{0}. Valid values are default or appletls
<h3><a name="MM2012">MM2012: Only first {0} of {1} "Referenced by" warnings shown. ** This message related to 2009 **</h3>
### <a name="MM2012">MM2012: Only first {0} of {1} "Referenced by" warnings shown. ** This message related to 2009 **
<h3><a name="MM2013">MM2013: Failed to resolve the reference to "{0}", referenced in "{1}". The app will not include the referenced assembly, and may fail at runtime.</h3>
### <a name="MM2013">MM2013: Failed to resolve the reference to "{0}", referenced in "{1}". The app will not include the referenced assembly, and may fail at runtime.
<h3><a name="MM2014">MM2014: Xamarin.Mac Extensions do not support linking. Request for linking will be ignored. ** This message is obsolete in XM 3.6+ **</h3>
### <a name="MM2014">MM2014: Xamarin.Mac Extensions do not support linking. Request for linking will be ignored. ** This message is obsolete in XM 3.6+ **
<!-- 2015 used by mtouch -->
<h3><a name="MM2016">MM2016: Invalid TlsProvider `{0}` option. The only valid value `{1}` will be used.</h3>
### <a name="MM2016">MM2016: Invalid TlsProvider `{0}` option. The only valid value `{1}` will be used.
<h3><a name="MM2017">MM2017: Could not process XML description: {0}</h3>
### <a name="MM2017">MM2017: Could not process XML description: {0}
<h3><a name="MM202x"/>MM202x: Binding Optimizer failed processing `...`.</h3>
### <a name="MM202x"/>MM202x: Binding Optimizer failed processing `...`.
<h3><a name="MM2100"/>MM2100: Xamarin.Mac Classic API does not support Platform Linking. </h3>
### <a name="MM2100"/>MM2100: Xamarin.Mac Classic API does not support Platform Linking.
# MM3xxx: AOT
## MM30xx: AOT (general) errors
<h3><a name="MM3001">MM3001: Could not AOT the assembly '{0}'</h3>
### <a name="MM3001">MM3001: Could not AOT the assembly '{0}'
<!-- 3002 used by mtouch -->
<!-- 3003 used by mtouch -->
@ -163,43 +166,43 @@ The easiest way to get exact version information is to use the **Xamarin Studio*
<!-- 3006 used by mtouch -->
<!-- 3007 used by mtouch -->
<!-- 3008 used by mtouch -->
<h3><a name="MM3009">MM3009: AOT of '{0}' was requested but was not found</h3>
### <a name="MM3009">MM3009: AOT of '{0}' was requested but was not found
<h3><a name="MM3010">MM3010: Exclusion of AOT of '{0}' was requested but was not found</h3>
### <a name="MM3010">MM3010: Exclusion of AOT of '{0}' was requested but was not found
# MM4xxx: code generation
## MM40xx: driver.m
<h3><a name="MM4001">MM4001: The main template could not be expanded to `{0}`.</h3>
### <a name="MM4001">MM4001: The main template could not be expanded to `{0}`.
## MM41xx: registrar
<h3><a name="MM4134">MM4134: Your application is using the '{0}' framework, which isn't included in the MacOS SDK you're using to build your app (this framework was introduced in OSX {2}, while you're building with the MacOS {1} SDK.) This configuration is not supported with the static registrar (pass --registrar:dynamic as an additional mmp argument in your project's Mac Build option to select). Alternatively select a newer SDK in your app's Mac Build options.</h3>
### <a name="MM4134">MM4134: Your application is using the '{0}' framework, which isn't included in the MacOS SDK you're using to build your app (this framework was introduced in OSX {2}, while you're building with the MacOS {1} SDK.) This configuration is not supported with the static registrar (pass --registrar:dynamic as an additional mmp argument in your project's Mac Build option to select). Alternatively select a newer SDK in your app's Mac Build options.
# MM5xxx: GCC and toolchain
## MM51xx: compilation
<h3><a name="MM5101">MM5101: Missing '{0}' compiler. Please install Xcode 'Command-Line Tools' component.</h3>
### <a name="MM5101">MM5101: Missing '{0}' compiler. Please install Xcode 'Command-Line Tools' component.
<!-- 5102 used by mtouch -->
<h3><a name="MM5103">MM5103: Failed to compile. Error code - {0}. Please file a bug report at http://bugzilla.xamarin.com</h3>
### <a name="MM5103">MM5103: Failed to compile. Error code - {0}. Please file a bug report at http://bugzilla.xamarin.com
<!-- 5104 used by mtouch -->
## MM52xx: linking
<h3><a name="MM5202">MM5202: Mono.framework MDK is missing. Please install the MDK for your Mono.framework version from http://mono-project.com/Downloads</h3>
### <a name="MM5202">MM5202: Mono.framework MDK is missing. Please install the MDK for your Mono.framework version from http://mono-project.com/Downloads
<h3><a name="MM5203">MM5203: Can't find libxammac.a, likely because of a corrupted Xamarin.Mac installation. Please reinstall Xamarin.Mac.</h3>
### <a name="MM5203">MM5203: Can't find libxammac.a, likely because of a corrupted Xamarin.Mac installation. Please reinstall Xamarin.Mac.
<h3><a name="MM5204">MM5204: Invalid architecture. x86_64 is only supported on non-Classic profiles.</h3>
### <a name="MM5204">MM5204: Invalid architecture. x86_64 is only supported on non-Classic profiles.
<h3><a name="MM5205">MM5205: Invalid architecture '{0}'. Valid architectures are i386 and x86_64 (when --profile=mobile).</h3>
### <a name="MM5205">MM5205: Invalid architecture '{0}'. Valid architectures are i386 and x86_64 (when --profile=mobile).
<h3><a name="MM5218"/>MM5218: Can't ignore the dynamic symbol {symbol} (--ignore-dynamic-symbol={symbol}) because it was not detected as a dynamic symbol.</h3>
### <a name="MM5218"/>MM5218: Can't ignore the dynamic symbol {symbol} (--ignore-dynamic-symbol={symbol}) because it was not detected as a dynamic symbol.
See the [equivalent mtouch warning](mtouch-errors.md#MT5218).
@ -218,21 +221,21 @@ See the [equivalent mtouch warning](mtouch-errors.md#MT5218).
## MM53xx: other tools
<h3><a name="MM5301">MM5301: pkg-config could not be found. Please install the Mono.framework from http://mono-project.com/Downloads</h3>
### <a name="MM5301">MM5301: pkg-config could not be found. Please install the Mono.framework from http://mono-project.com/Downloads
<!-- 5302 used by mtouch -->
<!-- 5303 used by mtouch -->
<!-- 5304 used by mtouch -->
<h3><a name="MM5305">MM5305: Missing 'otool' tool. Please install Xcode 'Command-Line Tools' component</h3>
### <a name="MM5305">MM5305: Missing 'otool' tool. Please install Xcode 'Command-Line Tools' component
<h3><a name="MM5306">MM5306: Missing dependencies. Please install Xcode 'Command-Line Tools' component</h3>
### <a name="MM5306">MM5306: Missing dependencies. Please install Xcode 'Command-Line Tools' component
<h3><a name="MM5308">MM5308: Xcode license agreement may not have been accepted. Please launch Xcode.</h3>
### <a name="MM5308">MM5308: Xcode license agreement may not have been accepted. Please launch Xcode.
<h3><a name="MM5309">MM5309: Native linking failed with error code 1. Check build log for details.</h3>
### <a name="MM5309">MM5309: Native linking failed with error code 1. Check build log for details.
<h3><a name="MM5310">MM5310: install_name_tool failed with an error code '{0}'. Check build log for details. </h3>
### <a name="MM5310">MM5310: install_name_tool failed with an error code '{0}'. Check build log for details.
<!-- MM6xxx: mmp internal tools -->
<!-- MM7xxx: reserved -->
@ -259,6 +262,4 @@ See the [equivalent mtouch warning](mtouch-errors.md#MT5218).
<!-- 8015 used by mtouch -->
<!-- 8016 used by mtouch -->
<h3><a name="MM8017">MM8017: The Boehm garbage collector is not supported. Please use SGen instead.</h3>
### <a name="MM8017">MM8017: The Boehm garbage collector is not supported. Please use SGen instead.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -29,8 +29,11 @@ namespace XamarinAnalysisDoc
static void GenerateAnalysisDoc (string path)
{
var section = "id:{c29b69f5-08e4-4dcc-831e-7fd692ab0886}\n";
section += "title:Xamarin.iOS Analysis Rules\n\n";
var section = "---\n";
section += "id: c29b69f5-08e4-4dcc-831e-7fd692ab0886\n";
section += "title: Xamarin.iOS Analysis Rules\n";
section += "dateupdated: " + DateTime.Now.ToString("yyyy-MM-dd") + "\n";
section += "---\n\n";
section += "[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)\n";
section += "[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)\n";
section += "[//]: # (Modifications outside of xamarin-macios/master will be lost on future updates)\n\n";
@ -45,11 +48,11 @@ namespace XamarinAnalysisDoc
var ruleID = rule [0];
var ruleName = rule [1];
section += $"<h3><a name=\"{ruleID}\"/>{ruleID}: {ruleName}</h3>\n\n";
section += $"### <a name=\"{ruleID}\"/>{ruleID}: {ruleName}\n\n";
foreach (var xpaResult in target.Descendants (ns + "XamarinProjectAnalysisResult").Elements ()) {
if (xpaResult.Name.LocalName != "Category") {
section += "* **" + xpaResult.Name.LocalName + ":** ";
section += "- **" + xpaResult.Name.LocalName + ":** ";
section += xpaResult.Value + "\n";
}
}

Просмотреть файл

@ -1,33 +1,35 @@
id:{c29b69f5-08e4-4dcc-831e-7fd692ab0886}
title:Xamarin.iOS Analysis Rules
---
id: C29B69F5-08E4-4DCC-831E-7FD692AB0886
title: "Xamarin.iOS Analysis Rules"
dateupdated: 2017-06-26
---
[//]: # (The original file resides under https://github.com/xamarin/xamarin-macios/tree/master/docs/website/)
[//]: # (This allows all contributors (including external) to submit, using a PR, updates to the documentation that match the tools changes)
[//]: # (Modifications outside of xamarin-macios/master will be lost on future updates)
<h3><a name="XIA0001"/>XIA0001: DisabledLinkerRule</h3>
### <a name="XIA0001"/>XIA0001: DisabledLinkerRule
* **Problem:** The linker is disabled on device for the debug mode.
* **Fix:** You should try to run your code with the linker to avoid any surprises.
- **Problem:** The linker is disabled on device for the debug mode.
- **Fix:** You should try to run your code with the linker to avoid any surprises.
To set it up, go to Project > iOS Build > Linker Behavior.
<h3><a name="XIA0002"/>XIA0002: TestCloudAgentReleaseRule</h3>
### <a name="XIA0002"/>XIA0002: TestCloudAgentReleaseRule
* **Problem:** App builds that initialize the Test Cloud agent will be rejected by Apple when submitted, as they use private API.
* **Fix:** Add or fix the necessary #if and defines in code.
- **Problem:** App builds that initialize the Test Cloud agent will be rejected by Apple when submitted, as they use private API.
- **Fix:** Add or fix the necessary #if and defines in code.
<h3><a name="XIA0003"/>XIA0003: IPADebugBuildsRule</h3>
### <a name="XIA0003"/>XIA0003: IPADebugBuildsRule
* **Problem:** Debug configuration that uses developer signing keys should not generate an IPA as it is only needed for distribution, which now uses the Publishing Wizard.
* **Fix:** Disable IPA build in Project Options for the Debug configuration.
- **Problem:** Debug configuration that uses developer signing keys should not generate an IPA as it is only needed for distribution, which now uses the Publishing Wizard.
- **Fix:** Disable IPA build in Project Options for the Debug configuration.
<h3><a name="XIA0004"/>XIA0004: Missing64BitSupportRule</h3>
### <a name="XIA0004"/>XIA0004: Missing64BitSupportRule
* **Problem:** The supported architecture for "release | device" isn't 64 bit compatible, missing ARM64. This is a problem as Apple does not accept 32 bits only iOS apps in the AppStore.
* **Fix:** Double click on your iOS project, go to Build > iOS Build and change the supported architectures so it has ARM64.
- **Problem:** The supported architecture for "release | device" isn't 64 bit compatible, missing ARM64. This is a problem as Apple does not accept 32 bits only iOS apps in the AppStore.
- **Fix:** Double click on your iOS project, go to Build > iOS Build and change the supported architectures so it has ARM64.
<h3><a name="XIA0005"/>XIA0005: Float32Rule</h3>
* **Problem:** Not using the float32 option (--aot-options=-O=float32) leads to hefty performance cost, specially on mobile, where double precision math is measurably slower. Note that .NET uses double precision internally, even for float, so enabling this option affects precision and, possibly, compatibility.
* **Fix:** Double click on your iOS project, go to Build > iOS Build and uncheck the "Perform all 32-bit float operations as 64-bit float".
### <a name="XIA0005"/>XIA0005: Float32Rule
- **Problem:** Not using the float32 option (--aot-options=-O=float32) leads to hefty performance cost, specially on mobile, where double precision math is measurably slower. Note that .NET uses double precision internally, even for float, so enabling this option affects precision and, possibly, compatibility.
- **Fix:** Double click on your iOS project, go to Build > iOS Build and uncheck the "Perform all 32-bit float operations as 64-bit float".