show ANSI color in Xcode4 debug console - ios

Is there any way to do this?
I wan't to distinguish my Logs by different colors.

To enable ANSI colors in Xcode console install clone https://github.com/robbiehanson/XcodeColors and build. The build process will install the Xcode plugin in the proper directory.
To unsign Xcode clone https://github.com/steakknife/unsign, run make, put the unsign command in the path. Then run the following:
cd /Applications/Xcode.app/Contents/MacOS
sudo unsign Xcode
sudo mv Xcode Xcode.signed
sudo ln -sf Xcode.unsigned Xcode
Note that this is reversible. Just change the symbolic link. Now you need to update the plugin UUID to match the current Xcode version:
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
for f in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*; do defaults write "$f/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID; done
Now you can use ANSI colors in your Xcode console. It looks like this:

Related

iOS - CocoaPods requires your terminal to be using UTF-8 encoding - after latest flutter upgrade

I am getting this error after I upgraded flutter. Before upgrading everything was working normal on both iOS and android. Now my project is not building in iOS.
Below is my terminal info.
pod setup --verbose
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
pod install --verbose
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
[!] No `Podfile' found in the project directory.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:151:in `verify_podfile_exists!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:46:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'
locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Open Terminal
Type open ~/.zshrc (or open ~/.profile if you don't use zsh)
It seems that LANG="en_US.UTF-8" alone isn't enough, so you have to set:
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Save the file
Go back to Terminal and type source ~/.zshrc and type locale
You can now safely run pod update or pod install
After one day of struggle finally i found the full solution
Follow these steps to solve this issue
Unhide filles in Mac using Cmd + Shift + dot.
Go to Macintosh HD -> User -> (Your user ).
Search for .zshrc
Open it with any editor (I recommend VS code)
Under. #User configuration comment out export LANG=en_US.UTF-8.
Open your flutter project and manually delete Pods folder, Podfile, Podfile.lock. (back-up all podfiles)
Restart your Mac and run your flutter application
Run pod install
It will automatically create podfile and its new config in UTF - 8 encoding
Enjoy and chill i got your back !!!!!
Clean files with flutter clean
Type vim .zshrc in your terminal. This should open up your .zshrc profile. Type I to insert something. Then, simply paste in export LANG=en_US.UTF-8 and hit ESC to get out and then type :wq to save and quit.
Opened project folder, next open iOS folder in mac terminal and run pod install
It may give warning of using ios 9.0 so update it to 10.0, for that open Podfile in text edit and uncomment or change
# platform :ios, '9.0' to platform :ios, '10.0'
Run flutter build iOS in the main root project through the terminal.
Run main root file eg. flutter run
If you are facing a problem with Flutter. Try this solution
Delete the Podfile, Podfile.lock, Pods folder, Runner.xcworkspace
flutter clean
flutter build ios
finally i have solved this with below steps
export LANG=en_US.UTF-8
opened project in Xcode and cleaned
it.
opened iOS folder in mac terminal and ran pod install
it gave me warming of using ios 9.0 so i updated it to 10.0
ran flutter build ios
project build successfully
opened Runner.xcworkspace in xode
clicked on run - this time Xcode again installed pod automatically
and Solved.
To iterate on Shruti Tupkari's answer ~ To add in export LANG=en_US.UTF-8 to your terminal it needs to be added to a profile such as .zshrc , .bashrc , or .bash_profile .
To do this simply use vim
So try
vim .zshrc
This should open up your .zshrc profile. Type 'i' to insert something.
Then simply paste in export LANG=en_US.UTF-8 hit esc to get out and then type :wq to save and quit
Try and run your app again. If you get the error, repeat the same steps on the other profiles in your computer.
Here's some information on how to use vim
https://www.howtoforge.com/vim-basics
If adding export LANG=en_US.UTF-8 doesn't help, try export LC_ALL="en_US.UTF-8"
Credits:
https://github.com/CocoaPods/CocoaPods/issues/6333#issuecomment-551052399
The proper solution, without re-installing anything, can be found:
here: https://stackoverflow.com/a/69160445/3821002
and here: https://stackoverflow.com/a/69376499/3821002
The crux is to use export LC_ALL=en_US.UTF-8.
The links above explain how to do that.
In my case the following needed to be added to .bash_profile instead of the other suggested files.
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
vim ~/.profile
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
source ~/.profile
Changing the .zshrc file didn't work for me, so I ended up with executing the cmd with specific language UTF-8 definition:
$ LANG=en_US.UTF-8 <pod command>
Source: cocoaPods issue
if you use Android Studio, then open terminal in it with:
nano ~/.profile
add these values:
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
and it's very important: now you need to close Android Studio and open it again, then you will be able to make a project
Solving Cocoapods UTF-8 error: (Detailed explanation)
We need to change the locale of the terminal to UTF-8.
Step 1: Open the terminal, type locale, press enter, and check what locale it shows.
Step 2: If it's a bash terminal, change it to a zsh terminal,
Step 3: Then open finder, go to mac HD, users, folder with your username, and press command+shift+. to open hidden files
Step 4: Create or open a file named .zshrc
Step 5: Paste this there:
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Step 6: Save it by command + s
Step 7: Then open the terminal again and check by typing, locale and pressing enter (Then you can either keep it open or close the terminal)
Step 8: If it shows some other locale instead of UTF-8, then paste the below 3 lines and press enter:
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Step 9: Then open Android Studio, go to the terminal and paste the same above 3 lines, and press enter
Step 10: Then on your project file, go to the ios folder, right-click on it, and open in the terminal, then in the terminal, do paste the same above 3 lines and press enter
Step 11: Now you can install pods in this terminal by typing, pod install.
Now it will work, if you still get the same error, go to tools -> flutter -> flutter clean and restart android studio by clicking on File -> restart ide or a similar one.
Then on your project, right-click on the ios folder and open the terminal, type locale, and press enter, if it's not in UTF-8 now, then from step 9 again up to step 11, it will work now. You can run your app on iOS devices now.
My repo -> https://github.com/anantha-eswar/
To fix this, you might want to find either your ~/.bash_profile (for bash) or ~/.zshrc (for zsh) and add the export line that you put in your ~/.profile
export LANG=en_US.UTF-8
That was all I had to do.
After upgrading mac os big sur version I get this error when I try to build ios unity.
If you don't have the file .profile, you can create new file .profile in /Users/"user-name"/.profile
step 1: open terminal. create new file .profile
$ cd
$ touch .profile
step 2: edit .profile.add
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
in .profile
I had this problem only in android studio. When I switched to the terminal outside Android Studio it worked fine.
Just open your terminal
and enter the below command
export LC_ALL=en_US.UTF-8
In my case, this error only occurs when I use the android Studio terminal to run the flutter ios app.
so instead, I used Mac Terminal to run the flutter ios app, and it's working perfectly fine.
To run the flutter app from the terminal use the below command:
flutter run
I have figured out the latest solution that works fine in 2022
Open iOS folder in terminal
Run command pod install, and let the process complete.
pod install
This works fine, if not try restarting the device

"config.h" file not found in iOS project of React native

In X-Code project of react native, getting error
config.h file not found.
Here is version detail :
react-native-cli: 2.0.1
react-native: 0.51.0
How to solve it?
Close Xcode.
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
Open Xcode and try to run your app.
I had the same issue, using this steps solves for me:
Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:
In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run sh ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find
Run your iOS BUILD
Regards!
When project files get messed up for me. I typically follow these steps.
rm -rf node_modules
npm install
react-native upgrade (Only changing affected files, so IOS for you)
react-native link
npm start --reset-cache
(In another terminal)
react-native run-ios
These steps worked for me:
rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start
You need to change to the legacy build system in Xcode 10 and install third party scripts manually.
1:
File -> Project/Workspace settings
Build System: dropdown -> change to Legacy Build system
2: Follow this to manually install third party scripts for RN:
Clean RN cache
$ rm -rf ~/.rncache
Re-install the deps
$ cd your_project_path
$ rm -rf node_modules/ && npm install
Then install the third-party
$ cd node_modules/react-native/scripts
$ ./ios-install-third-party.sh
Run the commands below if glog installation failed.
$ cd ../third-party/glog-0.3.x
$ ./configure
It works for me, I hope it helps for you.
If above all answers don't work,
Please check that there is no space in any directory name of the full path and not only the project directory name.
While in terminal, it accepts throgh My Disk as My\ Disk but xcode do not recognize that.
If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.
configure: error: unsafe absolute working directory name Issue:
-Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.5/
Run the configure script:
./configure
got error: configure: error: unsafe absolute working directory name
try to created app in desktop and from there run ./configure command.
Please note with XCOXE 10, and Mojave MAC OS , I had same issue, ./configure was showing some permission issue, I had set permission "777" to project folder enclosing with inner folders
This is the linking issue in xcode. You just need to re-link the files.
Please follow the below steps:
Open you peoject's root directory then open node-module -> react-native -> React.
Open React.xcodeproj file in xcode.
You will see missing (showing red in color) files under the third-party folder
Just run the React.xcodeproj project.
After completion close this project & open you project file.
Delete Drive data & Clean the project & run.
If after running the project you are getting linking issue then please make sure you have added all the (ios) products () come under the Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries.
If everyone has tried solving the issue by this
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
But still not got the solution then,
Go to your Xcode and check if there any library is missing. Add that library and then perform this above step.
Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error.
Here I have written a detailed solution to the problem.
Solution: config.h file not found mutex.h During Archive.
The steps are the following:
Remove node_modules directory
Clear Cache
Install packages again with Yarn
Install third party
Configure Glog
Make & Make install glog
For all these above steps the I have shared commands in the above mentioned article, so not going to write again. I hope it will solve problem for guys who are still struggling.

Carthage requires git 2.3.0 or later

I am using charts library and trying to run the demo. Before running I have to install the dependencies using Carthage. I goto project folder location and type in terminal:
carthage update
I got the below error:-
Carthage requires git 2.3.0 or later.
How to install Carthage decencies and run the above said demo.
Select Command Line Tools to the latest version of Xcode.
Xcode -> Preferences -> Locations -> Command Line Tools
Open Preferences shortcut : Command + comma ⌘ + ,
It seems like you have used another Xcode version since last time. You should set command line tool again by running the following in terminal:
sudo xcode-select -s <path to Xcode>/Contents/Developer
for example:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Not sure if this will help, but I ran into the same issue and found out that xcodebuild is using a different Xcode that I installed.
so you can probably double check which Xcode you are using:
xcode-select --print-path
Here is the original post that helped me solving this issue:
Change Carthage Swift version
It seems you have to install new version of git.
brew install git
It could say "Target /usr/local/bin/git
already exists. You may want to remove it". I didn't want to remove it and decided only to overwrite:
brew link --overwrite git
It helped me with the same issue. I hope it will help to someone else.

Change Carthage Swift version

Is it possible to change Carthage Swift version used to build the frameworks?
I'm trying to migrate my project to swift 3 (on Xcode 8 beta), and the third party libraries are the only thing that stops my project from compiling.
While using specific branches for swift 3, Carthage throws errors about the new Swift syntax.
Any help will be appreciated!
Carthage uses the command line tool xcodebuild to build the frameworks. The version of Xcode used by the command line system is determined by the value selected by the tool xcode-select
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
It needs to point to the Developer SDK directory, so you can use --print-path to check where it's currently pointing.
xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
Then to change it just run sudo xcode-select --switch <path-to-beta-xcode>/Contents/Developer
There is a bug report on Carthage's GitHub about XCode 8 and broken compatibility. You may want to follow that issue's thread on their repo:
https://github.com/Carthage/Carthage/issues/1440
Another related reported issue in Carthage's repo is: https://github.com/Carthage/Carthage/issues/1445

How to obfuscate code using Polidea's iOS Class Guard?

Can any one tell me the steps to implement Polidea's iOS Class Guard in iOS project. I have gone through the following github link:
https://github.com/Polidea/ios-class-guard
I also gone through sample project. I only find a obfuscate_project file in it. How can I test after implementing this?
4.1.1.1. Installation
Execute this simple bash script in Terminal. When asked for the password, enter your account. It's needed because the utility is installed in /usr/local/bin.
$ brew install https://raw.githubusercontent.com/Polidea/homebrew/ios-class-guard/Library/Formula/ios-class-guard.rb
To install bleeding edge version:
$ brew install --HEAD https://raw.githubusercontent.com/Polidea/homebrew/ios-class-guard/Library/Formula/ios-class-guard.rb
4.1.1.2. How to use it?
A few steps are required to integrate iOS Class Guard in a project.
Download obfuscate_project into your project root path.
$ chmod +x obfuscate_project
Update the project file, scheme and configuration name in shell script obfuscate_project.sh .
Do
$ ./obfuscate_project
every time when you want to obfuscate your project. It should be done every release. Store the json file containing symbol mapping so you can get the original symbol names in case of a crash. **Rename stored json file with release version number. **
Build, test and archive your project using Xcode or other tools.
The presented way is the simplest one. You can also add an additional target that will automatically regenerate the symbols map during compilation.
ios-class-guard will be called by shell script obfuscate_project.
============Unfortunately =============
In XCode 7.0 enviorment, we can't finish obfuscating without errors.

Resources