no product after "build success" of a cocoa touch static library project

691 Views Asked by At

I have searched so many problem but there is no the same as me. on Xcode 4.3.2(4.3.1)

I added several files to a new cocoa touch static library project and use iPhone Simulator to build it, then receive build success, but no .a file in products group (the .a file is red in the files list, left of Xcode)

When I change the "iPhone Simulator" to IOS Device, also receive build success, but now I can see .a file is not red and I can find in the product folder^

After I use lipo -info to check the .a file, it shows that it only supports arm7 architecture, thus confirms my first action(no product built in Simulator)^ so the .a file can't be used in my another project(i know it only can be used in simulator by supporting i386 architecture)

1

There are 1 best solutions below

1
On

Use the command line. Here is a simple script I built a while back, it will even lipo your binaries together for you!

#!/bin/bash
#build the device
echo building for ARM architecture
xcodebuild -sdk iphoneos4.3 "ARCHS=armv6 armv7" build > /dev/null
#build the simulator
echo building for the i386 architecture
xcodebuild -sdk iphonesimulator4.3 "ARCHS=i386 x86_64" "VALID_ARCHS=i386 x86_64" build > /dev/null
#make the folder
mkdir "Fat Binary"
#lipo suck it together
echo lipo binaries together
lipo -output Fat\ Binary/libMyLib.a  -create build/Release-iphoneos/liblibMyLib.a build/Release-iphonesimulator/libMyLib.a
echo lipo binary saved at $./Fat Binary/libMyLib.a
echo coping headers
cp -R build/Release-iphoneos/usr "Fat Binary"
echo [COMPLETE]

Just replace occurrences of libMyLib.a with the name of your library.