assets bundle for ios

Hi guys

I want to make assets bundle for ios .i have done for web player but when i download that bundle for ios it show me error

he file can not be loaded because it was created for another build target that is not compatible with this platform.
Please make sure to build asset bundles using the build target platform that it is used by.
File’s Build target is: 6

(Filename: Line: 625)

Failed to read file ‘none’ because it is corrupted.

(Filename: Line: 444)

The asset bundle ‘https://dl.dropboxusercontent.com/u/76813056/Bundles/Bundle.unity3d’ can’t be loaded because it was not built with the right version or build target.

here is my code for making assets bundle

    using UnityEngine;

    using UnityEditor;
    public class ExportAssetBundles {
        [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")]
        static void ExportResource () {
            // Bring up save panel
            string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d");
            if (path.Length != 0) {
                // Build the resource file from the active selection.
                Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
                BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);
                Selection.objects = selection;
            }
        }
        [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")]
        static void ExportResourceNoTrack () {
            // Bring up save panel
            string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d");
            if (path.Length != 0) {
                // Build the resource file from the active selection.
                BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path);
            }
        }
    }

and for getting assets code is

   IEnumerator Start()
	{
		//float timebefore;
		//float timeafter;
		//StartCoroutine("CheckInternetWorking");
	   // Download the file from the URL. It will not be saved in the Cache
	   using (www = new WWW(BundleURL))
		{
			yield return www;
		   if (www.error != null)
			{
				Debug.Log("error = "+www.error);
			}
	      AssetBundle bundle = www.assetBundle;
		  Instantiate(bundle.mainAsset);
		  bundle.Unload(false);
	   }
   }

please help me i am in trouble ,i want to make a assets bundle for ios and load on device

and sorry for my english

Thanks in advance

This post already has a valid answer, but on a side not you could also use:

EditorUserBuildSettings.activeBuildTarget
instead of
BuildTarget.iPhone

That way, your bundles should be built correctly for whichever platform you currently have chosen as the build target.

Switch build platform to iOS, then run your AssetBundle creation code again.

I had a similar issue and fixed it by changing a line in the ExportAssetBundles script.
There in line
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iPhone);
Added BuildTarget.iPhone to the end.

Now it works.

I was building the Asset Bundles for Android like so and it did not work:

BuildPipeline.BuildAssetBundles(“Assets/AssetBundles”, BuildAssetBundleOptions.None, BuildTarget.Android);

But when I changed to this, it worked:

BuildPipeline.BuildAssetBundles(“Assets/AssetBundles”, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);

What a headache!