I have the following code:
using UnityEngine;
using System.Collections;
public class ShowKeyboard : MonoBehaviour {
string inputText = "my text";
iPhoneKeyboard keyboard;
void OnGUI() {
GUI.Label(new Rect(0,40,200,32),inputText);
if (GUI.Button(new Rect(0, 10, 200, 32), inputText))
keyboard = iPhoneKeyboard.Open(inputText);
if (keyboard.active)
inputText = keyboard.text;
}
}
When I add the lines:
if (keyboard.active)
inputText = keyboard.text;
then I get a runtime error when Xcode builds onto the device:
GDB: Program received signal: “SIGBUS”.
take this code away and all works fine.
any ideas ?
thx
if (iPhoneKeyboard.visible)
inputText = keyboard.text;
works but still interested in the original error - thx
SIGBUS error also occurs when checking if (keyboard.done)
Not 100% sure but I think you should not check for .active but just use
if( keyboard ) in this case (as you can see on the iPhoneKeyboard.active documentation page)
EDIT: This posting was edited and the author of the thread already has included it.
Still I would like to point out why this check and not the original keyboard.active one:
if you just check for keyboard.active you have the ugly problem that if the keyboard has not happened yet and is not fully there, you potentially try to access an inexistant object which would lead to a nullreference error or kill it as in this case
thx for the reply.
keyboard is not a boolean.
iPhoneKeyboard.visible works but the active option should not kick out a runtime error. If anything I would expect a compile error in Unity.
thx again
(btw: I agree its ugly as it could be sliding in/out but even then I guess the user could be tapping the keyboard. Visible is a nicer solution albeit it is used on the type rather than the instance although I doubt you would have more than one keyboard showing?)
right keyboard is not a boolean
But if( keyboard ) isn’t a boolean check too 
actually its a nice stealthed if( keyboard != null )
thx.
yep if(keyboard !=null) is a good solution as it targets the instance. iPhoneKeyboard.visible is possibly more elegant and the better way for a simple solution. So now we have two ways to manage this for different circumstances.
The docs show if(keyboard) but that is JS and I have no idea if this is valid but either way it may help if the docs are updated.
maybe someone from support will see this and can look at the active runtime error.
Its valid code 
Thats one of the benefits of JS, it has a lot of “lazy syntax” capabilities that take care of “intuitive human assumptions”
create a bugreport so its logged and can be looked into.
Throughout this I wondered if it was possible to create more than one keyboard on screen at the same time but it seems its not possible (that I can see anyhow, at least from within Unity).
bug report filed with a link to this thread.
thanks again
OK looking further into this the issue :
if(keyboard.active) // until the keyboard is showing then this would be a null reference and hence the SIGBUS error. same with if(keyboard.visible).
It may be a case that when you: iPhoneKeyboard.Open(…) you set a flag to say its open then you can test for the other stuff.
One other point is that I have found that if you tap the done button it destroys the text in the textfield immediately which means if you want to commit the typing only when ‘done’ rather than ‘as you type’ you would have to use an intermediate field to hold the typing then check keyboard.done (keyboard being the ref to the iPhoneKeyboard)
here is an example:
using UnityEngine;
using System.Collections;
public class ShowKeyboard : MonoBehaviour {
iPhoneKeyboard keyboard;
string inputText;
bool keyboardIsVisible = false;
string intermediateText;
//show typing output in a label when done is pressed
void OnGUI() {
GUI.Label(new Rect(0,40,200,32),inputText);
if (GUI.Button(new Rect(0, 10, 200, 32), "Open the Keyboard"))
{
keyboardIsVisible = true;
//following Open shows all options and is set to multiline with a placeholder of "enter some text"
keyboard = iPhoneKeyboard.Open("",iPhoneKeyboardType.Default,true,true,false,false,"enter some text");
}
//this will update as you type
if (keyboardIsVisible)
intermediateText = keyboard.text;
//this will update only when you are happy with what you have typed via the keyboard
if(keyboardIsVisible keyboard.done)
{
inputText = intermediateText;
keyboardIsVisible = false;
}
}
}
I guess what is happening is that the keyboard instance is only created when the keyboard is opened. Before that its going to be null. This makes sense as there would be no point in carrying it around as it would only take up memory.