dsplaisted / PCLStorage

PCL Storage - Portable Storage APIs
Microsoft Public License
305 stars 95 forks source link

Xamarin.Mac support #28

Open haritowa opened 8 years ago

haritowa commented 8 years ago

Xamarin.Mac version doesn't work proper way(for example, LocalStorage returns ~/../Library, which incorrect by definition). Here you can find fork, which repairs Mac compatibility

dsplaisted commented 8 years ago

I see that the fork creates a separate project which specifically targets Xamarin.Mac. As far as I know, it's not currently possible to build a project targeting Xamarin.Mac on Windows.

I think that libraries targeting .NET Framework 4.5 will probably work on Xamarin.Mac. So what I'd like to try is to just compile the library for .NET Framework with the code that uses the correct path for LocalStorage, and see if it can be used from Xamarin.Mac.

Would you be willing to see if this works and send a PR for it?

haritowa commented 8 years ago

Sorry for delay, i was rly busy this weekend. As temporary solution, i use PCLStorage, PCLStorage.Abstractions & PCLStorage.FileSystem.Desktop source code in xamarin.mac project:

screen shot 2015-12-21 at 03 04 08

with some changes(just remove #if derectives & use Filesystem || MAC || Portable code version), for example & it works perfectly

static IFileSystem CreateFileSystem()
{
    return new DesktopFileSystem();
}

My mac project use Xamarin.Mac Mobile as Target Framework, not Xamarin.Mac .Net 4.5

I can try to build everything u want on mac, if it'll help you :smile:

Sparksteam commented 8 years ago

I'm now getting this error with the LocalStorage on mac. Are there plans to implement a solution in the main branch and publishing an updated version? Thanks.

Sparksteam commented 8 years ago

So what do you think? Can we get this fixed soon?

Thanks

haritowa commented 8 years ago

@Sparksteam Still using workaround ¯(ツ)

Sparksteam commented 8 years ago

@haritowa Hope not too much longer.

haritowa commented 8 years ago

@Sparksteam we have switched to native, so this doesn't make me suffer any more :joy:

You can use source from this fork

Sparksteam commented 8 years ago

Thanks @haritowa, I may have to use that fork eventually. Did you build a binding class for OS X, or are you going native across-the-board?

haritowa commented 8 years ago

@Sparksteam fully native both for iOS & OS X

dsplaisted commented 8 years ago

To be able to produce a package with Mac support, I need a way to be able to build a library that can run on Xamarin.Mac on a Windows machine. Possible ways of doing this include:

Sparksteam commented 8 years ago

Why would it need to run on Windows? Is there bait-and-switch going on in the NuGet?

dsplaisted commented 8 years ago

@Sparksteam It doesn't need to run on Windows, but I need to be able to build it on Windows. I don't own a Mac, so I can't use one to build the library for Xamarin.Mac. Even if I did, I would strongly prefer to enable everything to be built on a single machine, instead of having to build some of the files on Windows, some on a Mac, and then copying them together and creating a NuGet package out of them.

dsplaisted commented 8 years ago

@Sparksteam And yes, PCL Storage is a canonical example of bait-and-switch. The NuGet package contains a portable "reference assembly" that PCLs can compile against, and then implementations compiled for each platform supported.

Sparksteam commented 8 years ago

Yeah Daniel, it is somewhat cumbersome. And expensive to buy a MAC. I’d be more than happy to build binaries for you and upload them somewhere.

Allan

From: Daniel Plaisted [mailto:notifications@github.com] Sent: Thursday, March 17, 2016 4:12 PM To: dsplaisted/PCLStorage PCLStorage@noreply.github.com Cc: Sparksteam achin5957@hotmail.com Subject: Re: [PCLStorage] Xamarin.Mac support (#28)

@Sparksteam https://github.com/Sparksteam It doesn't need to run on Windows, but I need to be able to build it on Windows. I don't own a Mac, so I can't use one to build the library for Xamarin.Mac. Even if I did, I would strongly prefer to enable everything to be built on a single machine, instead of having to build some of the files on Windows, some on a Mac, and then copying them together and creating a NuGet package out of them.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/dsplaisted/PCLStorage/issues/28#issuecomment-198123575 https://github.com/notifications/beacon/AL--vEEDUozYGk7Eubgik-lNiMP4KSnLks5pud_cgaJpZM4G1ges.gif

Sparksteam commented 8 years ago

@haritowa - Is this only change you had to make to the master code, in DesktopFileSystem.LocalStorage?

elif MAC

var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var localAppData = Path.Combine(documents, "Library");

else

and adding the necessary MAC preprocessor symbol, of course.

Thanks

haritowa commented 8 years ago

@Sparksteam unfortunately, i can't remember all details, i just remove all #IF sections for other platforms :)

haritowa commented 8 years ago

PCLStorage.Mac.zip @Sparksteam Try this

Sparksteam commented 8 years ago

Thanks @haritowa . I diff'd the files with the current master and although there were some differences, it doesn't look like any of them contain any MAC specific changes. The one change I referenced last week in your DesktopFileSystem.LocalStorage might be all that's required. I will give that a try and let you know.

Sparksteam commented 8 years ago

@haritowa - I worked around this problem in my code by simply implementing my own GetStorageFolder with this code;

IFolder storageFolder;

if _MAC

var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var localAppData = documents + "/Library"; storageFolder = await FileSystem.Current.GetFolderFromPathAsync(localAppData);

else

storageFolder = FileSystem.Current.LocalStorage;

endif

@dsplaisted - My offer still stands if you'd like me to build some binaries for you. The fix seems simple enough, but you will need that MAC project.

Thanks guys.

dsplaisted commented 8 years ago

@Sparksteam Can you send a PR to add support for building on the Mac? Once we have that merged then you can build the Mac DLL and send it to me.

Thanks, Daniel

Sparksteam commented 8 years ago

Ok Daniel - PR #38 with the changes I think are required. I'm not sure how to go about testing it though. I have all the release binaries for PCLStorage.OSX. Let me know how you would like me to get them to you. If you build and publish a pre-release NuGet package with these changes I would be more than happy to test it for you.

Thanks,

Allan

soroshsabz commented 7 years ago

ITNOA

Is there any update?

martinobordin commented 7 years ago

Is it working?