今天使用xcode单步调试代码时,发现一直进入的是汇编语言界面,显示的都是地址界面,无法定位到代码行,懵逼了,后来发现有个设置打开了,估计哪天误点了,具体位置在:
Debug -> Debug WorkFlow -> Always Show Disassembly (这项不要打勾 / uncheck)
DONE!
今天使用xcode单步调试代码时,发现一直进入的是汇编语言界面,显示的都是地址界面,无法定位到代码行,懵逼了,后来发现有个设置打开了,估计哪天误点了,具体位置在:
Debug -> Debug WorkFlow -> Always Show Disassembly (这项不要打勾 / uncheck)
DONE!
2012 macpro 升级 macos 到 10.15.2 catalina 并 安装 新xcode时碰到下列问题,供其他碰到的同学参考。
Go to settings then date&time. Click and then unclick “set date and time automatically”. Save the changes by clicking the lock.
Then restart the computer and proceed to download the update once again through settings and software update. It resolved the issue of the update not being verified.
解决方法:
苹果公司就这么把版本放出来也是醉了!
iOS9.0的权限设置
iOS9.0引入了新特性App Transport Security (ATS),导致网络请求访问失败,新特性要求App内访问的网络必须使用HTTPS协议,但很多公司使用的还是http协议。
为了让http请求也能正常范文网络数据,解决的办法如下:
在info.plist文件中添加App Transport Security Settings,类型Dictionary;
在App Transport Security Settings下添加Allow Arbitrary Loads类型Boolean,值设为YES;
iOS10.0对用户的隐私权限越来越重视,要想正常访问相册,相机,位置,麦克风,蓝牙,健康等都需要事先在info.plist文件中进行相应设置,现将开发中常用的用户权限设置总结如下:
蓝牙
NSBluetoothPeripheralUsageDescription
日历
NSCalendarsUsageDescription
相机
NSCameraUsageDescription
健康分享
NSHealthShareUsageDescription
健康更新
NSHealthUpdateUsageDescription
始终允许访问位置
NSLocationAlwaysUsageDescription
位置
NSLocationUsageDescription
在使用期间访问位置
NSLocationWhenInUseUsageDescription
麦克风
NSMicrophoneUsageDescription
运动与健康
NSMotionUsageDescription
相册
NSPhotoLibraryUsageDescription
提醒事项
NSRemindersUsageDescription
方式一:使用属性列表方式修改:
方式二:源文件方式
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSContactsUsageDescription</key>
<string>请求访问通讯录</string>
<key>NSMicrophoneUsageDescription</key>
<string>请求访问麦克风</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>请求访问相册</string>
<key>NSCameraUsageDescription</key>
<string>请求访问相机</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>始终访问地理位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>在使用期间访问地理位置</string>
<key>NSCalendarsUsageDescription</key>
<string>请求访问日历</string>
<key>NSRemindersUsageDescription</key>
<string>请求访问注意事项</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>请求访问蓝牙</string>
XCODE中获取添加的文件的路径的3个方法,以下以显示图片测试获取图片路径的方法:
测试的UIViewController的demo源码(TestImageViewController.swift),注释中详细描述3个不同添加文件方式下获取路径的方法,GOOD LUCK!
import AVFoundation
class TestImageViewController: UIViewController {
lazy var imageView: UIImageView = {
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
//方法1: 选择Targets中项目 –> build Phases中 –> copy Bundle Resources点击下面的+ 直接添加的alalay.jpg
//let testImage = UIImage(contentsOfFile: Bundle.main.path(forResource: “alalay”, ofType: “jpg”)!)
//方法2: 新建目录任意命名如imgs,将测试图片alalay.jpg文件拖入imgs目录后,将imgs目录名称修改为imgs.bundle,将这个imgs.bundle拖入xcode项目
//let testImage = UIImage(contentsOfFile: Bundle.main.path(forResource: “imgs”, ofType: “bundle”)! + “/” + “alalay.jpg”)
//方法3: 将alalay.jpg图片放在Assets.xcassets中
let testImage = UIImage(named:“alalay.jpg”)!
imageView.image = testImage
imageView.contentMode = .scaleAspectFit
return imageView
}()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(imageView)
}
}
原来mac 10 版本时安装过Network Link Conditioner,后来升级到macOS Mojave后,系统偏好设置里就没有了。 后来安装了xcode 11,需要用到Network Link Conditioner,就又下载Additional_Tools_for_Xcode_11.dmg,然后打开,进入Hardware目录里, 点击Network Link Conditioner.prefPane时提示:“Network Link Conditioner”偏好设置是随 macOS 安装,不能被替换。”
解决办法如下:
1. 第一种使用原来的。
按住 Command + Space 打开 spotlight 全局搜索
搜索 Network Link Conditioner
在结果列表里双击打开
(自动添加到设置面板并打开)
2. 第二种替换使用新的版本
将Network Link Conditioner.prefPane文件复制到/Library/PreferencePanes目录, 再进入“系统偏好设置”,就能在底部找到Network Link Conditioner工具了
我在xcode 11下使用 pod install 安装包时,总有提示如下: “target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/xxxxx.xcconfig’. This can lead to problems with the CocoaPods installation”
可以使用下面的方式解决:
DONE!!
使用xcode时 在终端使用 genstrings命令时, 却提示: xcode-select: error: tool ‘genstrings’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance, 可以使用下面的方法解决:
1. 打开xcode, 进入Xcode -> preferences 菜单,或者直接快捷键command + , 进入菜单。
2. 在Locations这个tab下,找到 “Command Line Tools” ,在这个组合框里选择对应的xcode版本即可,我机器选择的是:Xcode 10.2.1(10E1001)
DONE!
新建xcode文件时,类名和文件名都起错了,文件里的类名可以修改(refactor->rename),但修改文件名时报错: rename failed,
可通过下面方式解决(此法似乎对类名修改报错也有效):
1.关闭 xCode
2.进入 ~/Library/Developer/Xcode/DerivedData 目录并删除包含 “ModuleCache”名的目录.
3.重新打开xcode
4.再尝试该名下。
Good Luck!