经典错误:symbol(s) not found for architecture x86_64 || Undefined symbols for architecture x86_64:

记录经典,防止踩坑!!!!!

 

真机可以运行,模拟器报错。

错误信息显示如下:

Ld /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Products/Debug-iphonesimulator/MYPayBucketDemo.app/MYPayBucketDemo normal x86_64 (in target 'MYPayBucketDemo' from project 'MYPayBucketDemo')
    cd /Users/lyj/Desktop/sdk\ 制作/MYPayBucketDemo
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios11.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.1.sdk -L/Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Products/Debug-iphonesimulator -F/Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Products/Debug-iphonesimulator -F/Users/lyj/Desktop/sdk\ 制作/MYPayBucketDemo/MYPayBucketDemo -filelist /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Intermediates.noindex/MYPayBucketDemo.build/Debug-iphonesimulator/MYPayBucketDemo.build/Objects-normal/x86_64/MYPayBucketDemo.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Intermediates.noindex/MYPayBucketDemo.build/Debug-iphonesimulator/MYPayBucketDemo.build/Objects-normal/x86_64/MYPayBucketDemo_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Intermediates.noindex/MYPayBucketDemo.build/Debug-iphonesimulator/MYPayBucketDemo.build/MYPayBucketDemo.app-Simulated.xcent -framework MYSDKCoreKit -framework UIKit -framework MYPayBucket -framework Foundation -Xlinker -dependency_info -Xlinker /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Intermediates.noindex/MYPayBucketDemo.build/Debug-iphonesimulator/MYPayBucketDemo.build/Objects-normal/x86_64/MYPayBucketDemo_dependency_info.dat -o /Users/lyj/Library/Developer/Xcode/DerivedData/MYPayBucketDemo-gtrplkdamuwrabcpmyhxodgbqlgw/Build/Products/Debug-iphonesimulator/MYPayBucketDemo.app/MYPayBucketDemo

ld: warning: ignoring file /Users/lyj/Desktop/sdk 制作/MYPayBucketDemo/MYPayBucketDemo/MYPayBucket.framework/MYPayBucket, missing required architecture x86_64 in file /Users/lyj/Desktop/sdk 制作/MYPayBucketDemo/MYPayBucketDemo/MYPayBucket.framework/MYPayBucket (3 slices)
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_MYPayUser", referenced from:
      objc-class-ref in ViewController.o
      objc-class-ref in TestLoginViewController.o
      objc-class-ref in TestSendTransferViewController.o
  "_OBJC_CLASS_$_MYPayBucket", referenced from:
      objc-class-ref in ViewController.o
      objc-class-ref in TestReceiveTransferViewController.o
      objc-class-ref in TestLoginViewController.o
      objc-class-ref in TestSendTransferViewController.o
      objc-class-ref in TestScanCodeViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

 

 

 

网上查了好多文章,大部分说是路径问题

1.项目中含有静态库

可能是该静态库不支持在模拟器下编译,可使用真机或Generic iOS Device,一般就不会出现这个错误了;

2.缺少文件引用

从错误信息的""_OBJC_CLASS_$_FMDataBase",referenced from:"能够看出,是缺少FMDataBase文件的引用;

解决方法:

在Build Phases-->Compile Sources(items)中,添加报错的.m文件,点左下角的"+",在弹出框中找到报错的.m文件,选中,add
 

这种之类的

 

解决办法:

在自制的MYPayBucket.framework中,TARGET--》BuildSetting--》Valid Architectures中添加x86_64;如下图所示。

具体原因,真机arm格式,模拟器x87格式,所以MYPayBucket.framework不支持。添加x86_64格式就行。

x86

 

 

 

 

 

 

 

继续挖坑愉快填😀😃:

问题:使用aggregate根据脚本语言打包,打出来的framework不支持模拟器,错误同上;

脚本语言如下:

# Type a script or drag a script file from your workspace to insert its path.

# Sets the target folders and the final framework product.

# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME

# 例如: FMK_NAME = "MyFramework"

FMK_NAME=${PROJECT_NAME}

 

# Install dir will be the final output to the framework.

# The following line create it in the root folder of the current project.

INSTALL_DIR=${SRCROOT}/../MYPayBucket/${FMK_NAME}.framework

 

# Working dir will be deleted after the framework creation.

WRK_DIR=build

DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework

SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework

 

# -configuration ${CONFIGURATION}

# Clean and Building both architectures.

xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean build

xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator -arch x86_64

 

# Cleaning the oldest.

if [ -d "${INSTALL_DIR}" ]

then

rm -rf "${INSTALL_DIR}"

fi

 

mkdir -p "${INSTALL_DIR}"

 

cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"

 

# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.

lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"

 

rm -r "${WRK_DIR}"

 

open "${SRCROOT}/../MYPayBucket"

 

 

解决方法:

脚本语言采用Release-iphoneos 和Release-iphonesimulator进行framework二进制合并,二项目中并没有配置Release-模式下的x86_64格式,所以出来的包不支持模拟器。

在targets--buildsettings--***PayBucket--valid architectures下添加x86_64格式即可,然后从新aggregate打包。

注意:在targets--buildsettings--***PayBucketAggregate--valid architectures下添加x86_64格式是无效的,亲测。

问题总计3

 

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: undefined symbols for architecture x86_64 意思是在编译或链接时,找不到指定的符号或函数。这通常是由于缺少库文件或头文件,或者代码中存在语法错误或逻辑错误导致的。需要检查代码和依赖项,以解决这个问题。 ### 回答2: “undefined symbols for architecture x86_64”这个错误信息通常出现在使用C/C++语言进行编程时。这个错误表示在链接时缺少符号,编译器无法找到函数或变量的定义。在x86_64架构中,符号可能是函数、变量或其他代码,因此需要通过特定的符号解析过程来定义他们。 这个错误可以通过以下方法解决: 1.检查代码中是否有定义所有需要的函数和变量,如果有遗漏,需要添加定义。 2.检查头文件和库文件是否正确包含,必须确保所有必需的头文件和库文件都被正确链接。 3.检查编译器选项和链接器选项是否正确设置。如果编译时使用了新的标志或选项,可能需要更新链接器选项。 4.如果代码中使用了某些外部库的函数,则需要确保库已经被正确添加到链接器中。 5.如果使用了静态库,那么需要确保发布的静态库文件与正在编译的代码是匹配的。 在解决了上述问题后,编译器会将代码重新链接,以确保所有符号被正确解析。此时,就可以消除“undefined symbols for architecture x86_64”的错误提示,顺利完成编译和链接过程。 ### 回答3: "undefined symbols for architecture x86_64"是一种错误信息,通常出现在使用编译器或链接器编译和构建程序的过程中。这个错误信息表明,编译器或链接器无法找到代码中引用的某些函数或变量的定义。 这个错误信息提示中的“architecture x86_64”表示代码的编译架构是x86_64,即64位的x86架构。这个错误还可以在其他架构上出现,如ARM架构等。 这种错误通常是由于程序中调用的某些库或函数没有正确地链接到程序中,或者库或函数的定义没有包括在项目中导致的。解决这个问题的一种方法是检查相关的库或函数是否正确地链接到程序中,并确保它们的定义包括在项目中。可以使用命令行工具或IDE中的链接器选项来解决这个问题。 此外,也有可能是由于程序中使用了已过时的函数或库,或者程序中的代码出现了错误。在这种情况下,需要检查代码并修复错误,或者使用更新的函数或库来替换旧代码。 总之,“undefined symbols for architecture x86_64”是一个指出编译/链接过程中可执行文件依赖库不匹配或者找不到库函数的错误信息,需要检查相关链接库、函数定义文件和编译器选项并修正代码错误,以解决此问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值