# Sets the target folders and the final framework product.
Fmk_name=hovnvoipengine
fmk_version=1.0
# Install Dir'll is the final output to the framework.
# The following line create it at the root folder of the current project.
Install_dir=${srcroot}/products/${fmk_name}.framework
# working dir would be a deleted after the framework creation.
Wrk_dir=build
Device_dir=${wrk_dir}/release-iphoneos/${fmk_name}.framework
Simulator_dir=${wrk_dir}/release-iphonesimulator/${fmk_name}.framework
# Building both architectures.
Xcodebuild-configuration "Release" -target "${fmk_name}" -sdk Iphoneos
Xcodebuild-configuration "Release" -target "${fmk_name}" -sdk iphonesimulator
# cleaning the oldest.
if [-D "${install_dir}" ]
Then
rm-rf "${install_dir}"
Fi
# creates and renews the final product folder.
mkdir-p "${install_dir}"
mkdir-p "${install_dir}/versions"
mkdir-p "${install_dir}/versions/${fmk_version}"
mkdir-p "${install_dir}/versions/${fmk_version}/resources"
mkdir-p "${install_dir}/versions/${fmk_version}/headers"
# creates the internal links.
# It must uses relative path, otherwise won't work when the folder is copied/moved.
ln-s "${fmk_version}" "${install_dir}/versions/current"
ln-s "versions/current/headers" "${install_dir}/headers"
ln-s "versions/current/resources" "${install_dir}/resources"
ln-s "Versions/current/${fmk_name}" "${install_dir}/${fmk_name}"
# Copies The headers and resources files to the final product folder.
cp-r "${device_dir}/headers/" "${install_dir}/versions/${fmk_version}/headers/"
cp-r "${device_dir}/" "${install_dir}/versions/${fmk_version}/resources/"
# removes the binary and header from the Resources folder.
rm-r "${install_dir}/versions/${fmk_version}/resources/headers""${install_dir}/versions/${fmk _version}/resources/${fmk_name} "
# Uses The Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo-create "${device_dir}/${fmk_name}""${simulator_dir}/${fmk_name}" -output "${ Install_dir}/versions/${fmk_version}/${fmk_name} "
rm-r "${wrk_dir}"