Xcode 11.3 could not attach to the pid: <Number> without internet - ios

Error Prompt
Xcode 11.3 not able to run the simulator when the lab being "offline" I need to connect to the internet to make the Xcode run the simulator. I found this is hard, please note I try to the following possible solutions but no one solve the problem.
Remove driven data
Erase all content and setting from the simulator
Enable AuthDevTools

There are several answers about this issue.
1st way
You should run this command in your terminal ->
sudo DevToolsSecurity -enable
2nd way
Uncheck this box ->
Edit Scheme > Run > Debug executable
Resource for this answer
Developer Apple Thread
Bonus
What is the DevToolsSecurity -enable command?
This is the command we can use for enable Developer Mode
When you run Xcode for the first time on a fresh system, it asks if you’d like to enable Developer Mode. Developer Mode allows Xcode to execute common debugging tasks without constantly asking for your password.
Brian Gilham's Medium Article

Related

Xcode 9: Could not attach to pid

I've been facing an issue (frequently) with the recent major release of the iOS application development tool - Xcode 9-beta.
It's showing me the following error frequently while running/debugging app in Simulator (iOS 11).
Could not attach to pid : “2370”
Ensure <project title> is not already running, and <system username> has permission to debug it.
Here is a snapshot for the same issue:
What would be permanent solution of this issue, as it's disturbing frequently?
If issue is on OS Mojave and you are trying, like me to run tests on older Xcode version (lower than 10.0), make sure that in your scheme, when you select Test, Debug executable is disabled
You won't be able to debug tests from this point
Still not a permanent solution, but I had to quit and restart Xcode as the other solutions did not work for me.
This worked for me:
Edit Scheme -> Info -> Executable -> Ask on launch
Credits to #nastya-gorban's answer here
Update
After spending a considerable time with examples on Apple bug report, they basically disregarded the issue as using manual certificates is not "expected".
Long story short, if you don't have a business account and hence multiple developers on the same account, you should be fine with using the automatic signing and should not see the issue.
If you do have a business account with multiple users (which I found it breaks automatic signing), this is their suggestion:
We suggest that you use automatic signing for your debug builds and
manual signing for your distribution builds.
Killing my simulator and then running it again from Xcode.
I had this issue too. There seems to be an issue with having two Xcode version installed at the same time. (9.4.1 and 10.0 Beta)
It works with the beta, but not with the stable version. Everything is set to the tools of the Xcode 9.4.1 stable version. I can only run my unit tests with the beta.
After removing the beta, it worked with the stable version.
delete derived data and clean the project, wait until processing is complete, this may take some time. The idea is to give some processing time. Works fine after that
I have been dealing with this issue for days. I have been able to build but not launch on Simulator, and I get the same "pid:.." error message.
I am using:
- Xcode v9.2
- Swift 3.2
- Building for iOS
The things that I tried that DID NOT WORK were:
restarting the computer; deleting content and settings (of Simulator, I do not have "reset"); uninstalling and reinstalling Xcode; changing "Deployment Target"; changing the device in the simulator's Hardware->Manage Device; deleting Derived Data, Cleaning and Building, or just waiting...forever.
What WORKED was as #Rajasekhar mentioned:
checked out the Keychain certificates.
deleted the exiting ones by right clicking (they'd passed expiration)
and unchecked "automatically manage signing" in Targets->General
After that it successfully launched in Simulator. I don't know if the issue will come back but hopefully this works.
Even on Xcode 11.1/2/3
It is an Authorization issue with Simulator,
When Simulator does not have the necessary access. It raises the issue.
Try following in Terminal
sudo DevToolsSecurity -enable
or
sudo /usr/sbin/DevToolsSecurity -enable
Details can be found here
I hate to add more noise to this, but for me, the answer is to, nonsensically, use sudo.
Run normally, Xcode 9.4.1 (9F2000) and Xcode 10.0 beta 4 (10L213o) both failed to attach to my app after multiple tries, giving the error quoted in the original post.
What worked was to run Xcode (9.4) with sudo,
sudo /Applications/Xcode.app/Contents/MacOS/Xcode
I don't see why sudo is necessary. The Cocoa app to which I am attaching is a Debug build that I just built in Xcode 9.4.1 and dragged into /Applications. It is not codesigned. Posix permissions on the .app, its Contents, its MacOS, and the executable are all octal 755. Owner is me. It works fine if I leave it in the Build folder, build and debug in the normal way.
The problem is apparently with lldb. I also tried using lldb (lldb-902.0.79.7) from the command line. I got the same result. It works only with sudo. Without sudo,
error: attach failed: unable to attach
I had same issue. Check screenshot.
Below are few solutions that should work:
Rerun project
Clean (Shortcut: cmd + shift + K) and Rerun project
Quit Xcode and Simulator. Open project and run again
Reset content of Simulator (Select Simulator -> Goto Hardware tab -> Erase All Content and Settings…) and rerun project.
Solution 4 worked for me.
This seems to be a temporary issue when you are trying to build too fast after a build has started. Try stopping and running the project again.
(most likely solution) 1. Simulator-> Hardware-> Erase all contents and Settings
(less likely solution) 2. keychain-> upper right lock-> unlock and lock again (or the other way around)
I was seeing this in Xcode 10.2 and the cause for me was that lldb-rpc-server was crashing. I worked around it by ensuring either Address Sanitizer or Thread Sanitizer is enabled in the debug options. I also filed a bug report viewable on Open Radar.
I tried all the answers above. The only thing worked to me is changing the build number.
In my case (Xcode 10.1), this was the error in the console:
kernel macOSTaskPolicy: (com.apple.debugserver) may not get the taskport of (bin) (pid: 10132): (bin) is hardened, (bin) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger
So the solution was to disable the Hardened Runtime, clean the build folder and run again.
This is the issue with the untrusted certificates in key-chain access, please remove such a type of certificates and re-build again.
This happens on my machine, when I set the 'new build system'
Go to menu file=>workspace settings and set Build System to "Standard".
I realise this is not a problem with a single solution, from all the other answers. So, here's what worked for me:
1) Reboot the machine
2) The first run always works for me. The only thing that helps me avoid this error after this first run, is to stop the application from XCode, instead of just clicking the Run button to re-run the application.
Another thing, when I lock my computer the issue re-appears sometimes (probably when I forget to stop the application). So I have to reboot my machine again.
After doing some digging, this worked for me on Xcode 10.3.
sudo /usr/sbin/DevToolsSecurity -enable
In my case the only thing that worked was switching back from the "New Build System" to the "Legacy Build System" in the Workspace Settings. Bummer.
It's an issue with authorization. Try this in the Terminal:
sudo DevToolsSecurity -enable
First, close app completely via sim (not sleep - close app totally)
If not working yet: reboot whole PC, ensure only 1 simulator is active upon reboot.
More than 1 sim can confuse it if it's bugging.

Xcode 7.1 : Simulator can't be opened because the identity of developer cannot be confirmed

I've upgraded my Mac OS X to 10.11.1 El Capitan. When I try to run app on Xcode 7.1 I'm getting an pop message stating "Simulator" can't be opened because the identity of the developer cannot be confirmed. Refer screenshot.
Why this message? I'm not able to test any app on Xcode 7.1.
Gatekeeper requires that every application downloaded from the internet is verified. Since you downloaded "Simulator" with Safari it has to be checked and added to a list of accepted applications. Here is a quick way to do that:
Run Terminal.app
Enter the following command sudo xattr -d com.apple.quarantine /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
I found the answer here.
Apple believes is security that's the reason only apps which you have downloaded from App Store can be opened.
Well, to open any app which you have downloaded and install from anywhere you need to allow permission. To do so:
Open 'System Preferences'
Go to 'Security & Privacy' and tap on 'General' tab
Click on 'Lock' icon which you can find on bottom left screen and type your administrator password.
The last step is to choose 'Anywhere' under 'Allow apps downloaded from:' and then again click on 'Lock' icon.
That's it. Now you can run any apps.
Enjoy!
Simulator.app is distributed by Apple and should be codesigned appropriately.
The dialog you are seeing indicates that the version you have did not pass Gatekeeper's codesignature checks.
Possible causes:
You made local modifications to Xcode.app or Simulator.app to invalidate Apple's code signature.
Disk corruption or maybe an error in transport caused some resources in Simulator.app to not be valid such that the signature is no longer valid.
You downloaded an unofficial copy of Xcode.app (or just Simulator.app) which has been modified by a 3rd party. Google "XcodeGhost" for information on why that's a bad idea.
The Simulator.app you are trying to open is not actually Xcode's.
A bug in Gatekeeper or OS X might be triggering a false result.
Please also update your question with the output of the following steps (assuming you've setup xcode-select appropriately) for additional support:
codesign -vvv -d $(xcode-select -p)/Applications/Simulator.app
codesign -vvv $(xcode-select -p)/Applications/Simulator.app
This happened to me when I ran a build script that launched the simulator directly, before actually opening Xcode.
When you open Xcode for the first time it will go through a verification process that takes a long time. After that completes, the contents of the bundle will be verified as well and you can use the simulator without the warning.
If you still have the warning after verification your version of Xcode might be compromised.
It is possibly a bug that gatekeeper doesn't warn you that the parent bundle has not been verified.
In my case I had multiple instances of Simulator.app present (some downloaded directly from Apple's site, rather than installed from the store). When I issued open -b com.apple.iphonesimulator one of the downloaded simulators got opened, instead of the current one in /Applications/Xcode.app. I changed my command to open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app and the issue is now resolved.

Corona SDK and lldb

Whether it possible to debug corona SDK application on iOS simulator?
I build a Corona SDK application for Xcode simulator and wrote next commands:
cd /Users/username/Library/Application\ Support/iPhone\ Simulator/7.0.3/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/app-name.app/
lldb
(lldb) attach --name "app-name" --waitfor
Then I run app in simulator and I get the next message from lldb:
error: attach failed: process did not stop (no such process or permission problem?)
Are you logged in to the Mac remotely (ssh or whatever)? You need to authorize debugging the first time you use the debugger. It's easy to verify if your machine is set up to allow debugging:
% /usr/sbin/DevToolsSecurity -status
Developer mode is currently enabled.
If it's not enabled, I think sudo /usr/sbin/DevToolsSecurity -enable may do the trick. If you're debugging locally, you should see a pop-up window asking you if you want to allow the debugging to happen. But when logged in remotely, you won't see that pop-up of course.

Can I sign the iOS app with an AdHoc profile wihtout using XCode?

Preferably using Linux, Windows is also OK.
Something like openssh and zip?
If you can remotely shell into the Mac (ssh), then you should be able to build and sign your project from the command line. It may require some setup beforehand, but xcodebuild and xcrun should get you where you need to go. (This is the same kind of thing folks do to get automated continuous integration builds set up.)
Doesn't get you out of using Xcode or a Mac, but maybe gets you out of having to be physically sitting in front of that Mac to get work done.
Further reading:
Xcode “Build and Archive” from command line
xcodebuild man page
xcrun man page
I would use TeamViewer ( payed version) or other remote desktop software to connect tom office mac mini. Otherwise you will break up the signing license too, beside it is hard to configure the keychain.
It will be very hard to figure out after you have signed a build why it doesn't install at client's PC, because no error messages there.

iOS (iPhone, iPad, iPodTouch) view real-time console log terminal

Is there a way to view the real-time console log to view NSLog and other debug messages in a real-time manner, such as adb logcat?
The solution documented by Apple in Technical Q&A QA1747 Debugging Deployed iOS Apps for Xcode 6 is:
Choose Window -> Devices from the Xcode menu.
Choose the device in the left column.
Click the up-triangle at the bottom left of the right hand panel to show the device console.
Two options:
libimobiledevice is installable via homebrew and works great. Its idevicesyslog tool works similarly to deviceconsole (below), and it supports wirelessly viewing your device's syslog (!)
I've written more about that on Tumblr tl;dr:
brew install libimobiledevice
idevice_id --list // list available device UDIDs
idevicesyslog -u <device udid>
with the device connected via USB or available on the local wireless network.
(Keeping for the historical record, from 2013:) deviceconsole from rpetrich is a much less wacked-out solution than ideviceconsole above. My fork of it builds and runs in Xcode 5 out of the box, and the Build action will install the binary to /usr/local/bin for ease of use.
As an additional helpful bit of info, I use it in the following style which makes it easy to find the device I want in my shell history and removes unnecessary > lines that deviceconsole prints out.
deviceconsole -d -u <device UDID> | uniq -u && echo "<device name>"
EDIT: Please use #cbowns solution - deviceconsole is compatible with iOS9 and much easier to use.
This is a open-source program that displays the iDevice's system log in Terminal (in a manner similar to tail -F). No jailbreak is required, and the output is fully grep'able so you can filter to see output from your program only. What's particularly good about this solution is you can view the log whether or not the app was launched in debug mode from XCode.
Here's how:
Grab the libimobiledevice binary for Mac OS X from my github account at
https://github.com/benvium/libimobiledevice-macosx/zipball/master
Follow the install instructions here:
https://github.com/benvium/libimobiledevice-macosx/blob/master/README.md
Connect your device, open up Terminal.app and type:
idevicesyslog
Up pops a real-time display of the device's system log.
With it being a console app, you can filter the log using unix commands, such as grep
For instance, see all log messages from a particular app:
idevicesyslog | grep myappname
Taken from my blog at http://pervasivecode.blogspot.co.uk/2012/06/view-log-output-of-any-app-on-iphone-or.html
Just open the Application Console.app on mac osX.
You can find it under Applications > Utilities > Console.
On the left side of the application all your connected devices are listed.
Try the freeware iOS Console. Just download, launch, connect your device -- et voila!
This might be what you're looking for: Xcode Organizer
device > terminal output is on iPhone configuration app
here: http://support.apple.com/kb/DL1465
You have three options:
Xcode Organizer
Jailbroken device with syslogd + openSSH
Use dup2 to redirect all STDERR and STDOUT to a file and then "tail -f" that file (this last one is more a simulator thing, since you are stuck with the same problem of tailing a file on the device).
So, to get the 2º one you just need to install syslogd and OpenSSH from Cydia, restart required after to get syslogd going; now just open a ssh session to your device (via terminal or putty on windows), and type "tail -f /var/log/syslog". And there you go, wireless real time system log.
If you would like to try the 3º just search for "dup2" online, it's a system call.
To view your iOS device's console in Safari on your Mac (Mac only apparently):
On your iOS device, go to Settings > Safari > Advanced and switch on Web Inspector
On your iOS device, load your web page in Safari
Connect your device directly to your Mac
On your Mac, if you've not already got Safari's Developer menu activated, go to Preferences > Advanced, and select "Show Develop menu in menu bar"
On your Mac, go to Develop > [your iOS device name] > [your web page]
Safari's Inspector will appear showing a console for your iOS device.
As an alternative, you can use an on-screen logging tool like ticker-log to view logs without having (convenient) access to the console.

Resources