记录经典,防止踩坑!!!!!
真机可以运行,模拟器报错。
错误信息显示如下:
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格式就行。
继续挖坑愉快填😀😃:
问题:使用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格式是无效的,亲测。