Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6.1 static library .a for iOS not generated

I tried to make a static library for my iOS device using Xcode 6.1.

I choose on Xcode a new project with template Cocoa Touch Static Library and named it MyLib. For MyLib target I choose iPhone 6 in the Simulator.

After the project was opened, I build MyLib with succeed.

But if I look to the Products folder, the libMyLib.a is red and nothing happens, if I want show it with finder.

In prior versions of Xcode it seems to work, how I find in some tutorials.

I found the solution: the library is created under

../Xcode/Products/Debug-iphonesimulator/libMyLib.a

If I switch the target to the my real iPhone 6 it works too and in the Products Folder the libMyLib would be black and the library is created under

../Xcode/Products/Debug-iphoneos/libMyLib.a

like image 371
MUECKE446 Avatar asked Nov 20 '14 13:11

MUECKE446


People also ask

How do I create a static library in Xcode?

Open XCode and start a new project. Under iOS, select Library and “Cocoa Touch Static Library” say it as "staticlibrary". This will create a nice new project for us that builds a . a file.

What is iOS Dylib?

clang-as-ios-dylib is a workaround for building iOS dynamic libraries from Xcode. Most importantly, it lets Xcode build iOS dylibs without requiring any modifications to the Xcode installation. It works by tricking Xcode into building an OS X dynamic library as if it were an iOS dynamic library.

How do I create a static library in Swift?

Create Static Library ProjectOpen Xcode and select Cocoa Touch Static Library . Give it a name and select Swift as the development language. In our case, we will call it Networking and assume that it will contain the code to communicate with a back end. Press Cmd+N and select Swift file .

What is the difference between static library and dynamic library in Swift?

Static libraries, unlike dynamics, gather object files into one, while dynamics exist as separate files outside the executable, which means that static libraries add those files as they link, before it becomes an executable binary and dynamic libraries also have object files but are not added during compilation, they ...


1 Answers

This happened to me as well. I believed the libMyLib.a was built successfully and sat under Debug-iphonesimulator folder but Xcode couldn't link to the correct path. Two way you can find it.

  1. As OP suggested, build the library with iPhone 6. The target library should be in black and right click show in folder. The library folder for Debug-iphonesimulator is at the same level as Debug-iphoneos

  2. Find your build target directory. Typically, it is under:

/Users/yourName/Library/Developer/Xcode/DerivedData/yourProjectName-wholebunchofalphebets/Build/Products

like image 151
timbuntu2 Avatar answered Oct 28 '22 14:10

timbuntu2