Xcode 4 中的静态库 [英] static Library in Xcode 4

查看:30
本文介绍了Xcode 4 中的静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我太喜欢 Xcode 4.X 中的静态库了

I am too much of this Static Libary thing in Xcode 4.X

以下是我通常做的步骤..

Following are the steps that I usually do..

1)为了制作一个静态库,我打开Xcode,new,static libary,然后在项目中添加一些类..然后构建阶段->复制头文件->在这里一一添加所有头文件,然后我建立了这个项目在 ios 模拟器上运行时 -> 未创建静态库..(红色)在 ios 设备上运行时 - > 创建静态库..

1)For making a static libary , I open Xcode , new , static libary , and then by adding some classes in the project .. then build phases ->copy headers -> add all headers here one by one,and then i build up the project when run on ios simulator -> static libary does not created ..(red color) when run on ios device - > static library gets created..

2) 用于使用库..我创建了一个新项目,然后我将文件添加到项目"并根据需要复制"以下 2 个文件...a 文件(即静态库)包含库文件头文件的文件夹

2) for using the library.. I make a new Project , then i "add files to project" and also "copy if needed" the following 2 files.. .a file (i.e.static library) folder consisting the headers of library files

现在,当我尝试在我的项目中导入头文件时,没有出现建议"......但我仍然写并且它没有给出错误找不到头文件"......

Now when I try to import a header file in my project , there is no "suggestion" appear ...but still i write and it does not give an error "header file not found"...

但是当我运行项目时,它给出了如下错误:

but when I run the project it gives the error like:

ld:警告:忽略文件/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a,文件是为归档而构建的,这不是被链接的架构(i386):/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a

ld: warning: ignoring file /Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a, file was built for archive which is not the architecture being linked (i386): /Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_LibraryImporting_test", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

请指导我....指出如果在某个步骤出错....请帮助我如果有人提到我在制作库和在项目中使用它所做的所有步骤会更好......这将是一个很大的帮助

Plz guide me....point out if get wrong at some step....help plz it will be better if someone mentions all the steps as i have done in making a library and using it in a project...it will be a great help

推荐答案

问题的关键是错误信息的这部分:

The key to the issue is this part of the error message:

文件是为归档而构建的,这不是被链接的架构(i386)

file was built for archive which is not the architecture being linked (i386)

从外观上看,您已导入为 iPhone 设备 (ARM) 构建的库,并且您正尝试在 i386 的 iPhone 模拟器中使用它.

You have imported the library built for the iPhone Device (ARM) by the look of it, and you are trying to use it in the iPhone Simulator which is i386.

我建议使用 Xcode 工作区,其中静态库项目是其中一个项目,而 iPhone 应用程序是另一个项目.这样,Xcode 将根据需要为调试/发布和设备/模拟器构建库.

What I would recommend is using an Xcode Workspace where the static library project is one of the projects and the iPhone app is another project. This way Xcode will build the library, as required, for Debug/Release and Device/Simulator.

这篇关于Xcode 4 中的静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆