1、
error build: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0.
Build Setting中把Swift Language Version下改为Swift 4或者5即可
2、
[WindowScene] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
原因分析:在StoryBoard中没有一个view controller设置了Initial View。
解决方案:在Storyboard中,选择一个view conroller作为story board的第一启动界面
3、
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to register a cell class 'UICollectionView' which is not a subclass of UICollectionViewCell'
没有正确注册UICollectionViewCell
错误:collectionView.register(UICollectionView.self, forCellWithReuseIdentifier: "cell")
正确:collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")
4、improt SwiftyJSON
使用 SwiftyJSON 时,Xcode报错:No such module 'SwiftyJSON'
解决方法:如果还没有引入SwiftyJSON,通过CocoaPods引入SwiftyJSON
步骤1:打开终端,cd+你的项目目录
pod init
此时会在项目目录下产生一个Podfile文件,用xcode打开,放开相关注释,加入pod 'SwiftyJSON'
platform :ios, '10.0'
target '<Your Target Name>' do
use_frameworks!
pod 'SwiftyJSON'
end
在终端输入pod install
安装出错:
[!] Error installing SwiftyJSON
[!] /usr/bin/git clone https://github.com/SwiftyJSON/SwiftyJSON.git /var/folders/sd/ctycs6613hq_x52s33nz90fh0000gn/T/d20221229-3442-io2e9c --template= --single-branch --depth 1 --branch 5.0.1
Cloning into '/var/folders/sd/ctycs6613hq_x52s33nz90fh0000gn/T/d20221229-3442-io2e9c'...
fatal: unable to access 'https://github.com/SwiftyJSON/SwiftyJSON.git/': LibreSSL SSL_read: error:02FFF03C:system library:func(4095):Operation timed out, errno 60
啊噢!我们忘了添加SwiftyJSON的clone地址,重新编辑Podfile文件
尝试:pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
再次运行pod install
安装成功,关闭xcode,重新打开项目工作空间,improt SwiftyJSON 便可以正常使用SwiftyJSON了
5、假设字典转模型不成功,可以尝试在class BookDataModel: NSObject之前加上@objcMembers修饰,再重新运行程序试试
@objcMembers class BookDataModel: NSObject {code}
6、第一次尝试网络请求不成功,可能还缺少一些配置
7、拖拽出来的button控件无法修改它的字体颜色等属性,Type默认为Plain,修改为Default即可
8、有个特别小白的问题,但也许就是会有人遇到又一脸懵,我决定还是说一下,不能看不起小白是不是?小白也是很努力的!
就是xib里的视图控件突然变小了,不懂怎么调整大小,有两个解决方法