Static Library to Framework

Datetime:2016-08-23 01:39:44          Topic: Xcode  Cocoa           Share

I have no idea , new version of cocoa pods was not working with 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 current static library to the framework. I wrote about how to build enable bit code for static library.

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

I changed my build code like following


# build.sh 
folder="Release"
project_name="mycustomlib"
lib_name="libmycustom"
name_simulator=$lib_name"_simulator"
name_device=$lib_name"_device"

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_FLAGS="-static"
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 same path with build.sh .

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





About List