Animation doesn't works in iOS

Hi, guys! Can’t realise what is going wrong. Added animation programmatically to game object. Here is my code:

private void addMoveAnimOnYAxis (GameObject GO, float axisMove, string clipName) {
		if (GO.GetComponent ("Animation") == null) {
			GO.AddComponent<Animation>();
		}
		if (GO.GetComponent<Animation>().IsPlaying (clipName)) {
			GO.GetComponent<Animation>().Sample ();
			GO.GetComponent<Animation>().RemoveClip (clipName);
		}

		Animation anim = GO.GetComponent<Animation>();
		AnimationCurve curve1 = null, curve2 = null, curve3 = null;
		AnimationClip clip = new AnimationClip();
		clip.frameRate = 20;
		float clipLength = 0.5f;

		curve1 = AnimationCurve.Linear (0, GO.transform.localPosition.x, clipLength, GO.transform.localPosition.x);
		curve2 = AnimationCurve.Linear (0, GO.transform.localPosition.y, clipLength, GO.transform.localPosition.y + axisMove);
		curve3 = AnimationCurve.Linear (0, GO.transform.localPosition.z, clipLength, GO.transform.localPosition.z);

		clip.SetCurve ("", typeof(Transform), "localPosition.x", curve1);
		clip.SetCurve ("", typeof(Transform), "localPosition.y", curve2);
		clip.SetCurve ("", typeof(Transform), "localPosition.z", curve3);

		clip.legacy = true;
		clip.EnsureQuaternionContinuity ();

		anim.AddClip(clip, clipName);
	}

This one works perfectly in UnityEditor. When testing it on iOS device, animation doesn’t work at all. Need help, can’t figure out what is wrong? Already checked settings, everything seams correct, but it doesn’t work on iOS. Heard that may help set interpolation method to euler angles (quaternion approximation), but can’t figure out how to make it programmatically. Thx.

Well figured out what was wrong. In case if anyone will have such problem set legasy when you instantiate AnimationClip like this:

AnimationClip clip = new AnimationClip () { legacy = true };

Somehow if you set clip in this way clip.legacy = true; , it works in UnityEditor, but nothing on device.