[背景]
之前用iOS 模拟器的iPhone 5,去编译和测试程序,是好好的
但是切换到iPhone 6(9.3)之后,就出错了:
Ld /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/QorosSales.app/QorosSales normal x86_64 cd /Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales export IPHONEOS_DEPLOYMENT_TARGET=8.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -L/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator -F/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator -F/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/DBGuestureLock -F/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/KKGestureLockView -F/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/SEFilterControl -F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Build/iOS -filelist /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Intermediates/QorosSales.build/Debug-iphonesimulator/QorosSales.build/Objects-normal/x86_64/QorosSales.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -framework DBGuestureLock -framework KKGestureLockView -framework SEFilterControl -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Intermediates/QorosSales.build/Debug-iphonesimulator/QorosSales.build/Objects-normal/x86_64/QorosSales.swiftmodule -framework Alamofire -framework SwiftKeychainWrapper -framework Charts -framework Realm -framework RealmSwift -framework Cartography -framework XCGLogger -framework Pods_QorosSales -Xlinker -dependency_info -Xlinker /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Intermediates/QorosSales.build/Debug-iphonesimulator/QorosSales.build/Objects-normal/x86_64/QorosSales_dependency_info.dat -o /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/QorosSales.app/QorosSales ld: warning: ignoring file /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts, file was built for i386 which is not the architecture being linked (x86_64): /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts Undefined symbols for architecture x86_64: "Charts.LineChartData.__allocating_init (xVals : [__ObjC.NSObject]?, dataSets : [Charts.IChartDataSet]?) -> Charts.LineChartData", referenced from: QorosSales.setDoubleLineChart (Charts.LineChartView, xPoints : [Swift.String], leftAxisValues : [Swift.Double], rightAxisValues : [Swift.Double], leftAxisLabel : Swift.String, rightAxisLabel : Swift.String, leftColor : __ObjC.UIColor, rightColor : __ObjC.UIColor) -> () in CrifanLib.o "Charts.ChartDataEntry.__allocating_init (value : Swift.Double, xIndex : Swift.Int) -> Charts.ChartDataEntry", referenced from: QorosSales.setSingleLineChart (Charts.LineChartView, xPointList : [Swift.String], leftYAXisValues : [Swift.Double], leftYAxisLabel : Swift.String, lineColor : __ObjC.UIColor) -> () in CrifanLib.o 。。。。。。。。。。 ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) |
但是是可以运行在iPhone 6(9.3)的真机上面的
搜:
Undefined symbols for architecture x86_64 Charts.LineChartData
xcode Undefined symbols for architecture x86_64 Charts.LineChartData
ios – Undefined symbols for architecture x86_64 on Xcode 6.1 – Stack Overflow
objective c – Xcode build failure "Undefined symbols for architecture x86_64" – Stack Overflow
其中,此处出问题的Charts库,记得是:
用Carthage去直接下载已编译好的二进制framework文件的
看到:
ld: warning: ignoring file /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts, file was built for i386 which is not the architecture being linked (x86_64 |
-》
猜测是:
Charts库自己编译的时候,是x86(i386)的环境
编译出来的库只有x86的
而我此处的iOS模拟器的iPhone6所在的Mac是x64(x86_64)的
所以没法用
-》好像去重新下载Charts源码并编译,估计就解决问题了?
-》但是为何此处的iOS模拟器的iPhone 5,可以正常运行呢???
Fix for "undefined symbols" when building in Xcode 6 – x-code – openFrameworks
ios – Undefined symbols for architecture x86_64 on Xcode 6.1 – Stack Overflow
此处,也去项目的targets中看到了architectures是x64的:
而没有包含x86==i386
所以,不要去乱改为i386
-》可能会导致其他库有问题了
-》保险起见,还是去下载Charts的源码并编译吧
carthage update –no-use-binaries Charts
licrifandeMacBook-Pro:QorosSales crifan$ carthage update –no-use-binaries Charts |
除了暂时用不到到tvOS的Charts库,其他都正常编译了
去看对应的iOS的Charts.framework,也是最新刚刚编译出来的:
再去重新编译项目试试
问题依旧。
换不同iOS模拟器试试:
iPhone 6 (9.3)
iPhone 6 (8.1)
iPhone 5s (9.3)
iPhone 5s (8.1)
iPhone 6 Plus (8.1)
iPhone 6s
都会出现同样错误
但是:
iPhone 5 (9.3)
iPhone 5 (8.1)
都没问题,都可以正常编译,链接库,运行
搜:
xcode iphone 6 simulator file was built for i386 which is not the architecture being linked (x86_64)
$(inherited)
$(PROJECT_DIR)/Carthage/Build/iOS
清空:
再去试试
结果不行,找不到库:
改回去.
结果找不到我另外的用cocoapods管理的库了
所以还是要加上:$(inherited)
结果问题依旧:
-》
感觉是:
即使是从Charts的源码去编译,但是由于Charts提供的scheme中制定了x86而不是x86_64
所以即使重新编译也没用。。。
但是最诡异的还是:
为何iPhone 5可以
之后的6 6s 6sp都不可以?
算了,还是把Charts的管理从Carthage换成Cocoadpods试试
Cartfile变成:
github "robb/Cartography" github "realm/realm-cocoa" github "DaveWoodCom/XCGLogger" ~> 3.3 github "Alamofire/Alamofire" ~> 3.4 github "jrendel/SwiftKeychainWrapper" |
Podfile变成:
# Uncomment this line to define a global platform for your project platform :ios, ‘8.0’ # Uncomment this line if you’re using Swift use_frameworks! target ‘QorosSales’ do pod ‘Charts’ pod "KKGestureLockView" pod ‘SEFilterControl’ end target ‘QorosSalesTests’ do end target ‘QorosSalesUITests’ do end |
去更新:
licrifandeMacBook-Pro:QorosSales crifan$ carthage update *** Fetching SwiftKeychainWrapper *** Fetching Alamofire *** Fetching XCGLogger *** Fetching realm-cocoa *** Fetching Cartography *** Checking out Alamofire at "3.4.0" *** Checking out SwiftKeychainWrapper at "1.0.11" *** Checking out XCGLogger at "Version_3.3" *** Downloading realm-cocoa.framework binary at "v0.103.0" *** Checking out Cartography at "0.6.0" *** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.jn8klX.log *** Building scheme "Alamofire watchOS" in Alamofire.xcworkspace *** Building scheme "Alamofire iOS" in Alamofire.xcworkspace *** Building scheme "Alamofire OSX" in Alamofire.xcworkspace *** Building scheme "Alamofire tvOS" in Alamofire.xcworkspace *** Building scheme "Cartography-iOS" in Cartography.xcodeproj *** Building scheme "Cartography-Mac" in Cartography.xcodeproj *** Building scheme "SwiftKeychainWrapper" in SwiftKeychainWrapper.xcodeproj *** Building scheme "XCGLogger (OS X)" in XCGLogger.xcodeproj *** Building scheme "XCGLogger (tvOS)" in XCGLogger.xcodeproj *** Building scheme "XCGLogger (watchOS)" in XCGLogger.xcodeproj *** Building scheme "XCGLogger (iOS)" in XCGLogger.xcodeproj /Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: 'anyGenerator' is deprecated: renamed to 'AnyGenerator' 。。。。。。 licrifandeMacBook-Pro:QorosSales crifan$ pod install Analyzing dependencies Downloading dependencies Installing Charts (2.2.4) Using KKGestureLockView (1.0.0) Using SEFilterControl (2.0.0) Generating Pods project Integrating client project Sending stats Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.
结果错误依旧。。
去删除掉,Carthage的Build/iOS中残留的Charts的库:Charts.framework
错误依旧。。。
把:
Build Active Architecture Only-》Debug的Yes改为No
结果导致额外的警告:
无意间看到:
ld: warning: ignoring file /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts, file was built for i386 which is not the architecture being linked (x86_64): /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts
中提到了:
Xcode/DerivedData
也无意间看到了Xcode的设置中,有个Xcode/DerivedData,所以去看看:
看到这里的Chart.framework是i386的:
而这里
是
x86_64
的
算了,去删除掉:
/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/
下面的:
Charts.framework
-》希望xcode可以自动找到另外的:
Charts/Charts.framework
之所以能够想到去删除那个:
Build/Products/Debug-iphonesimulator/
下面的
Charts.framework
是因为:
Podfile中的:
target ‘QorosSales’ do pod ‘Charts’ pod "KKGestureLockView" pod ‘SEFilterControl’ end |
包括Charts,以及其他几个库:
SEFilterControl
KKGestureLockView
对应的xxx.framework都是放在对应的库名字命名的文件夹下的
只有这个Charts.framework是直接放在Debug-iphonesimulator/下面的
所以觉得,这个Debug-iphonesimulator下面的Charts.framework
应该是之前残留下来的(i386版本的)库,
所以去尝试删除掉
然后果然可以正常编译了:
并正常运行了:
同理,其他iPhone 6之后的版本,也都可以运行了。
另外,注意到:
/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/
下面,还残留一个文件夹:
DBGuestureLock
这个也是:
之前用Cocoapods安装的
之后又不用了,虽然cocoapods删除了对应的库
但是Xcode的DerivedData:
/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/
中却还残留了对应的文件夹
不过幸好是空的,没啥内容。
另外,看到了:
/Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphoneos/Charts.framework
即,对于iOS的真机,比如我此处的iPhone6的话,用的则是此处的Debug-iphoneos/Charts.framework
是arm64的
-》
所以在iPhone 6真机上是可以正常运行的
licrifandeMacBook-Pro:QorosSales crifan$ pod install Analyzing dependencies Removing Charts Downloading dependencies Using KKGestureLockView (1.0.0) Using SEFilterControl (2.0.0) Generating Pods project Integrating client project Sending stats Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
ld: warning: ignoring file /Users/crifan/Library/Developer/Xcode/DerivedData/QorosSales-fdvmkfwiibblhkeaqjznadykdyuj/Build/Products/Debug-iphonesimulator/Charts.framework/Charts, file was built for i386 which is not the architecture being linked (x86_64) |
转载请注明:在路上 » [基本解决]使用iOS模拟器iPhone 6结果编译出错:file was built for i386 which is not the architecture being linked x86_64