Added OS X framework build target. Also added background/foreground detection on iOS.