Month: June 2016

No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com

If you receive the following error message after trying to run an Xamarin application in Visual Studio

"No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com. <YourAppName>"

What this basically means is that you need to create or log into your Apple ID in XCode itself and get a certification straight from Apple.

There is a great article on the Xamarin website on how to do this, check it out here

https://developer.xamarin.com/guides/ios/getting_started/installation/device_provisioning/#Using_Xcode

If you still get the error message, make sure you have the iPhone simulator selected

 

Untitled

 

Untitled2

Changing SharedPreferences of a Context instance for testing with Robolectric

The following code will get it done in a snap

Context context = RuntimeEnvironment.application.getApplicationContext();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
sharedPreferences.edit().putBoolean("useOnlyOnWifi", false).commit();

Explanation

 

You use “RuntimeEnvironment.application.getApplicationContext();” to create an instance of a Context object.

You return the preferences, and modify the needed value and then commit it.

The next time this instance of Context returns SharedPreferences, it will return the version that you modified.

Change as many settings as you need to, then pass the context to the method you are trying to test!