Xcode 报错, 适用Xcode 9 10 11
1、Error 点击不显示

解决办法 在Help 中输入 report
选择 Navigations -> Show Report Navigator
会自动显示选择途径

可以直接使用快捷键
command + 9
来快速定位
2、Multiple commands
error: Multiple commands produce '/Users/xxx/App.app':
- Target 'App' has create directory command with output '/Users/xxx/App.app'
- That command depends on command in Target 'App': script phase “[CP] Copy Pods Resources”

在 Target -> Build Phase -> [CP] Copy Pods Resources -> Output Files
中删除 Output Files
即可

error: Multiple commands produce '/Users/xxx/Library/Developer/Xcode/xxx/Info.plist':
在 Target -> Build Phase
搜索 plist
把 Copy Bundle Resources (m of n items)
中删除收到的plist
文件

同理其他 LICENSE
README
文件的错误也这样删除处理。
当然如果包含多个TARGET
的话,需要每个TARGET
都找一下。
3、library not found xxx (libstdc++.6.dylib, libstdc++.6.0.9.dylib,libstdc.dylib)
Xcode 10
升级后 framework
做了很大的改变,从 Xcode 9
中拷贝需要的库到 Xcode 10
中。
简单的在 Xcode
中通过 Add Other
的方式加入下载的或者拷贝过来的系统库可能并不能起作用,无论怎么 clean
都依旧报错,这时候考虑可能没有拷贝到系统库应该存在的位置。Show in Finder
可以方便定位,拷贝时可能需要输入登录密码。

还可以直接终端上使用 open
命令直接打开,其中
Device 路径:(.tdb
)
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
Simulators路径:
tdb/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
Xcode 11 需要必须要设置 dylib 路径
dylib/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
当然也可以在 Application
中 右键->显示包内容
,然后一层层找下去,iOS.simruntime
同样也需要显示包内容才可以看到下一级目录。
直接在终端上操作
$open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
和
$open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
和
$open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
而且 Xcode 10
取消了 stdc++
库,所以同理,对于 libstdc++.6.0.9.tbd not found
也同样适用 。
找到stdc++
相关的几个库,(e.g. libstdc++.6.0.9.tbd, libstdc++.6.tbd, libstdc++.tbd
) 全都拷贝过去就可以了.
昨天升级了 Xcode 10.12, 然后编译时...
ld: library not found for -lprotobuf
clang: error: linker command failed with exit code 1 (use -v to see invocation)
有了上面的经验,对于这种问题直接查找:TARGETS -> Build Phases -> Link Binary With Libraries
点击 +
,输入 protobuf
查看是否有对应的静态库。果不其然,并没有发现,那一定是 Xcode 在升级 10.12 时做了调整,删除了这个静态库。 好在有同事还没有升级,直接从他们的 Xcode 中取出来添加到系统库中就可以顺利编译通过,为了防止这种事情再次发生,最好提前备份一份系统库,方便更新时及时补缺,而且小版本的升级也会造成系统库的更新,比如上次已经导入的 stdc++
库,更新 Xcode 后,又会自动消失,仍需要再次导入。
以防以后需要,备份 Libraries for Xcode9 传送门
4、Development cannot be enabled while your device is locked.

由于第一次连接Mac时(或手机系统升级后),在设备上点击了"不信任"选项,导致
Xcode
不能访问手机。Apple官网的解释:https://support.apple.com/en-us/HT202778

5. Invalid bitcode signature

Xcode 10
以前版本不对静态库的 bitcode
做检查,所以除了对项目的 bitcode
检查外,还要对自编译(第三方)的静态库检查一遍。
查看 Target -> Build Settings -> Enable Bitcode

6. 联机运行Okay,打包时却报错 Undefined symbols for architecture for xxx
, 查看 Build Active Architecture Only
的 Debug 和 Release 是否一致。

7. Not a PNG file...
While reading /Users/scorpioanke/Code/OC/CT_SDK/CTMediaBundle/黄金ETF/gold_new_user@2x.png pngcrush caught libpng error:
Not a PNG file..
Could not find file: /Users/scorpioanke/Library/Developer/Xcode/DerivedData/CTABC/Build/Products/Debug-iphonesimulator/MediaBundle.bundle/new_user@2x.png
Command /Applications/Xcode.app/Contents/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure
这是因为图片原本是 jpg
格式,强行把扩展名改成了 .png
造成的,修改方式也就是找到报错图片,先把图片改成 .jpg
格式,然后打开图片,选择文件 -> 导出

然后选择
png

保存好后把之前的图片文件替换掉即可。
8. dyld: Library not loaded:(image not found)
dyld: Library not loaded: @rpath/Starscream.framework/Starscream
Referenced from: /Users/xxx/Library/Developer/CoreSimulator/Devices/8807E75B-CEAA-48C1-B8F5-1D18AFF7E023/data/Containers/Bundle/Application/A6F27A9E-E49B-4A88-A245-E001AF51EF3B/CT_SDK_DEMO.app/CT_SDK_DEMO
Reason: image not found
Message from debugger: Terminated due to signal 6
TARGETS -> Build Phases -> Embed Frameworks
中添加报错的库
