X $ C $Ç - 符号(S)未找到x86_64的架构(IOS库) [英] Xcode - symbol(s) not found for architecture x86_64 (iOS Lib)
问题描述
我建立一个静态库。构建设置已经设置到体系结构: $(ARCHS_STANDARD)
被示为标准架构(ARMv7的,armv7s,arm64)
我建的lib选择iOS设备,然后使用仿真器(例如iPhone的Retina)。
现在,我有两个版本(一个在调试-的iPhoneOS
和其他内部调试 - iphonesimulator
,我使用脂-create
以创建聚集的lib目录下:
脂 - 创建路径/要/首/ lib目录/路径/要/秒/ lib目录-o mylib.a上
如果我用这个库中的另一个项目,以模拟在任何iOS设备与64位架构,它提供了符号(S)未找到架构的x86_64
。真正让我气得的lib项目本身是与使用的lib另一个项目工作区中。我可以模拟64位的iOS模拟器! (所有的模拟器和设备为此事)。我究竟做错了什么?
注:
- 在此不重复的问:在指责我的那个(因为这是我的第二天试图解决这个愚蠢的问题),我也搜索堆栈和谷歌。所有的答案都没有帮助。
- 我用X code 5.1.1。
我有同样的麻烦建立静态库。
最后,我已经找到了基本解决。 (您需要构建 x86_64的
/ 通用库的ARMv7
/ armv7s
/ arm64
)
1)点击项目文件
2)点击目标
3)打开构建阶段
4)打开运行脚本
5)加入/ bin / sh的
及以下
########################################## # #C.F. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-x$c$c-and-sdk-4 # #2.7版 # #最新变化: # - 支持iPhone 5 / iPod Touch的5(使用苹果的解决方法,以脂错误) # # 目的: #自动在X code创建一个通用的静态库的iPhone + iPad的+ iPhone模拟器 # #作者:亚当·马丁 - http://twitter.com/redglassesapps #基于:从Eonil原始脚本(主要变化:Eonil的脚本将无法工作在X $ C $ÇGUI - 它会崩溃您的计算机) # 设置-e 设置-o pipefail ################# [测试:有助于解决办法以x code的任何未来的错误] ######## # DEBUG_THIS_SCRIPT =假 如果[$ DEBUG_THIS_SCRIPT =真] 然后 回声###########试验############# 回声调试该脚本时,请使用以下变量;请注意,它们可能更改递归 回声BUILD_DIR = $ BUILD_DIR 回声BUILD_ROOT = $ BUILD_ROOT 回声CONFIGURATION_BUILD_DIR = $ CONFIGURATION_BUILD_DIR 回声BUILT_PRODUCTS_DIR = $ BUILT_PRODUCTS_DIR 回声CONFIGURATION_TEMP_DIR = $ CONFIGURATION_TEMP_DIR 回声TARGET_BUILD_DIR = $ TARGET_BUILD_DIR 科幻 #####################[ 第1部分 ]################## #首先,制定出BASESDK版本号(注:苹果公司应该报告这一点,但他们隐藏) #(附带:在SH搜索字符串是一场噩梦啜泣!) SDK_VERSION = $(回声$ {SDK_NAME} |'。\ {3 \} $'grep的-o) #接下来,工作,如果我们是在SIM卡或设备 如果[$ {PLATFORM_NAME} =iphonesimulator] 然后 OTHER_SDK_TO_BUILD =的iPhoneOS $ {SDK_VERSION} 其他 OTHER_SDK_TO_BUILD = iphonesimulator $ {SDK_VERSION} 科幻 回声X code选择了SDK:$ {PLATFORM_NAME}版本:$ {SDK_VERSION}(虽然回目标定位:$ {IPHONEOS_DEPLOYMENT_TARGET}) 回声......因此,OTHER_SDK_TO_BUILD = $ {OTHER_SDK_TO_BUILD} # ##################### [第1部分结束] ################## #####################[ 第2部分 ]################## # #如果这是原来的调用,调用WHATEVER其他版本是必需的 # #X code已经建立一个目标...... # #...但是这是一个库,因此苹果是错误的设置它来建立只有一个。 #......我们需要建立所有目标 #......我们不能重新建立一个已经在建的目标:X code会崩溃您的计算机如果你试试这个(无穷递归!) # # #所以:只建缺失的平台/配置。 如果[真== $ {ALREADYINVOKED:-false}] 然后 回声递归:我不是根调用,所以我不会递归 其他 # 临界: #prevent无限递归(X code很烂) 出口ALREADYINVOKED =真 回声递归:我的根......在递归所有丢失的建设目标,现在... 回声递归:...关于调用:X codebuild构型的\$ {配置} \ - 项目\$ {} PROJECT_NAME .X codeproj \-target \$ {} TARGET_NAME \-sdk \$ {OTHER_SDK_TO_BUILD} \$ {操作} RUN_CLANG_STATIC_ANALYZER = NOBUILD_DIR = \$ {BUILD_DIR} \BUILD_ROOT = \$ {BUILD_ROOT} \SYMROOT = \$ {SYMROOT} \ X codebuild构型的$ {}配置 - 项目$ {} PROJECT_NAME .X codeproj-target$ {} TARGET_NAME-sdk$ {OTHER_SDK_TO_BUILD}$ {操作} RUN_CLANG_STATIC_ANALYZER = NO BUILD_DIR =$ {BUILD_DIR}BUILD_ROOT =$ {BUILD_ROOT}SYMROOT =$ {SYMROOT} ACTION =建 #Merge所有平台的二进制文件作为脂肪二进制的每个配置。 #计算,其中(多)建立文件的来源: CURRENTCONFIG_DEVICE_DIR = $ {SYMROOT} / $ {}配置-iphoneos CURRENTCONFIG_SIMULATOR_DIR = $ {SYMROOT} / $ {}配置-iphonesimulator 回声以设备构建的:$ {CURRENTCONFIG_DEVICE_DIR} 回声以模拟器打造而成:$ {CURRENTCONFIG_SIMULATOR_DIR} CREATING_UNIVERSAL_DIR = $ {SYMROOT} / $ {}配置 - 通用 回声......我会输出一个普遍建立于:$ {CREATING_UNIVERSAL_DIR} #...删除previous这个脚本运行的产品 #注:这个目录只有通过该脚本创建 - 它应该是安全的删除! RM -rf$ {CREATING_UNIVERSAL_DIR} MKDIR$ {CREATING_UNIVERSAL_DIR} # 回声脂:当前配置($ {配置})创建输出文件:$ {CREATING_UNIVERSAL_DIR} / $ {EXECUTABLE_NAME} xcrun -sdk的iPhoneOS脂 - 创建 - 输出$ {CREATING_UNIVERSAL_DIR} / $ {EXECUTABLE_NAME}$ {CURRENTCONFIG_DEVICE_DIR} / $ {EXECUTABLE_NAME}$ {CURRENTCONFIG_SIMULATOR_DIR} / $ {EXECUTABLE_NAME} ######### # #补充:StackOverflow的建议,还复制包括文件 #(未经测试,但应该工作正常) # 回声抓取头从$ {PUBLIC_HEADERS_FOLDER_PATH} 回声(如果你嵌入您的库项目在其他项目中,您将需要添加 回声用户搜索头的构建设置:(NB包括双引号低于!) 回声$(TARGET_BUILD_DIR)的/ usr / local / include目录/ 如果[-d$ {CURRENTCONFIG_DEVICE_DIR} $ {PUBLIC_HEADERS_FOLDER_PATH}] 然后 MKDIR -p$ {CREATING_UNIVERSAL_DIR} $ {PUBLIC_HEADERS_FOLDER_PATH} #*必须是双引号外面? 的cp -r$ {CURRENTCONFIG_DEVICE_DIR} $ {PUBLIC_HEADERS_FOLDER_PATH}*$ {CREATING_UNIVERSAL_DIR} $ {PUBLIC_HEADERS_FOLDER_PATH} 科幻 科幻
6)按CMD + B
(建设项目)
7)搜索打开产品
8)导航1的目录了(CMD +↑),你将看到发布 - 通用
目录。
将有你的胖/通用
库,你准备好去!
I am building a static library. The build setting has the Architectures set to: $(ARCHS_STANDARD)
which is shown as Standard Architectures (armv7, armv7s, arm64)
I build the lib choosing iOS Device AND then using the simulator (for example iPhone Retina).
Now that I have two builds (one inside Debug-iphoneos
and the other inside Debug-iphonesimulator
, I use lipo -create
to create the aggregated lib:
lipo -create path/to/first/lib /path/to/second/lib -o MyLib.a
If I used this library in another project to simulate on any iOS device with 64-bit architecture, it gives symbol(s) not found for architecture x86_64
. What really makes me so angry that the lib project itself is inside a workspace with another project that use the lib. I can simulate on 64-bit iOS simulator! (on all simulators and devices for that matter). What am I doing wrong?
Notes:
- This is not duplicate Q. Before accusing me of that (since this is my second day trying to fix this stupid issue), I did search on Stack and Google. All answers don't help.
- I am using Xcode 5.1.1.
I had the same trouble with building static library.
Finally I have found the basic solution. (You need to build universal library for x86_64
/armv7
/armv7s
/arm64
)
1) Click on the project file
2) Click on the target
3) Open "Build Phases"
4) Open "Run Script"
5) Add "/bin/sh"
and the script below
########################################## # # c.f. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 # # Version 2.7 # # Latest Change: # - Supports iPhone 5 / iPod Touch 5 (uses Apple's workaround to lipo bug) # # Purpose: # Automatically create a Universal static library for iPhone + iPad + iPhone Simulator from within XCode # # Author: Adam Martin - http://twitter.com/redglassesapps # Based on: original script from Eonil (main changes: Eonil's script WILL NOT WORK in Xcode GUI - it WILL CRASH YOUR COMPUTER) # set -e set -o pipefail #################[ Tests: helps workaround any future bugs in Xcode ]######## # DEBUG_THIS_SCRIPT="false" if [ $DEBUG_THIS_SCRIPT = "true" ] then echo "########### TESTS #############" echo "Use the following variables when debugging this script; note that they may change on recursions" echo "BUILD_DIR = $BUILD_DIR" echo "BUILD_ROOT = $BUILD_ROOT" echo "CONFIGURATION_BUILD_DIR = $CONFIGURATION_BUILD_DIR" echo "BUILT_PRODUCTS_DIR = $BUILT_PRODUCTS_DIR" echo "CONFIGURATION_TEMP_DIR = $CONFIGURATION_TEMP_DIR" echo "TARGET_BUILD_DIR = $TARGET_BUILD_DIR" fi #####################[ part 1 ]################## # First, work out the BASESDK version number (NB: Apple ought to report this, but they hide it) # (incidental: searching for substrings in sh is a nightmare! Sob) SDK_VERSION=$(echo ${SDK_NAME} | grep -o '.\{3\}$') # Next, work out if we're in SIM or DEVICE if [ ${PLATFORM_NAME} = "iphonesimulator" ] then OTHER_SDK_TO_BUILD=iphoneos${SDK_VERSION} else OTHER_SDK_TO_BUILD=iphonesimulator${SDK_VERSION} fi echo "XCode has selected SDK: ${PLATFORM_NAME} with version: ${SDK_VERSION} (although back-targetting: ${IPHONEOS_DEPLOYMENT_TARGET})" echo "...therefore, OTHER_SDK_TO_BUILD = ${OTHER_SDK_TO_BUILD}" # #####################[ end of part 1 ]################## #####################[ part 2 ]################## # # IF this is the original invocation, invoke WHATEVER other builds are required # # Xcode is already building ONE target... # # ...but this is a LIBRARY, so Apple is wrong to set it to build just one. # ...we need to build ALL targets # ...we MUST NOT re-build the target that is ALREADY being built: Xcode WILL CRASH YOUR COMPUTER if you try this (infinite recursion!) # # # So: build ONLY the missing platforms/configurations. if [ "true" == ${ALREADYINVOKED:-false} ] then echo "RECURSION: I am NOT the root invocation, so I'm NOT going to recurse" else # CRITICAL: # Prevent infinite recursion (Xcode sucks) export ALREADYINVOKED="true" echo "RECURSION: I am the root ... recursing all missing build targets NOW..." echo "RECURSION: ...about to invoke: xcodebuild -configuration \"${CONFIGURATION}\" -project \"${PROJECT_NAME}.xcodeproj\" -target \"${TARGET_NAME}\" -sdk \"${OTHER_SDK_TO_BUILD}\" ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO" BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" SYMROOT=\"${SYMROOT}\" xcodebuild -configuration "${CONFIGURATION}" -project "${PROJECT_NAME}.xcodeproj" -target "${TARGET_NAME}" -sdk "${OTHER_SDK_TO_BUILD}" ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" ACTION="build" #Merge all platform binaries as a fat binary for each configurations. # Calculate where the (multiple) built files are coming from: CURRENTCONFIG_DEVICE_DIR=${SYMROOT}/${CONFIGURATION}-iphoneos CURRENTCONFIG_SIMULATOR_DIR=${SYMROOT}/${CONFIGURATION}-iphonesimulator echo "Taking device build from: ${CURRENTCONFIG_DEVICE_DIR}" echo "Taking simulator build from: ${CURRENTCONFIG_SIMULATOR_DIR}" CREATING_UNIVERSAL_DIR=${SYMROOT}/${CONFIGURATION}-universal echo "...I will output a universal build to: ${CREATING_UNIVERSAL_DIR}" # ... remove the products of previous runs of this script # NB: this directory is ONLY created by this script - it should be safe to delete! rm -rf "${CREATING_UNIVERSAL_DIR}" mkdir "${CREATING_UNIVERSAL_DIR}" # echo "lipo: for current configuration (${CONFIGURATION}) creating output file: ${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}" xcrun -sdk iphoneos lipo -create -output "${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}" "${CURRENTCONFIG_DEVICE_DIR}/${EXECUTABLE_NAME}" "${CURRENTCONFIG_SIMULATOR_DIR}/${EXECUTABLE_NAME}" ######### # # Added: StackOverflow suggestion to also copy "include" files # (untested, but should work OK) # echo "Fetching headers from ${PUBLIC_HEADERS_FOLDER_PATH}" echo " (if you embed your library project in another project, you will need to add" echo " a "User Search Headers" build setting of: (NB INCLUDE THE DOUBLE QUOTES BELOW!)" echo ' "$(TARGET_BUILD_DIR)/usr/local/include/"' if [ -d "${CURRENTCONFIG_DEVICE_DIR}${PUBLIC_HEADERS_FOLDER_PATH}" ] then mkdir -p "${CREATING_UNIVERSAL_DIR}${PUBLIC_HEADERS_FOLDER_PATH}" # * needs to be outside the double quotes? cp -r "${CURRENTCONFIG_DEVICE_DIR}${PUBLIC_HEADERS_FOLDER_PATH}"* "${CREATING_UNIVERSAL_DIR}${PUBLIC_HEADERS_FOLDER_PATH}" fi fi
6) Hit "cmd + B"
(Build Project)
7) Open Product in Finder
8) Navigate 1 directory up ("cmd + ↑"), and you will see "Release-universal"
directory.
There will be your "fat/universal"
library, You are ready to go!
这篇关于X $ C $Ç - 符号(S)未找到x86_64的架构(IOS库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!