Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.Mac support #28

Open
haritowa opened this issue Dec 15, 2015 · 23 comments
Open

Xamarin.Mac support #28

haritowa opened this issue Dec 15, 2015 · 23 comments

Comments

@haritowa
Copy link

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
Copy link
Owner

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
Copy link
Author

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 😄

@Sparksteam
Copy link

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
Copy link

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

Thanks

@haritowa
Copy link
Author

@Sparksteam Still using workaround ¯_(ツ)_/¯

@Sparksteam
Copy link

@haritowa Hope not too much longer.

@haritowa
Copy link
Author

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

You can use source from this fork

@Sparksteam
Copy link

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
Copy link
Author

@Sparksteam fully native both for iOS & OS X

@dsplaisted
Copy link
Owner

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:

  • Build a library which targets .NET Framework 4.5, and rely on the fact that it should "just work" when running on Xamarin.Mac
  • Build against the Xamarin.Mac reference assemblies. Xamarin would need to release them in a publicly consumable form (preferrably a NuGet package)
  • Target the .NET Platform Standard v1.3. Xamarin.Mac would need to support .NETStandard v1.3, which I don't think it does yet.

@Sparksteam
Copy link

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

@dsplaisted
Copy link
Owner

@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
Copy link
Owner

@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
Copy link

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:[email protected]]
Sent: Thursday, March 17, 2016 4:12 PM
To: dsplaisted/PCLStorage [email protected]
Cc: Sparksteam [email protected]
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 #28 (comment) https://github.com/notifications/beacon/AL--vEEDUozYGk7Eubgik-lNiMP4KSnLks5pud_cgaJpZM4G1ges.gif

@Sparksteam
Copy link

@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
Copy link
Author

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

@haritowa
Copy link
Author

PCLStorage.Mac.zip
@Sparksteam Try this

@Sparksteam
Copy link

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
Copy link

@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
Copy link
Owner

@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
Copy link

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
Copy link

ITNOA

Is there any update?

@martinobordin
Copy link

Is it working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants