【问题标题】:Xamarin Object Sharpie Obj-C Library Binding why Output huge File?Xamarin Object Sharpie Obj-C 库绑定为什么要输出巨大的文件?
【发布时间】:2017-12-08 08:55:35
【问题描述】:

我现在正在尝试绑定 Google Maps iOS 实用程序的 Heatmap 部分。

https://github.com/googlemaps/google-maps-ios-utils

1:.a file Create

2:创建Makefile并执行make命令

XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
PROJECT_ROOT=./GoogleMapiOSHeatmapUtility
PROJECT=./GoogleMapiOSHeatmapUtility.xcodeproj
TARGET=GoogleMapiOSHeatmapUtility

all: lib$(TARGET).a

lib$(TARGET)-i386.a:
        $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release clean build
        -mv ./build/Release-iphonesimulator/lib$(TARGET).a $@

lib$(TARGET)-armv7.a:
        $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7 -configuration Release clean build
        -mv ./build/Release-iphoneos/lib$(TARGET).a $@

lib$(TARGET)-arm64.a:
        $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch arm64 -configuration Release clean build
        -mv ./build/Release-iphoneos/lib$(TARGET).a $@

lib$(TARGET).a: lib$(TARGET)-i386.a lib$(TARGET)-armv7.a lib$(TARGET)-arm64.a
        xcrun -sdk iphoneos lipo -create -output $@ $^

clean:
        -rm -f *.a *.dll

3:add 「.a」File BindingProject

4:创建 ApiDefinitions & StructsAndEnums 文件

执行命令

sharpie bind --output=GoogleMapiOSHeatmapUtility --namespace=GoogleMapiOSHeatmapUtility --sdk=iphoneos11.1  ./GoogleMapiOSHeatmapUtility/*.h

结果

Parsing 14 header files...
In file included from /var/folders/kv/_n7jh8kd1cbd0sl1jy75k_cm0000gn/T/tmpcc4d148.h:6:
/Users/xxxxxxxx/Documents/repository/GoogleMapiOSHeatmapUtility/GoogleMapiOSHeatmapUtility/GMUHeatmapTileLayer.h:45:1: warning: no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed
      [-Wobjc-property-no-attribute]
@property(nonatomic) GMUGradient *gradient;
^
/Users/xxxxxxxxxxx/Documents/repository/GoogleMapiOSHeatmapUtility/GoogleMapiOSHeatmapUtility/GMUHeatmapTileLayer.h:45:1: warning: default property attribute 'assign' not appropriate for non-GC object
      [-Wobjc-property-no-attribute]

Binding...
  [write] ApiDefinitions.cs
  [write] StructsAndEnums.cs

Binding Analysis:
  Automated binding is complete, but there are a few APIs which have been flagged with [Verify] attributes. While the entire binding should be audited for best API design practices, look more closely at APIs
  with the following Verify attribute hints:

  ConstantsInterfaceAssociation (205 instances):
    There's no foolproof way to determine with which Objective-C interface an extern variable declaration may be associated. Instances of these are bound as [Field] properties in a partial interface into a
    nearby concrete interface to produce a more intuitive API, possibly eliminating the 'Constants' interface altogether.

  MethodToProperty (201 instances):
    An Objective-C method was bound as a C# property due to convention such as taking no parameters and returning a value (non-void return). Often methods like these should be bound as properties to surface a
    nicer API, but sometimes false-positives can occur and the binding should actually be a method.

  StronglyTypedNSArray (45 instances):
    A native NSArray* was bound as NSObject[]. It might be possible to more strongly type the array in the binding based on expectations set through API documentation (e.g. comments in the header file) or by
    examining the array contents through testing. For example, an NSArray* containing only NSNumber* instances can be bound as NSNumber[] instead of NSObject[].

  PlatformInvoke (3177 instances):
    In general P/Invoke bindings are not as correct or complete as Objective-C bindings (at least currently). You may need to fix up the library name (it defaults to '__Internal') and return/parameter types
    manually to conform to C calling conventionsfor the target platform. You may find you don't even want to expose the C API in your binding, but if you do, you'll probably also want to relocate the
    definition to a more appropriate class and expose a stronger type-safe wrapper. For P/Invoke guidance, see http://www.mono-project.com/docs/advanced/pinvoke/.

  InferredFromMemberPrefix (30 instances):
    The name of this originally anonymous declaration was taken from a common prefix of its members.

  Once you have verified a Verify attribute, you should remove it from the binding source code. The presence of Verify attributes intentionally cause build failures.

  For more information about the Verify attribute hints above, consult the Objective Sharpie documentation by running 'sharpie docs' or visiting the following URL:

    http://xmn.io/sharpie-docs
2 warnings generated.

Done.

执行sharpie bind命令后,生成了ApiDefinitions.cs和StructsAndEnums.cs,但是这两个文件的代码都超过20000行,出现了3000多个错误

为什么使用了14个头文件却没有一个满足100行的时候会创建一个巨大的文件?

我刚刚开始使用 Xamarin,我在这里遇到了很多困难 必须绝对使用热图是有原因的。

请帮帮我

【问题讨论】:

  • 同样的问题,在这里找到一些信息forums.xamarin.com/discussion/54222/… 但是在通过 -xcodeproj-target 和 -xcodeproj-config 之后 - 没有运气(同样的错误发生
  • 感谢您的评论。我尝试了以下命令,但效果不佳sharpie bind -xcodeproj-target GoogleMapiOSHeatmapUtility -xcodeproj-config Debug GoogleMapiOSHeatmapUtility.xcodeproj GoogleMapiOSHeatmapUtility.xcodeproj target 'GoogleMapiOSHeatmapUtility' 没有任何要解析的标头

标签: c# xamarin xamarin.ios objective-sharpie xamarin.ios-binding


【解决方案1】:

为什么使用了14个头文件却没有一个满足100行的时候会创建一个巨大的文件?

好像这个问题是最新的 Sharpie 出现的(我之前做过绑定库,它工作正常)。

大文件只有一部分有用(在文件末尾),你可以删除无用的代码。

另外,如果这个项目已经注册,我建议你通过CocoaPods创建它。

【讨论】:

  • 感谢您的回答 Cocoapods中的绑定由于包含多个静态库而无法完成,但我们删除了不必要的代码并修复了它,直到通过返工消除错误。结果,我能够创建绑定库。我充满感激。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2018-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-03
  • 2014-06-29
  • 1970-01-01
相关资源
最近更新 更多