Krumelur
Krumelur

Reputation: 33048

Code works on Android and iOS - why can't I move it into a PCL?

I have a static class that uses

Currently, the class is in my iOS project and unchanged also in my Android project.

I created a PCL that targets Android and iOS only.

However, neither one of the namespaces is available.

I presume that is because iOS and Android alone are not suitable for a PCL profile and that's why Windows Store 8 or Silverlight 5 gets added and that removes the System.IO.* namespaces.

Is this working as designed? Is file linking my only chance in this case?

Upvotes: 3

Views: 414

Answers (2)

Softlion
Softlion

Reputation: 12605

System.IO.Path, System.IO.Directory and System.IO.File are partially supported in PCL profile EXCLUDING silverlight 5: WP8 + NET4.5 + Xamarin + iOS.

Path.Combine works perfectly in this targeted PCL.

Upvotes: 0

Daniel Plaisted
Daniel Plaisted

Reputation: 16744

Yes, for now this is the way it's supposed to work. You can use something like my PCL Storage library to access the file system from a PCL, or you can simply use file linking.

As a side note, I'd recommend choosing Windows Store and .NET 4.5 along with the Xamarin targets. That profile is going to give you more APIs than the one which targets Silverlight 5 which you get by default when you just choose Xamarin platforms in that dialog.

Upvotes: 3

Related Questions