codesign -f -s "3rd Party Mac Developer Application: Your Company" -v YourApp.app productbuild --component YourApp.app /Applications --sign "3rd Party Mac Developer Installer: Your Company" YourApp.pkg
There is a lot more to do, of course, like having the correct bundle ID set, but this speeds up codesigning, if you do not use XCode to build your application.
For iOS it is pretty similar, except you don't need the productbuild:
codesign -f -s "iPhone Distribution: Your Company" -v YourApp.app