3
votes

When creating a Cocoa Touch Static Library with XCode4, the .a file in the Products groups appear red and building doesnt fix this. Then, when adding this project to another project in the same workspace with Build Phases/Link Binary With Libraries, the build fails at linking. Any pointers?

Edit: It looks like a problem with anything I build with XCode4, because no matter what project I build, the content of Products appears in red.

4
Are you sure you have chosen the correct scheme when you build? I just created a static lib project in Xcode4 a few days ago and it worked just fine. - Firoze Lafeer
@Firoze Lafeer, there's only one scheme created. - sharvey
can you explain me how to create static libraries using xcode4.0.I currently using xcode4.0 and there is no good online help for creating static library using xcode4.0. its urgent to me. thanks in advance. emailId : [email protected] - Naveen Shan

4 Answers

1
votes

I experienced the same bug in Xcode 4. Try building the project for the device. Once I did that once, the build product turned black and I could then build for the simulator or device without issues. You may also need to re-add the libraries to your dependent project.

1
votes

XCODE 4.x builds .a files in respective directory - below is description of release build for simulator and iphone

There was no modification to project settings during the output

/Users/userName/Library/Developer/Xcode/DerivedData/projectName-uniqueIdentifier/Build/Products/Release-iphoneos

/Users/userName/Library/Developer/Xcode/DerivedData/projectName-uniqueIdentifier/Build/Products/Release-iphonesimulator

replace below values -

userName = change userName to current user
projectName-uinqueIdentifier = project name followed by unique identifier
0
votes

When the product name is in red, that indicates it wasn't built successfully. Check the "issues" pane to see what the problem was. The triangle & exclamation point icon will bring it up, as shown here:

enter image description here

(Sorry, Grab captured the tool tip, but not the mouse cursor - I hope you can see the icon I mean anyway.)

0
votes

Looking at the comments, I'm a little confused. It sounds like you have successfully built the library, but maybe you haven't got a static build yet? Because that's what you'll want if you're trying to link it to another project. If that's the case, then you need to run the scheme that includes the static library target first. Then it will appear, and then you can link it to another project.