0
Mac의 Visual Studio에서 네이티브 obj-c 라이브러리를 래핑하는 데 문제가 있습니다. Build가 NativeLibraryWrapperDef.cs에서 클래스의 코드 숨김을 생성하지만 네임 스페이스에 문제가 있습니다.Xamarin 'GetNSObject'가 'Internal.Runtime'네임 스페이스에 존재하지 않습니다.
오류 CS0234 : 'GetNSObject'형식 또는 네임 스페이스 이름이 'Internal.Runtime'네임 스페이스에 없습니다. 조립 참조가 누락 되었습니까?) (CS0234) (Gmc.Mobile.Sdk.iOS)
Xamarin studio를 사용하는 Workmate가 잘 만들 수 있습니다. 이 문제가 발생한 사람은 누구입니까?
using System;
using UIKit;
using Foundation;
using ObjCRuntime;
using Gmc.Mobile.Sdk;
using SafariServices;
namespace Internal.iOS
{
/*
The first step to creating a binding is to add your native library ("libNativeLibrary.a")
to the project by right-clicking (or Control-clicking) the folder containing this source
file and clicking "Add files..." and then simply select the native library (or libraries)
that you want to bind.
When you do that, you'll notice that MonoDevelop generates a code-behind file for each
native library which will contain a [LinkWith] attribute. MonoDevelop auto-detects the
architectures that the native library supports and fills in that information for you,
however, it cannot auto-detect any Frameworks or other system libraries that the
native library may depend on, so you'll need to fill in that information yourself.
Once you've done that, you're ready to move on to binding the API...
Here is where you'd define your API definition for the native Objective-C library.
For example, to bind the following Objective-C class:
@interface Widget : NSObject {
}
The C# binding would look like this:
[BaseType (typeof (NSObject))]
interface Widget {
}
To bind Objective-C properties, such as:
@property (nonatomic, readwrite, assign) CGPoint center;
You would add a property definition in the C# interface like so:
[Export ("center")]
CGPoint Center { get; set; }
To bind an Objective-C method, such as:
-(void) doSomething:(NSObject *)object atIndex:(NSInteger)index;
You would add a method definition to the C# interface like so:
[Export ("doSomething:atIndex:")]
void DoSomething (NSObject object, int index);
Objective-C "constructors" such as:
-(id)initWithElmo:(ElmoMuppet *)elmo;
Can be bound as:
[Export ("initWithElmo:")]
IntPtr Constructor (ElmoMuppet elmo);
For more information, see http://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/
*/
// @interface MRDCState : NSObject <MRDBObject>
[BaseType(typeof(NSObject))]
interface MRDCState : MRDBObject
{
[Export ("remoteId", ArgumentSemantic.Copy)]
string RemoteId { get; set; }
[Export("documentID", ArgumentSemantic.Copy)]
string DocumentID { get; set; }
[Export("displayName", ArgumentSemantic.Copy)]
string DisplayName { get; set; }
[Export ("isUpdateAvailable", ArgumentSemantic.Copy)]
bool IsUpdateAvailable { get; set;}
[Export("lastUpdateDate", ArgumentSemantic.Copy)]
NSDate LastUpdateDate { get; set; }
[Export("content", ArgumentSemantic.Copy)]
string Content { get; set; }
//@property (nonatomic) int stateTypeFlag;
[Export ("stateTypeFlag", ArgumentSemantic.Copy)]
StateType TypeFlag { get; set; }
}
// @interface MRDCAppMessage : NSObject
[Protocol]
[BaseType(typeof(NSObject))]
interface MRAppMessage
{
// @property NSUInteger messageID;
[Export("messageID")]
ulong MessageID { get; set; }
// @property NSString *documentID;
[Export("documentID")]
string DocumentID { get; set; }
// @property NSString *messageType;
[Export("messageType")]
string MessageType { get; set; }
// @property NSString *payload;
[Export("payload")]
string Payload { get; set; }
// - (instancetype)initWithID:(NSUInteger)messageID documentID:(NSString *)documentID type:(NSString *)messageType payload:(NSString *)payload;
[Export("initWithID:documentID:messageType:payload:")]
IntPtr Constructor(ulong messageID, string documentID, string messageType, string payload);
}
'ObjCRuntime' 네임 스페이스에 있습니다 :'ObjCRuntime.Runtime.GetNSObject()','NativeLibraryWrapperDef.cs' 샘플을 추가 할 수 있습니까? – SushiHangover
질문 할 파일의 일부를 추가했습니다. Internal.iOS 네임 스페이스에서 Internal을 제거하려고했습니다. 이제 라이브러리 용 래퍼가 잘 컴파일됩니다. 내부 네임 스페이스가 어디서 왔는지는 잘 모르겠습니다. (새 래퍼 .dll 응용 프로그램에서 사용하려고 할 때 몇 가지 문제가 있지만 다른 원인에 의해 발생할 수 있습니다) –