Xcode 是 iOS开发人员的利器,偶尔也会变为“猪队友”,下面是本人在开发中积累的一些遇到的问题和解决方案。
- 代码提示不起作用:
This fix from apple dev forums works for me. I have had autocomplete issues with Xcode 6.1/Yosemite.- Quit Xcode.
- Restart the computer (this is to clear any in-memory caches).
- Delete the contents of the DerivedData folder (~/Library/Developer/Xcode/DerivedData), precisely run,
a) cd ~/Library/Developer/Xcode/DerivedData/
b) **rm -rf *** - (Try this if Steps 1-3 dont really work as it rebuilds the cache later on restart which takes time) Delete the contents of folder ~/Library/Caches/com.apple.dt.Xcode, i.e.,
a) cd ~/Library/Caches/com.apple.dt.Xcode
b) **rm -rf *** - Now launch Xcode once more…
- Logic Testing Unavailable:
Logic Testing on iOS devices is not supported. You can run logic tests on the Simulator.
http://stackoverflow.com/questions/8454935/logic-testing-on-ios-devices-is-not-supported
Log
ic test need a framework which has not installed with iOS device. Set a Host Application for Unit Test can resolve this issue: App will run first and Uint Test run. - $(inherited) in xcode:
- inherited值的是xcode设置项的继承关系。
- 每个项目都有PROJECT的设置与TARGETS设置,TARGETS一般情况下就是继承自PROJECT
- “Xcode 6.3: Can not verify build to install on device”
- $(inherited) can be used to inherit build settings from the project level to the target level. When you define library or header search paths at the project level you can use $(inherited) in the target build settings to use these search paths in the search paths of the project targets.
- Verify Xcode:
- spctl –assess –verbose /Applications/Xcode.app
- Xcode显示模拟器时,使用的是UUID,而不是系统型号
- http://stackoverflow.com/questions/26533025/xcode-using-guid-instead-of-ios-version-number-in-simulator-selection
- 在Xcode->Devices里,选中重复的模拟器,右键菜单“删除”,即可。
- iPhone Simulator没有网络
- http://stackoverflow.com/questions/13542706/iphone-simulator-cannot-connect-to-internet
- iOS Simulator (menu, top left) > Reset Content and Settings… fixed it for me. Note this will delete all the apps and associated data you have on the simulator.
- ineligible device
- 当前iOS版本比xcode版本高,就会出现这种情况,如iOS 9.1 就不能在Xcode 7上面进行调试,而只能在xcode 7.1进行调试。
- 更新xcode版本后,出现插件不兼容的问题
- fix-xcode-upgrade-plugin-invalid
- find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add
defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID
- 检查代码中的FIXME、TODO、ERROR
- http://krakendev.io/blog/generating-warnings-in-xcode
- Xcode 7.3(Swift 2.2) Release配置出现Crash:
- 在Debug和Staging配置环境下的build没有问题,但是Release编译出来的build会出现crash: unrecognised selector sent to instance
- 尝试方法
- 解决方法:
- 在Swift Compiler -> Code Generation选择,使用Fast [-O],而不能使用Fast, Whole Module Optimization
- 查看所有的Simulator:
- xcrun simctl list devices
- Xcode 注释功能不起作用:
- 重启 Xcode,重启 MAC
- 运行:sudo usr/libexec/xpccachectl
- 重命名 Xcode,然后打开,恢复后,重新改名为 Xcode
- 使用 Code Snippet
- Xcode开发技巧之code snippets(代码片段)
- <#type#>占位符
- Xcode中的代码片段默认放在下面的目录中:~/Library/Developer/Xcode/UserData/CodeSnippets