ios xib 总结

Apple M1 arm64 - IBDesignable error: “incompatible architecture” (have ‘x86_64’, need ‘arm64’)

1
Failed to render and update auto layout status for ViewController (BYZ-38-t0r): dlopen(ICONButton.app, 0x0001): tried: '/ICONButton' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRootICONButton.app' (no such file), 'ICONButton.app' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

解决办法, 参考: Xcode 12 Apple M1 arm64 - Designable error: “wrong architecture”

This is how I solved it:

  1. Set the target architecture to arm64
  2. Set the target exclude architecture x86_64
  3. Clean build folder (Product -> Clean build folder)
  4. Restart XCode

Easy XIB and Storyboard Localization

参考: Easy XIB and Storyboard Localization

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
protocol Localizable {
var localized: String { get }
}
extension String: Localizable {
var localized: String {
return NSLocalizedString(self, comment: "")
}
}
protocol XIBLocalizable {
var xibLocKey: String? { get set }
}
extension UILabel: XIBLocalizable {
@IBInspectable var xibLocKey: String? {
get { return nil }
set(key) {
text = key?.localized
}
}
}
extension UIButton: XIBLocalizable {
@IBInspectable var xibLocKey: String? {
get { return nil }
set(key) {
setTitle(key?.localized, for: .normal)
}
}
}

ios xib 总结
https://yxibng.github.io/2024/03/18/ios/2024-03-18-ios-xib/
作者
yxibng
发布于
2024年3月18日
许可协议