我需要Xamarin.iOS項目的草圖/繪畫控件,雖然我似乎無法找到與C#兼容的一個,但我確實發現了一個可用Objective C編寫的好組件https://github.com/acerbetti/ACEDrawingViewXamarin iOS綁定,庫中找不到符號
我已經完成了Xamarin綁定,所以我希望這個過程相當簡單,但不幸的是我一路上遇到了一些障礙。
我開始創建我的靜態庫和使用Ant構建腳本做出FAT二進制覆蓋設備和模擬器:
我的ant腳本
AceDrawingViewSDK.a: libAceDrawingView-i386.a libAceDrawingView-armv7.a libAceDrawingView-armv7s.a libAceDrawingView-arm64.a xcrun -sdk iphoneos lipo -create -output [email protected] $^
接下來的片斷,我跑
sharpie bind --sdk=iphoneos10.1 *.h
上的頭文件得到我的ApiDefinitions和Structs和Enum文件。
我檢查並刪除了驗證屬性。 (他們都看起來很好。)但這是我的其他一些問題開始的地方。
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。)這樣做通過了這個錯誤或者,讓我編譯
我的一個枚舉出來作爲
[Native]
public enum ACEDrawingMode : nuint
{
Scale,
OriginalSize
}
我找不到怎麼處理[本地]在這種情況下,(所以再次,測試的緣故,我刪除它。 )我嘗試使用從枚舉中刪除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.
...和等等。
我試過回去,重讀和重做步驟,並試圖從我以前的成功綁定中重用一些腳本和設置,但沒有運氣。
有沒有人有什麼可以解決這些問題的建議?