A Static Library to Framework

I have no idea, a new version of cocoa pods was not working with the static library. It was working before and I didn’t change any code in podspec. Xcode couldn’t find my library when it was building.

So, I decided to change the current static library to the framework. I wrote about how to build enable bit code for the static library.

I don’t want to change current my code and the current code cannot change to framework because it was using other static libraries inside, too.

I changed my build code like following

# build.sh 

xcodebuild OTHER_CFLAGS="-fembed-bitcode" -target $project_name build
xcodebuild OTHER_CFLAGS="-fembed-bitcode" -sdk iphonesimulator -target $project_name build
rm -r build/Production-SDK
cp -r build/$folder-iphoneos build/Production-SDK
cp build/$folder-iphonesimulator/$lib_name.a build/Production-SDK/$name_simulator.a
mv build/Production-SDK/$lib_name.a build/Production-SDK/$name_device.a
cd build/Production-SDK/
lipo -create $name_simulator.a $name_device.a -output $lib_name.a
rm $name_device.a
rm $name_simulator.a
file $lib_name.a

# Time For Building Framework
rm -rf $lib_name".framework"
mkdir $lib_name".framework"

libtool -no_warning_for_no_symbols $LIBTOOL_FLAGS -o $lib_name.framework/$lib_name $lib_name.a
cp -r ./usr/local/include $lib_name.framework/Headers/
cp ../../fwInfo.plist $lib_name.framework/Info.plist

open .

You need to have fwInfo.plist for framework plist file. You can create easily framework plist file from the Xcode. File > Project > Framework & Library > Cocoa Touch Framework

After that copy, the info.plist, and change to fwInfo.plist. Put in the same path with build.sh.

After running the build.sh , you will see the framework file, too.

Gravatar Image
My name is Than Dana but I’d like to be called Dana. I’m 28 years old and a single man. I’m from Toungoo, Bago division. I live in Yangon for my job and work as Digital Marketing Executive @ Win Mobile World Co., Ltd. I stand as a professional in IT fields and have been sharing, inventing and advancing tech developments since about 2008.