My Error Code List
When work in a project get Errors and how I solve the errors in xcode, Pod, terminal, github, swift code and crash app will be here.
1. "Pod install" Error
Check this Error screenshot
Solution:
Pod install --repo-update
2. Crash (UILayoutPriority) when in iOS 12, in 13++ it's normal running
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Mutating a priority from required to not on an installed constraint (or vice-versa) is not supported. You passed priority 500 and the existing priority was 1000.'
terminating with uncaught exception of type NSException
CoreSimulator 776.4 - Device: iPhone 8 (xxxxxx-589A-xxxx-8E6B-xxxxx) - Runtime: iOS 12.4 (16G73) - DeviceType: iPhone 8
try to Debug
Debug
(lldb) po descFirstHeight.priority
▿ UILayoutPriority
- rawValue : 1000.0
(lldb) po descSecondHeight.priority
▿ UILayoutPriority
- rawValue : 500.0
(lldb) po UILayoutPriority.defaultLow
▿ UILayoutPriority
- rawValue : 250.0
(lldb) po UILayoutPriority.defaultHigh
▿ UILayoutPriority
- rawValue : 750.0
(lldb)
Solution
- In XIB dont set (priority = 1000) but you must set (prority = 999)
descFirstHeight = 999
descSecondHeight = 250
- And in file swift
descFirstHeight.priority = UILayoutPriority.defaultLow // 250
descSecondHeight.priority = UILayoutPriority.defaultHigh // 750
Source: https://stackoverflow.com/a/37474902/8366535
3. In Stackview cannot change color UIView (IOS 12)
Condition when subview in stackview
example look like this
//// ----------- ///
SOLUTION
So this my solution can fix that problem use dispatchqueue async
//// ----------- ///
4. Error build after (pod install)
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
How to Solve
- clean build/ delete DrivedData
- pod install / pod update (again)
If still an error
- checkout to branch development/master and build app.
- If in branch master not failed back into your branch and build your app again
5. UserDefaults JSON
this example use pod swiftyJson
// set
if let model = JSON["data"].rawString(.utf8, options: .fragmentsAllowed) {
UserDefaults.standard.setValue(model, forKey: "UserDefaultKey")
}
//call
guard let status = UserDefaults.standard.string(forKey: "UserDefaultKey"), let data = statusOA.data(using: .utf8) else {
return nil }
6. Nil when passing data Model
When I passing optional data model like this
example:
In Model
In View Controller
Solution is create a new request model with parameter
7. Error Need Install `cocoapods-keys`
Not running with Xcode Cloud, setup podfile with cocoapod-keys plugin
[!] Your Podfile requires that the plugin `cocoapods-keys` be installed. Please install it and try installation again.
The problem is my git change from `https` to `ssh` setting so my old version ruby is `2.6.1` update to `3.1.2`
Solution
- delete old `cocoapod-keys-App ` in Keychain access
$arch
$ruby -v
$brew
$brew install rbenv ruby-build
$rbenv install 3.1.2
$rbenv global 3.1.2
$open ~/.zshrc
$ruby -v
$gem install cocoapods-keys
$gem install cocoapods
$gem install fastlane
$cd app
$pod install
8. When Cannot Run "xed ." in terminal
This Error
app: $xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Solution:
xcode-select --install sudo xcode-select -s /Applications/Xcode.app/Contents/Developersudo xcodebuild -license accept