Object.Instantiate produces error after I strip my iOS project

Can someone help me out with this?

Object instantiation worked fine before I stripped down my code, but when I stripped it (using strip bytecode setting), I started getting

Could not produce class with ID 64

My code goes like this...

public GameObject GetGameObjectAsset(WWW request, string key)                                     
{                                                                                                                
    GameObject obj = (GameObject)request.assetBundle.Load(key, typeof(GameObject));             
    return CreateGameObject(obj) : obj);          
} 

public GameObject CreateGameObject(GameObject obj)                                                               
{                                                                                                                
    if (obj == null) return null ;                                                                               
    Debug.Log(obj); // I get $myprefabname (UnityEngine.GameObject)
    GameObject newObj = (GameObject)Object.Instantiate(obj); // I get Could not produce class with ID 64                                    
    newObj.name = obj.name;
    return newObj;
}

This error happens regardless of the stripping level (strip assemblies and strip bytecode).

Any help would be greatly appreciated.

When you use stripping on your build if there no objects in the game that reference one of your scripts it will get stripped.
So when you use only asset bundles this is very likely to happen.
To avoid this simply create a scene that references all of the scripts that you need and they will then not be stripped.
You can also check the section “how to deal with stripping when using reflection” on this page http://unity3d.com/support/documentation/Manual/iphone-playerSizeOptimization.html

The way I fixed it was by using the link.xml file and adding the class to it.

In my case, I had the error about id 120.

I looked up the class ID in the class ID reference: Unity - Manual: Classes ordered by ID number

Then added that class to the link.xml file like so (it should be wrapped with `` tags, this is just an excerpt).

<assembly fullname="UnityEngine">
	<type fullname="UnityEngine.LineRenderer" preserve="all"/>
</assembly>