How to gain root access to Xcode to Disable Code Signing - xcode

I am trying to push an app to a jailbroken iPhone for development testing. I want to follow the steps in the second answer in this post, which involves editing Xcode's SDKSettings plist:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist
When I try to edit this file, I get an error that I'm not the owner and cannot unlock it. How do I get root privileges for this file?

Run the following command in Terminal:
sudo chmod 777 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/SDKSettings.plist

Related

Why "Watchman crawl failed" error in react-native immediately after updating to macOS catalina?

Trying to run react-native run-ios or build RN project from xcode, as soon as metro bundler starts, this error appears in the terminal:
Loading dependency graph...jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
Error: Watchman error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:183
throw er; // Unhandled 'error' event
^
Error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted
at BunserBuf.<anonymous> (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/fb-watchman/index.js:95:23)
at emitOne (events.js:116:13)
at BunserBuf.emit (events.js:211:7)
at BunserBuf.process (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:292:10)
at /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:247:12
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
This never happened before the Catalina update. I've had an empty watchman config file in the root of my project since the beginning. On first boot post-update, there was a popup in terminal saying something about permissions but i dont remember exactly. there's also a notice in my terminal in visual studio code saying "the default shell changed to zsh" run chsh -s /bin/zsh to change, so i did.
I've tried:
watchman watch-del-all
watchman server-shutdown
adding full disk access to terminal from within system preferences->privacy tab
npm uninstall watchman & npm uninstall -g watchman
You need to grant disk access to watchman. To do this You need to:
Go to System preferences > Security & Privacy then scroll down
Select Full Disk Access
Unlock it and click + button to add new app/tool
Select Macintosh HD in the folders list
Press this combination shift Command . at the same time to see all the directories list
Click opt > brew > bin (watchman is installed in this folder for MacOS Catalina) || usr > local > Cellar > Watchman > 21***** > bin (watchman is installed in this folder MacOS Monterey)
Look for watchman in the list then select it
Here we go, this should fix the issue.
I had the same issue after updating to Catalina. Wez Furlong's answer worked for me, but I had to provide full disk access to watchman in order to run watchman watch-project command without getting "Operation not permitted" error. As part of prior troubleshooting, I also had provided full disk access to Xcode and Terminal (not sure if this also contributed to the fix).
First run watchman watch-del-all
then run watchman shutdown-server fixed my issue
To change the permissions for Watchman regarding the Documents folder, it's under Security & Privacy -> files & folders in the system preferences
My issue was resolved by checking Watchman in the list under Document folder
The error message indicates a permission problem on /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA.
However, it may be something funky with launchd, so I would suggest:
$ watchman shutdown-server
$ launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
$ rm ~/Library/LaunchAgents/com.github.facebook.watchman.plist
$ watchman watch-project /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA
and see if that works or shows more context.
Cross linking back to an issue in our GitHub tracker:
https://github.com/facebook/watchman/issues/751
You need to change something its works for me. follow only following steps:
1. Go to System preferences > Security & Privacy then scroll down.
2. Select Full Disk Access.
3. Look for all watchmen on the list.
4. check(Mark) all Folders in all watchman files.
5. then go to vs code.
6. rebuilt your code.
I hope it will work smoothly
Try to change the directory of your project. I had mine on desktop and was getting that error, moved to the home folder and the error is gone
Just uncheck the repeated boxes in Mac:
System Preferences -> Security and privacy -> Privacy
For me above scenario didn't work, so I tried with different solution which solved the problem for me. (I am using MacBook Pro, chip: Apple M1 pro)
At first you have to update the setting of your Mac OS
System Preference >> security & privacy >> privacy tab >> Full disk access >> click on the lock icon >> checkmark for terminal
Sometime using this steps you are able to resolve the issue, but after this, if you are still facing issue, please use this link: #1030 (comment)
on macos. brew uninstall watchman
it works for me
npx react-native start --port=8088 resolved mine
There is only one solution at the moment. Move your project from the "Desktop" or "Documents" folder to the main folder (~/). None of the other ways worked for me.
This is because MacOS now asks for permissions for these folders (example in the image below). I guess this hasn't been added to the watchman yet.
As a temporary workaround, you can move your project to your home folder and it should run successfully.
To open your home folder, press Command-Shift-H.
(As of June 2022, there seems to be an issue with the 2022.05.30.00 version of Watchman, and this temporary solution is the only way I have been able to get around the issue.)

Change file permission of com.apple.screensharing.plist file on mac

I'm trying to change the file permission of a file.
I have tried chmod 777 on the file and nothing seems to work.
I even tried manually navigating to it and unocking and changing the permissions via the answers here (chmod unable to change permissions), I am at a loss for how to change the file permission so I can edit this file to allow screen sharing on a different port...
For anyone else that has a mac I'm trying to follow the instructions here, https://superuser.com/questions/148095/how-to-change-the-default-screen-sharing-vnc-port-number-on-mac-os-x
sudo vim /System/Library/LaunchDaemons/com.apple.screensharing.plist
This is the path to the file, but I can't edit it no matter what I do. Even as super user!
I found the answer to this, there is a protection on the system file csrutil, you need to disable this by booting up into recovery mode and open the terminal program and run the command csrutil disable.
Make sure to reenable after making the change in recovery mode again!

Lost permission for sudo in OSX El Capitan

I'm new to using OSX (using El Capitan 10.11.3) and while trying to change permissions on a file using sudo, I accidentally corrupted it. Now whenever, I try to use sudo to install anything globally, I'm getting the following error message.
sudo: unable to stat /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
Is there any way to solve it?
I'm also unable to even view the /etc folder
bash: cd: /etc: Permission denied
When I checked permissions on /etc folder, they are as follows
lrwxr-xr-x# 1 root wheel etc -> private/etc
I had the same issue and in my case the permissions of the root folder got corrupted. What people overlook is that / is in fact also a real, normal directory and just like every directory it has ownership and permissions. Ownership should be root:wheel and permission should be 755 (that's rwxr-xr-x).
The easiest way to restore both was starting Script Editor and then typing and running that script:
do shell script "/usr/sbin/chown root:wheel /" with administrator privileges
do shell script "/bin/chmod 755 /" with administrator privileges
You are prompted for amdin password and then chown and chmod come to the rescue. After that sudo was working again.
Disable System Integrity Protection (rootless)
Reboot the Mac and hold down Command + R keys simultaneously after you hear the startup chime, this will boot OS X into Recovery Mode
When the “OS X Utilities” screen appears, pull down the ‘Utilities’ menu at the top of the screen instead, and choose “Terminal”
Type the following command into the terminal then hit return:
csrutil disable; reboot
You’ll see a message saying that System Integrity Protection has been disabled and the Mac needs to restart for changes to take effect, and the Mac will then reboot itself automatically, just let it boot up as normal

Running ios-sim with Jenkins

I'm trying to start my app from the command line using ios-sim but this is what I get:
Started by user User
Building in workspace /Users/Shared/Jenkins/Home/jobs/UI Testing/workspace
[workspace] $ /bin/sh -xe /var/folders/h4/ws64t3bx2nnds4pg3345xrr000009c/T/hudson6341279754557259451.sh
+ /Users/myUser/Desktop/ios-sim launch /Users/Shared/Jenkins/Home/jobs/Project_Monkey_Build/workspace/build/Debug-iphonesimulator/ProjectMonkey.app
[DEBUG] Could not start simulator session: Error Domain=DTiPhoneSimulatorErrorDomain Code=5
"Operation failed with underlying error 4294956486." UserInfo=0x1001b1760
{NSLocalizedDescription=Operation failed with underlying error 4294956486.,
NSUnderlyingError=0x1001a3390 "The operation couldn’t be completed. (OSStatus error -10810.)"}
It looks like a permission problem as I can run the same command from terminal and it works fine. I've also tried to give full 777 permission to ios-sim and the MonkeyTalk directory,but still nothing.
Any idea?
It might be related to the Jenkins process not having a "display". Try running Jenkins as a user logged in to the desktop, then run the ios-sim again.
Unload Jenkins from launchd:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Then run Jenkins from a terminal:
sudo su jenkins -c "JENKINS_HOME=/Users/Shared/Jenkins/Home /Library/Application\ Support/Jenkins/jenkins-runner.sh"
If this works, you can make Jenkins always run as a logged in user by moving the launchd job config file from /Library/LaunchDaemons/org.jenkins-ci.plist to ~/Library/LaunchAgents/org.jenkins-ci.plist
I know this post was from a while ago, and not sure if anyone is checking it, but I also ran into this issue recently and it turned out that there was a duplicate app already in the iphone simulator creating an issue and not letting the new app run.
I reset the simulator and it then worked. I then added the applescript to reset the simulator each time before running ios-sim. this script can be found here...
How can I reset the iOS Simulator from the command line?
Scroll down the answer that has 13 up votes next to it, not the one that was checked marked.
Hope this helps someone in the future..
It looks like the only workaround it's to run the command as super user:
sudo /Users/myUser/Desktop/ios-sim launch /Users/Shared/Jenkins/Home/jobs/Project_Monkey_Build/workspace/build/Debug-iphonesimulator/ProjectMonkey.app
I was also facing the same problem and found that jenkins user is not correctly set up to run test case on simulator. Follow instruction given on below website:
http://pivotallabs.com/ios-ci-jenkins/
see the section "SETTING UP THE JENKINS USER".
hope it will work for you as well.

Running a cocoa app which requires keychain access from root terminal

I am trying to run a cocoa app KeychainTesterApp while I am logged in as root (sudo su).
Here are the steps:
Open terminal -> type sudo su -> Enter password.
Now, I want to open the app , so I do this: sudo -u username open KeychainTesterApp.app. The app starts up, except when I try to do anything related to the keychain I get the error Keychain not found - "A keychain cannot be found to store."
Any thoughts?
Thanks in advance.
The issue you're having above might be that running:
sudo -u username open KeychainTesterApp.app
Will not open the app as root. To open a Cocoa app as root, run the actual executable as sudo:
sudo "SimpleKeychainExample.app/Contents/MacOS/SimpleKeychainExample"
I'm not sure why the app cannot find the keychain you're looking for. Posting a code example from where that app is opening the Keychain might help clarify the question.

Resources