Xamarin.iOS プロジェクト用のスケッチ/ペイント コントロールが必要でした。C# と互換性のあるものを見つけることができなかったようですが、Objective C で記述された適切なコンポーネントを見つけました。https://github.com/acerbetti/ACEDrawingView
以前に Xamarin バインディングを行ったことがあるので、プロセスがかなり単純になることを期待していましたが、残念ながら途中でいくつかの障害にぶつかりました。
スタティック ライブラリの作成から始め、ant ビルド スクリプトを使用してデバイスとシミュレータをカバーする FAT バイナリを作成しました。
私のantスクリプトのスニペット
AceDrawingViewSDK.a: libAceDrawingView-i386.a libAceDrawingView-armv7.a libAceDrawingView-armv7s.a libAceDrawingView-arm64.a xcrun -sdk iphoneos lipo -create -output $@ $^
次に、走った
sharpie bind --sdk=iphoneos10.1 *.h
ヘッダー ファイルで、ApiDefinitions と Structs および Enum ファイルを取得します。
Verify属性を確認して削除しました。(それらはすべて問題ないように見えました。)しかし、これが私の他の問題のいくつかが始まったところです。
The type ACEDrawingLabelViewTransform' already contains a definition forTransform' (CS0102) (AceDrawingViewBinding).
先に進んで何かを機能させるために、この参照をコメントアウトしました。
その後、次のような複数の問題が発生しました。
The type or namespace name `IACEDrawingTool' could not be found. Are you missing an assembly reference? (CS0246) (AceDrawingViewBinding)
私はそれがこれに関連していると考えました:
// @interface ACEDrawingPenTool : UIBezierPath
[BaseType(typeof(UIBezierPath))]
interface ACEDrawingPenTool : IACEDrawingTool
この:
// @protocol ACEDrawingTool
[Protocol, Model]
[BaseType(typeof(NSObject))]
interface ACEDrawingTool
これを修正してインターフェイス名を統一しようとしました (IACEDrawingTool と ACEDrawingTool の両方を試しました)。
私の列挙型の1つが次のように出てきました
[Native]
public enum ACEDrawingMode : nuint
{
Scale,
OriginalSize
}
この場合、[Native] の処理方法が見つかりませんでした (もう一度、テストのために削除しました)。enum から nuint を削除し、uint を使用してみました。どちらのアプローチでもエラーが修正されたようです。
これらのエラーが修正されたので、バインディング プロジェクトから .dll を生成し、それをメイン プロジェクトに追加することができました。
今、私はさらに2つの問題を抱えています。
ビルドしてシミュレーターにデプロイすると、バインディングから ACEDrawingView の新しいインスタンスを作成しようとする時点までアプリを実行できます。私は得る:
Could not create an native instance of the type 'ACEDrawingView': the native class hasn't been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
ビルドして携帯電話にデプロイしようとすると、ビルド フェーズでさまざまなエラーが発生し、デバイスでまったく起動できなくなります。
MTOUCH: error MT5211: Native linking failed, undefined Objective-C class: ACEDrawingArrowTool. The symbol 'OBJC_CLASS$ACEDrawingArrowTool' could not be found in any of the libraries or frameworks linked with your application.
MTOUCH: error MT5211: Native linking failed, undefined Objective-C class: ACEDrawingDraggableTextTool. The symbol '_OBJC_CLASS$ACEDrawingDraggableTextTool' could not be found in any of the libraries or frameworks linked with your application.
MTOUCH: error MT5211: Native linking failed, undefined Objective-C class: ACEDrawingEllipseTool. The symbol '_OBJC_CLASS$_ACEDrawingEllipseTool' could not be found in any of the libraries or frameworks linked with your application.
...等々。
戻って、手順を読み直し、やり直して、以前の成功したバインドからいくつかのスクリプトと設定を再利用しようとしましたが、うまくいきませんでした。
これらの問題を解決するための提案はありますか?