iPhone build error: Attempting to JIT compile method in AOT only

ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) UnityEngine.GameObject:GameObject$get_renderer$ (object,object[])' while running with --aot-only.

  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.CreateMethodDispatcher () [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.Emitters.DispatcherEmitter.Emit () [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.EmitPropertyDispatcher (System.Reflection.PropertyInfo property, SetOrGet gos) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.EmitDispatcherFor (System.Reflection.MemberInfo info, SetOrGet gos) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter () [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices+<GetProperty>c__AnonStorey15.<>m__A () [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) [0x00000] in <filename unknown>:0 
  at Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name) [0x00000] in <filename unknown>:0 
  at UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name) [0x00000] in <filename unknown>:0 
  at GameController+$UpdateSequence$92+$.MoveNext () [0x00000] in <filename unknown>:0 
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
$:MoveNext()
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
$:MoveNext()
 
(Filename:  Line: -1)

Anyone know how to fix this error?

Do you have code that lead to this?
We could do a lot of blind guessing that wouldn’t get you anywhere I fear.

It happens as soon as you exit the menu into the game scene. I can post the whole game script but it’s pretty long

enum State {Initialise,Sequence,Play,Pause,Win,Lose,GameOver,LevelComplete};

var rootObject 		: GameObject;
var animationRoot	: GameObject;
var corona				: GameObject;
var outerRing 			: GameObject;
var innerRing 			: GameObject;
////////////////////////
//	Buttons info:
//	0 - Blue
//	1 - Green
//	2 - Red
//	3 - Yellow
////////////////////////
var outerButtons		: GameObject[];
var innerButtons		: GameObject[];

// GUI
var guiColour					: Color;
var guiSkin 					: GUISkin;
var gameOverTexture 		: Texture2D;
var levelCompleteTexture 	: Texture2D;
var heartIcon					: Texture2D;

// sounds
var pingSound 	: AudioClip;
var buzzerSound	: AudioClip;
var klaxonSound	: AudioClip;


// level stats
var currentLevel		: int 		= 1;
var difficultyLevel	: int 		= 1;
var score				: int 		= 0;
var pointsPerHit		: int 		= 1;
var TimeBonus		: int 		= 10;
var maxTime			: float 	= 20;
var lives				: int 		= 3;

// disc rotation
var outerSpinSpeed	: float 	= 2;
var innerSpinSpeed	: float 	= 0;
var maxSpinSpeed	: float 	= 60;

// button timings
var flashTime			: float 	= 1.5;
var minFlashTime		: float 	= 0.2;

// counters, arrays, etc
var timeCounter 			: float	= 60;
var gameState 			: State 	= State.Sequence;
private var buttonSequence 	:  Array = new Array();
private var sequenceIndex 		: int = 0;

function Start(){
	//buttonSequence = new Array();
	
	yield WaitForSeconds(4); // wait for animtaion
	
	rootObject.transform.position = Vector3.zero;
	NewGame();
}

function Update () {
	if(gameState == State.Play){
		UpdateTime();
		UpdateTouchInput();
	}
	UpdateCorona();
}

function OnGUI(){
	GUI.skin = guiSkin;
	GUI.color = guiColour;
	
	if(gameState == State.Initialise){
		
	}else if(gameState == State.GameOver){
		GUI.DrawTexture(Rect(0,Screen.height/2-(Screen.width*0.1),Screen.width,Screen.width*0.2),gameOverTexture);
		GUI.Label(Rect(0,50,Screen.width,40),"SCORE: "+score,"Centered");
		if(GUI.Button(Rect(Screen.width/2-190,Screen.height/2+(Screen.width/11)+20,180,40),"","Restart")){
			Application.LoadLevel(Application.loadedLevel);
		}
		if(GUI.Button(Rect(Screen.width/2+10,Screen.height/2+(Screen.width/11)+20,180,40),"","Menu")){
			// go to menu
			Application.LoadLevel("TTT_MainMenu");
		}
	}else if(gameState == State.LevelComplete){
		GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
		GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
		GUI.DrawTexture(Rect(0,Screen.height/2-(Screen.width*0.05),Screen.width,Screen.width*0.1),levelCompleteTexture);
		GUI.Label(Rect(0,Screen.height-100,Screen.width,40),"Level Bonus: "+(currentLevel*difficultyLevel*20),"Centered");
		for(i=0;i<lives;i++){
			GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
		}
	}else if(gameState == State.Win){
		GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
		GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
		GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
		GUI.Label(Rect(0,Screen.height-100,Screen.width,40),"Time Bonus: "+(Mathf.Ceil(timeCounter)*difficultyLevel),"Centered");
		for(i=0;i<lives;i++){
			GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
		}
	}else if(gameState == State.Pause){
		// Pause Buttons
		if(Screen.width<500){
			if(GUI.Button(Rect(Screen.width*.85,Screen.height*.05625,48,43),"","Pause")){
				gameState = State.Play;
			}		
		}else{
			if(GUI.Button(Rect(846,34,97,84),"","Pause")){
				gameState = State.Play;
			}
		}
		if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2-40,180,40),"","Continue")){
			gameState = State.Play;
		}
		if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2+5,180,40),"","Restart")){
			Application.LoadLevel(Application.loadedLevel);
		}
		if(GUI.Button(Rect(Screen.width/2-90,Screen.height/2+50,180,40),"","Menu")){
			// load menu
			Application.LoadLevel("TTT_MainMenu");
		}
		GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
		GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
		for(i=0;i<lives;i++){
			GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
		}
	}else if(gameState == State.Play){
		// Pause Buttons
		if(Screen.width<500){
			if(GUI.Button(Rect(Screen.width*.85,Screen.height*.05625,48,43),"","Pause")){
				gameState = State.Pause;
			}		
		}else{
			if(GUI.Button(Rect(846,34,97,84),"","Pause")){
				gameState = State.Pause;
			}
		}
		GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
		GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
		GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
		for(i=0;i<lives;i++){
			GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
		}
	}else{
		GUI.Label(Rect(Screen.width*0.04,15,Screen.width,40),"LEVEL - "+currentLevel.ToString());
		GUI.Label(Rect(Screen.width*0.04,27,Screen.width,40),"SCORE - "+score.ToString());
		GUI.Label(Rect(0,Screen.height/2-6,Screen.width,40),Mathf.Ceil(timeCounter).ToString(),"Centered");
		for(i=0;i<lives;i++){
			GUI.DrawTexture(Rect(Screen.width-32*i-42,Screen.height-35,32,30),heartIcon);
		}
	}
}

function UpdateTime(){
	timeCounter -= Time.deltaTime;
	if(timeCounter <= 0){
		LoseLife();
	}
}

function UpdateTouchInput(){
	// spin the disc
	if(currentLevel >= 1){
		outerRing.transform.Rotate(Vector3.forward*outerSpinSpeed*Time.deltaTime);
	}
	if(currentLevel >= 20){
		innerRing.transform.Rotate(-Vector3.forward*innerSpinSpeed*Time.deltaTime);
	}
	
	if(Application.isEditor){
		// stuff
	}else{
		if(Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Began){
			
			// Construct a ray from the current mouse coordinates
        	ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
		
   	     	if (Physics.Raycast (ray,hit)) {
				for(i=0;i<4;i++){
					if(hit.collider.gameObject == outerButtons[i]){
						TouchButton(outerButtons[i]);
						outerButtons[i].renderer.material.color = Color.white;
						if(!PlayerPrefs.HasKey("Mute")){
							audio.pitch = 1-i*0.1;
							audio.Play();
							}
					}else if(hit.collider.gameObject == innerButtons[i]){
						TouchButton(innerButtons[i]);
						innerButtons[i].renderer.material.color = Color.white;
						if(!PlayerPrefs.HasKey("Mute")){
							audio.pitch = 1-i*0.1;
							audio.Play();
						}
					}
				}
			}
		}
	
		if(Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount < 1){
			// make all materials grey
			for(i=0;i<4;i++){
				innerButtons[i].renderer.material.color = Color.grey;
				outerButtons[i].renderer.material.color = Color.grey;
			}
		}		
	}
}

function TouchButton(go : GameObject){
	if(go == buttonSequence[sequenceIndex]){
		sequenceIndex++;
		score += sequenceIndex;
		if(buttonSequence.length == sequenceIndex){
			Win();
		}
	}else{
		LoseLife();
	}
}

function Win(){
	//stuff
}

function LoseLife(){
	// stuff
}

function NewGame(){
	
	flashTime *= 0.9;
	flashTime = Mathf.Clamp(flashTime,0.2,1);
	
	if(buttonSequence.length >= difficultyLevel*5){
		gameState = State.LevelComplete;
		score += currentLevel*difficultyLevel*20; // level bonus
		
		animationRoot.animation.Play("fly out and in");
		yield WaitForSeconds(4.5); // display the level complete screen for 3.5 seconds
		
		rootObject.transform.position = Vector3.zero;
		
		currentLevel++;
		
		// Clear the array
		buttonSequence.Clear();
		sequenceLength = 0;
		
		//lives = 3;
		flashTime = 1-currentLevel*0.01;
		outerSpinSpeed += 6;
		outerSpinSpeed = Mathf.Clamp(outerSpinSpeed,0,maxSpinSpeed);
		if(currentLevel>5){
			innerSpinSpeed += 6;
			innerSpinSpeed = Mathf.Clamp(innerSpinSpeed,0,maxSpinSpeed);
		}
	}
	
	timeCounter = maxTime-difficultyLevel*5;

	UpdateSequence();
}

function LoseRepeat(){
	// stuff
}

function UpdateSequence(){
	gameState = State.Sequence;
	
	// set up the audio
	audio.clip = pingSound;
	
	// make all materials grey
	for(i=0;i<4;i++){
		innerButtons[i].renderer.material.color = Color.grey;
		outerButtons[i].renderer.material.color = Color.grey;
	}
	
	// Step 1: Select a random button
	var buttonIndex = Random.Range(0,4);
	var buttonGO : GameObject;
	if(currentLevel < 5){ // inner ring only activates beyond level 20
		buttonGO = outerButtons[buttonIndex];
	}else{
		if(Random.value>0.5){ // outer ring
			buttonGO = outerButtons[buttonIndex];
		}else{	// inner ring
			buttonGO = innerButtons[buttonIndex];
		}
	}
	// Step 2: Record the button
	buttonSequence.Push(buttonGO);
	
	// Step 3: Flash the whole sequence button on for a second
	for(i=0;i<buttonSequence.length;i++){
		buttonSequence[i].renderer.material.color = Color.white;
		
		// pitch change audio
		for(j=0;j<4;j++){
			if(buttonSequence[i] == outerButtons[j]){
				if(!PlayerPrefs.HasKey("Mute")){
					audio.pitch = 1-j*0.1;
					audio.Play();
					break;
				}
			}else if(buttonSequence[i] == innerButtons[j]){
				if(!PlayerPrefs.HasKey("Mute")){
					audio.pitch = 1-j*0.1;
					audio.Play();
					break;
				}
			}
		}
			
		yield WaitForSeconds(flashTime);
			
		buttonSequence[i].renderer.material.color = Color.grey;
		audio.Stop();
			
		yield WaitForSeconds(flashTime/2);
	}
	
	
	gameState = State.Play;
}

function UpdateCorona(){
	// stuff
}

function PlayFlyOut(){
     // stuff
}

function GameOver(){
	// stuff
}

had to chop out some bits to fit it in but I don’t know which bit in it is causing the error. It happens the moment the scene is loaded and there’s no other scripts in the scene.

From the error it sounds like GetRenderer is the problem but I don’t know where in my code that appears

EDIT:

so changing all the gameObject.renderer

into

var temp : Renderer = gameObject.GetComponent(Renderer)

Causes the same error but with “renderer” replaced by “GetComponent” in the error message

Could it be because I’m using Array()?
Lets give that a try…

EDIT2:

YEA!
Thanks unity community, solved it. It was indeed the use of javascript arrays and the lack of dynamic type setting in iphone. It didn’t get flagged up in the editor so I missed it.

Assigning the contents of the Array to a game object variable let me perform the required tasks on the objects in the array without the game crashing

@spinaljack -

I have the same problem. Can you post what piece of code you changed?