Xamarin.iOS绑定iOS Objective-C库导致空名称空间

问题描述 投票:0回答:1

我在Walkthrough: Binding an iOS Objective-C Library中认真执行了每个步骤,>

TestBindings

项目的生成结果为成功。

但是,我得到了空的命名空间引用。

Empty namespace

我的开发环境设置是:

  1. Windows 10 Pro 1909
  2. Visual Studio 2019专业版16.6.0
  3. macOS Catalina 10.15.5
  4. XCode版本11.4.1
  5. 项目结构为:

Project Structure

每个源代码是:

ApiDefinition.cs

using CoreGraphics;
using Foundation;
using ObjCRuntime;
using UIKit;

namespace TestBindings
{
    // @interface InfColorBarView : UIView
    [BaseType(typeof(UIView))]
    interface InfColorBarView
    {
    }

    // @interface InfColorBarPicker : UIControl
    [BaseType(typeof(UIControl))]
    interface InfColorBarPicker
    {
        // @property (nonatomic) float value;
        [Export("value")]
        float Value { get; set; }
    }

    // @interface InfColorIndicatorView : UIView
    [BaseType(typeof(UIView))]
    interface InfColorIndicatorView
    {
        // @property (nonatomic) UIColor * color;
        [Export("color", ArgumentSemantic.Assign)]
        UIColor Color { get; set; }
    }

    // @interface InfColorPickerController : UIViewController
    [BaseType(typeof(UIViewController))]
    interface InfColorPickerController
    {
        // +(InfColorPickerController *)colorPickerViewController;
        [Static]
        [Export("colorPickerViewController")]
        // [Verify(MethodToProperty)]
        InfColorPickerController ColorPickerViewController { get; }

        // +(CGSize)idealSizeForViewInPopover;
        [Static]
        [Export("idealSizeForViewInPopover")]
        // [Verify(MethodToProperty)]
        CGSize IdealSizeForViewInPopover { get; }

        // -(void)presentModallyOverViewController:(UIViewController *)controller;
        [Export("presentModallyOverViewController:")]
        void PresentModallyOverViewController(UIViewController controller);

        // @property (nonatomic) UIColor * sourceColor;
        [Export("sourceColor", ArgumentSemantic.Assign)]
        UIColor SourceColor { get; set; }

        // @property (nonatomic) UIColor * resultColor;
        [Export("resultColor", ArgumentSemantic.Assign)]
        UIColor ResultColor { get; set; }

        [Wrap("WeakDelegate")]
        InfColorPickerControllerDelegate Delegate { get; set; }

        // @property (nonatomic, weak) id<InfColorPickerControllerDelegate> delegate;
        [NullAllowed, Export("delegate", ArgumentSemantic.Weak)]
        NSObject WeakDelegate { get; set; }
    }

    // @protocol InfColorPickerControllerDelegate
    [BaseType(typeof(NSObject))]
    [Model]
    interface InfColorPickerControllerDelegate
    {
        // @optional -(void)colorPickerControllerDidFinish:(InfColorPickerController *)controller;
        [Export("colorPickerControllerDidFinish:")]
        void ColorPickerControllerDidFinish(InfColorPickerController controller);

        // @optional -(void)colorPickerControllerDidChangeColor:(InfColorPickerController *)controller;
        [Export("colorPickerControllerDidChangeColor:")]
        void ColorPickerControllerDidChangeColor(InfColorPickerController controller);
    }

    // @interface InfColorPickerNavigationController : UINavigationController
    [BaseType(typeof(UINavigationController))]
    interface InfColorPickerNavigationController
    {
    }

    // @interface InfColorSquareView : UIImageView
    [BaseType(typeof(UIImageView))]
    interface InfColorSquareView
    {
        // @property (nonatomic) float hue;
        [Export("hue")]
        float Hue { get; set; }
    }

    // @interface InfColorSquarePicker : UIControl
    [BaseType(typeof(UIControl))]
    interface InfColorSquarePicker
    {
        // @property (nonatomic) float hue;
        [Export("hue")]
        float Hue { get; set; }

        // @property (nonatomic) CGPoint value;
        [Export("value", ArgumentSemantic.Assign)]
        CGPoint Value { get; set; }
    }

    // @interface InfSourceColorView : UIControl
    [BaseType(typeof(UIControl))]
    interface InfSourceColorView
    {
        // @property (nonatomic) BOOL trackingInside;
        [Export("trackingInside")]
        bool TrackingInside { get; set; }
    }

    // @interface TestBindings : NSObject
    [BaseType(typeof(NSObject))]
    interface TestBindings
    {
    }
}

Structs.cs

using System;
using System.Runtime.InteropServices;
using CoreGraphics;

namespace TestBindings
{
    static class CFunctions
    {
        // extern float pin (float minValue, float value, float maxValue);
        [DllImport("__Internal")]
        // [Verify(PlatformInvoke)]
        static extern float pin(float minValue, float value, float maxValue);

        // extern void HSVtoRGB (float h, float s, float v, float *r, float *g, float *b);
        [DllImport("__Internal")]
        // [Verify(PlatformInvoke)]
        static extern unsafe void HSVtoRGB(float h, float s, float v, float* r, float* g, float* b);

        // extern void RGBToHSV (float r, float g, float b, float *h, float *s, float *v, BOOL preserveHS);
        [DllImport("__Internal")]
        // [Verify(PlatformInvoke)]
        static extern unsafe void RGBToHSV(float r, float g, float b, float* h, float* s, float* v, bool preserveHS);

        // extern CGImageRef createSaturationBrightnessSquareContentImageWithHue (float hue);
        [DllImport("__Internal")]
        // [Verify(PlatformInvoke)]
        static extern unsafe CGImage createSaturationBrightnessSquareContentImageWithHue(float hue);

        // extern CGImageRef createHSVBarContentImage (InfComponentIndex barComponentIndex, float *hsv);
        [DllImport("__Internal")]
        // [Verify(PlatformInvoke)]
        static extern unsafe CGImage createHSVBarContentImage(InfComponentIndex barComponentIndex, float[] hsv);

    }

    public enum InfComponentIndex : uint
    {
        Hue = 0,
        Saturation = 1,
        Brightness = 2
    }
}

libTestBindings.linkwith.cs

using System;
using ObjCRuntime;

[assembly: LinkWith ("libTestBindings.a", LinkTarget.ArmV7, SmartLink = true, ForceLoad = true)]

libTestBindings.a

libTestBindings.a properties

MAC OS

Xcode项目设置

Xcode Project Settings

Makefile

Makefile

文件夹

Folder

我在演练中认真地遵循了每个步骤:绑定iOS Objective-C库TestBindings项目的生成结果成功。但是,我得到了空的命名空间引用。我的发展...

c# xamarin xamarin.ios xamarin.ios-binding
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.