从工作区创建静态库

时间:2013-06-21 08:26:39

标签: ios xcode static-libraries

我设法使静态库工作,一切正常。现在我已经移动到正确的库,我想创建我有问题。我使用cocoapods导入其他文件,它创建了一个工作区。现在我编写的脚本不再有效,我的假设是因为我现在在框架中工作。我一直在谷歌搜索几个小时试图得到答案,但我发现的所有事情只涉及将一个项目变成一个图书馆 我的问题是: 1)是否可以将工作空间合并为一个单独的库? 2)我应该尝试创建一个框架吗? 3)是不是我的剧本不正确?

XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphoneos" -      configuration "Release" clean build
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphonesimulator" -   configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"

也试过这个

XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -workspace T5Pusher.xcworkspace -scheme "T5Pusher" -sdk "iphoneos" -      configuration "Release" clean build
$XCODEBUILD -workspace T5Pusher.xcworkspace -scheme "T5Pusher" -sdk "iphonesimulator" -   configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"

我得到的错误是

** BUILD FAILED **


The following build commands failed:
Libtool build/PusherTest.build/Release-iphoneos/PusherTest.build/Objects-    normal/armv7/libPusherTest.a normal armv7
Libtool build/PusherTest.build/Release-iphoneos/PusherTest.build/Objects-normal/armv7s/libPusherTest.a normal armv7s
(2 failures)
lipo: can't open input file: build/Release-iphoneos/libPusherTest.a (No such file or directory)
Showing first 200 notices only

并且对于第二个,构建成功但是库(.a)文件永远不会被创建,所以它不能组合它们

2 个答案:

答案 0 :(得分:0)

我找到了解决方案。您必须使用命令:

pod install --no-integrate

安装pod时。这不会创建工作区并允许使用脚本

XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphoneos" -        configuration "Release" clean build
$XCODEBUILD -project T5Pusher.xcodeproj -target "T5Pusher" -sdk "iphonesimulator" -   configuration "Release" clean build
lipo -create -output "build/libT5Pusher.a" "build/Release-iphoneos/libT5Pusher.a" "build/Release-iphonesimulator/libT5Pusher.a"

然后设置pods的配置文件:

- 转到项目编辑器 - >信息 - >构造

- 设置目标以使用pods.xconfig文件进行调试和发布

答案 1 :(得分:0)

我自己也有同样的问题,发现如果我指定了输出目录然后告诉lipo看那里然后它仍然让我使用工作区。在Xcode 5中可能有所不同,但是当我将它用作自定义构建阶段时,它可以在不指定输出目录的情况下工作,我只需将lipo指向$ {BUILD_DIR}即可找到生成的文件。

$XCODEBUILD -project T5Pusher.xcodeproj \
 -target "T5Pusher" \
 -sdk "iphoneos" \ 
 -configuration "Release"
 OBJROOT=${env_variable_to_some_directory}/Obj.root \
 SYMROOT=${env_variable_to_some_directory}/Sym.root \
 DSTROOT=${env_variable_to_some_directory}/Dst.root \
 clean build