refactor code struct and add ios lib