Embeddinator-4000
Embeddinator-4000 copied to clipboard
[ObjC] Embedding a library using PHAsset etc causes dupes for Mac
Note: using latest beta of Visual Studio for Mac
Example segment of header created...
@class PHObject;
@class PHAsset;
@class PHFetchOptions;
@class PHFetchResult;
@class PHImageManager;
@class PHImageRequestOptions;
@interface PHObject : NSObject {
}
-(NSObject *) copyWithZone:(id)p0;
@end
@interface PHAsset : PHObject {
}
@end
@interface PHFetchOptions : NSObject {
}
-(NSObject *) copyWithZone:(id)p0;
-(id) init;
@end
@interface PHFetchResult : NSObject {
}
-(NSObject *) copyWithZone:(id)p0;
-(NSObject *) objectAtIndex:(NSInteger)p0;
@end
@interface PHImageManager : NSObject {
}
-(int) requestImageForAsset:(id)p0 targetSize:(CGSize)p1 contentMode:(NSInteger)p2 options:(id)p3 resultHandler:(id)p4;
@end
@interface PHImageRequestOptions : NSObject {
}
-(NSObject *) copyWithZone:(id)p0;
-(id) init;
@end
From a method like...
public override void ViewDidLoad()
{
base.ViewDidLoad();
InfoTextField.StringValue = ProjectAssets.SharedInstance().GetAssets().Count().ToString();
var identifiers = ProjectAssets.SharedInstance().GetAssets();
if (identifiers.Length > 0)
{
var options = new PHFetchOptions();
var fetchResult = PHAsset.FetchAssetsUsingLocalIdentifiers(identifiers, options);
PHAsset asset = (PHAsset)fetchResult.ObjectAt(0);
PHImageRequestOptions options2 = new PHImageRequestOptions();
PHImageManager.DefaultManager.RequestImageForAsset(asset, new CoreGraphics.CGSize(500, 500), PHImageContentMode.AspectFill, options2, (NSImage result, NSDictionary info) =>
{
TestImageView.Image = result;
});
}
}
Xcode reports duplicate definitions of each of the
PHObject; PHAsset; PHFetchOptions; PHFetchResult; PHImageManager; PHImageRequestOptions;
@tritao is there any way I can update Embeddinator to not do above?
In your c# project, are you defining classes called PHObject?
Without seeing more, it is difficult to understand what is going on.
Could you attach a project showing the issue?
@chamons I've created a Xamarin test solution "PNI.Mobile.sln" that creates and copies an embedded framework to an Xcode project. "PNIPhotoProjectDemo.xcodeproj"
if you run both in sequence you should see problem mentioned above...
https://www.dropbox.com/s/hvkn39vscnpkd4u/ProblemExample.zip?dl=0
As to your question, the .Net library uses "using Photos;" with appropriate code and the Xcode project also uses "#import <Photos/Photos.h>", I am not myself defining any class names like PHObject...
the problem lies in fact that the header created in framework contains the duplicate interfaces...
e.g. @interface PHObject : NSObject { } -(NSObject *) copyWithZone:(id)p0; @end
which conflicts with the "#import <Photos/Photos.h>" used
@chamons have you been able to look into why this happens? For now as a work around I’m using sed to remove chunks of code from header.
@equinox2k - No, I have no yet. It's currently bucketed for after a potential .4 release.
I'm glad you have a work around right currently.