iOS Simulator "cannot be loaded in a restricted process" - ios

Just running my iOS project in the iOS Simulator and then get this error:
"dyld_sim: cannot be loaded in a restricted process"

Kevin Packard's comment gave me an insight on how to work around this issue. So basically there are several options:
As Kevin said, you can simply switch to Release configuration which will turn off Thread Sanitizer.
And yeah, the second option is to turn off Thread Sanitizer directly.

For me, the problem came because I changed folder names and had to delete and re-add files in the process. In doing so, I deleted AppDelegate.swift and SceneDelegate.swift and forgot to add them back. After copying those files from another project and adding them into the one I was working on, everything was fixed.

Related

Xcode won't pause at this breakpoint because it has not been resolved

Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change their look and turn to dotted blue outlined. Xcode does not stop execution at these breakpoints although code has been compiled, loaded and executed. I checked it in Console by adding some prints.
When I hover over breakpoint Xcode shows a message:
Xcode won't pause at this breakpoint because it has not been resolved
Resolving it requires that:
The line at the breakpoint is compiled.
The compiler generates debug information that is not stripped out (check the Build Settings).
The library for the breakpoint is loaded.
All trivial solutions like reloading, reapplying breakpoints have not helped.
Did anybody else see something like this? Is there a way to solve it?
Screenshot for reference:
Ok, so in my particular case rebooting laptop has helped. All breakpoints are now good. But it would still be nice to know the cause of the problem.
Make sure that the file in which you are adding breakpoint is having correct target set in target membership.
Click on .m file in which you want to add breakpoint.
Select the file inspector.
Check if you have selected correct target for that file or not (check below image).
What worked for me, was to select the files, delete them with - Delete>Move To Trash - and then drag the files back from the trash to the project.
In my case the issue was happening, because class was not added to the target, which I was trying to build.
For my case somehow the code path was never invoked and very likely considered as dead code. The same thing applies when not adding the file to the target that you want to debug.
This can be the case or somehow debugger might not be able to resolve your breakpoint. The first thing in this case should be cleaning derived data and any caches.
But instead of recloning your repo you can just delete breakpoint config from the location described in this answer
In Xcode 14 the problem is much more prevalent and "consistent". I figured out one pattern where it always fails and how to mitigate it.
If you have a final class then breakpoints set on or inside a private method will have that issue. If you remove private from the method or final from the class the breakpoints will get resolved properly.
If tried everything and nothing worked I suggest the following:
Reclone your repo
This is what worked for me.
I just passed through this problem and the solution for me was recreating the files.
Note: The ones I was trying to originally breakpoint on were copied from another project. When I created the new files, even though their Identity and Type looked just the same (target membership, encoding, paths), for some reason breakpoints started to work again.
Note 2: When copying and pasting code to your new files (if done manually), migrated breakpoints - created in the older file - will continue to fail. Only the ones created in this new file will work properly.
Hope it helps.
My case
Working on framework development. Framework is injected into the sample app for development/run purpose. Breakpoints inside the framework won't work.
Fix
Just removing xcframework in sample app and replacing with framework.
Reason
xcframework are precompiled outside of the app, so lib isn't compiled when project is built and that's why breakpoints doesn't work.
For me reboot the Xcode, and it works~

Xcode 11 Beta 5 stuck indexing [duplicate]

A project I've been working for 2 months stopped working for no reason because Xcode got stucked on "Indexing". I can't Build the project anymore. If I try to build, Xcode freezes and I have to force quit. This happens only with this project.
I tried cleaning all derived data but didn't help.
I'm using Xcode 4.5.2.
Any ideas?
Open your Project Folder.
Find ProjectName.xcodeproj file.
Right-Click Copy and Paste to Safe Place.
Right-Click Show Package Contents.
Find project.xcworkspace file and delete that file.
Reopen Your Project and clean and Rebuild.
If your problem is not solved then replace the file with your backup file.
Close that project from Xcode
Open Xcode Organizer, find the problematic project
Delete Derived Data folder in the Organizer
Close/re-open Xcode
Nuking Derived Data is the first thing to try in all cases of Xcode misbehaving
I had this exact problem, it was caused by a 20 item array literal. Had to switch to different syntax. Pretty silly.
Close any opened Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
Another thing to try if your trying to solve indexing issues and you're this far down the page!
Try adding this flag to your build settings.
-Xfrontend -warn-long-expression-type-checking=400
It will cause warning where the compiler take a long time to deduce a complex expression.
This may cause a build error which will go away after you find the slow expressions and then remove the build flag.
I had a similar problem, and found that I accidentally defined a class as its own subclass. I got no warning or error for this but the compiling got stuck.
class mainClass : mainClass
{
...
}
When using Xcode 6 and it says
Waiting for make
It might be that an instance of make is already running. Kill the process and indexing proceeds. Silly, but worked for me.
This happened to me. If you are using cocoapods do this:
Delete project.xcworkspace
Reinstall pods using pod install on the terminal
It will create a new project.xcworkspace
Open the new project.xcworkspace
-> Clean
-> Build
First, disconnect from network. Both your wired network and wireless network should turn off.
Second, kill the com.apple.dt.SourceKitService process. Then XCode would start to index again instead of stuck.
Hold alt > Product > Clean Build Folder
It's a Xcode bug (Xcode 8.2.1) and I've reported that to Apple, it will happen when you have a large dictionary literal or a nested dictionary literal. You have to break your dictionary to smaller parts and add them with append method until Apple fixes the bug.
For me completely closing out of Xcode and then restarting the project worked.
This is not the solution for the original question, I don't believe, but it is one more simple thing to try before deleting files and folders, etc. Credit to this answer for the idea.
I had a similar problem where Xcode would spend lots of time indexing and would frequently hang building the project, at which point I had to force-quit and relaunch Xcode. It was very annoying.
Then I noticed a warning in the project about improperly assigning self as a delegate. Sure enough, there was a missing protocol in the class declaration. Note that there is a similar assignment in the OP's sample code (though it is impossible to tell from the sample whether the correct protocol is declared):
leaderboardController.leaderboardDelegate == self;
After resolving that warning (by correctly declaring the implemented protocol), Xcode stopped misbehaving. Also, I should note that the project did execute correctly since the protocol methods were implemented. It was just that Xcode could not confirm that the protocol should in fact implemented by the class.
For me, I made a stupid mistake. I write a Class like this:
class A: A {
.......
}
A class inherit itself that causes the freezing. There is no message hint from Xcode.
Nothing worked for me, my project is too big (merging objective c, c++, swift, and java files with j2obj). I've disabled Xcode indexing and worked without code completion for months (and it's a pain). But finally I've found a workaround. The idea is to keep Xcode indexing the code, but to limit its CPU usage with an external tool like cputhrottle.
So first you need to install cputhrottle in terminal
brew install cputhrottle
Then limit the Xcode indexing process like this (20 = 20%)
sudo cputhrottle $(pgrep -f com.apple.dt.SKAgent) 20
I've exposed my "solution" here with mode details : How to prevent Xcode using 100% of CPU when indexing big projects
I'm working with Xcode 11.4.1 and I have the same problem with several projects. Every time, when internet connection is lost, indexing gets up. The best solution (it's just my opinion based on observing this problem):
- turn off internet and just kill the "com.apple...." process, then restart the Xcode(turn on connection)
or more easier
- just restart the Mac(with the internet)
Had similar problem in Xcode 6.4. The progress bar indicated that "Indexing" was "Paused". Tried deleting project.xcworkspace, then deleting Derived Data as described above. Did not appear to help. Noting that the posts above also suggest fixing warnings, and since I had inherited this huge project with 180 warnings, I said to myself, "What the hell this looks like a good day to fix warnings". As I was fixing warnings, a half hour later, I noticed that the "Indexing" progress bar had increased from 10% to about 20%. An hour later, it was at 50%, then another hour to 80%, then after another half hour it was done! Conclusion: Add "take a long lunch or a nap" to the above suggestions.
I experienced the same issue for Xcode 7.0 beta.
In my case, values for "Provisioning Profile" and "Product bundle identifier" of "Build Settings" differed between PROJECT and TARGETS.
I set the same values for them. And I also used the same values for TARGETS of "appName" and "appNameTest".
Then closed the project and reopened it.
That resolved my case.
In my case, deleting the derived data directory did not help. Apparently I had a file locked by another process, because after closing out a couple of terminal windows and emacs, and terminating a react-native packager process, everything resolved.
I have experienced this problem in some projects with Xcode 9.3.1 and in my case the problem is due to some swift code that for some reason Xcode doesn't like. This problem is hard to solve because is difficult to find what file is causing the problem.
When I have this problem, I removing some files from the Xcode project (removing references) and I try to test if indexing works. My process to do so
Remove some files
Close Xcode
Open Xcode
If indexing finish try to rename some method if works probably the files you have removed they have something strange for Xcode.
In my case I had a class definition with a reactive extension in the same file and for some reason Xcode doesn't like it, I moved the reactive extension to another file and now the indexing works fine.
2022 | Algorithm what to do:
Open activity monitor and kill there com.apple.dt.SKAgent
If did not help:
Close Xcode(cmd+Q). Run command in terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
If did not help:
Restart PC
If did not help:
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
If did not help:
run your project build with additional warning. For doing this you need to write:
-Xfrontend -warn-long-expression-type-checking=100
to the following place:
and optimize code at all of places.
If did not help:
Z. Uninstall XCode and install it from scratch
If did not help:
Z+1. answer of El Belga https://stackoverflow.com/a/50541767/4423545
Also stop running app. if you have another application running with your xcode, stop it first and you should have your indexing continue.
For me, the cause was I opened the same file in both the Primary Editor and Assistant Editor at the same time. Once I closed Assistant Editor, it came through. (Xcode Version 7.2.1)
Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.
Faced this recently on XCode 7.3.1 - for me, I noticed RAM usage going to 100% on to CleanMyMac3. The problem magically fixed itself after I restarted my machine. In all fairness however, I'd already gone ahead and tried the accepted-answer, so you'll want to do the same before you restart just in case :-)
I fixed this by simply deleting the app from my device and rebuild.
I had the same issue in swift 2.2
It had to do with a generic function overloaded function
func warnLog() {
print("Warning line: \(#line) file: \(#file) ")
}
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
func warnLog<T>(input:T) -> T {
print("Warning line: \(#line) file: \(#file) ")
return input
}
all I needed to do is remove one of the non used overloads
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
My case: it was not the project.xcworkspace file, it was not the Derived Data folder.
I've wasted a lot of time. Worse, no error message. No clue on the part of Xcode. Absolutely lost.
Finally this function (with more than 10 parameters) is responsible.
func animationFrames(level: Float,
image: String,
frame0: String,
frame1: String,
frame2: String,
frame3: String,
frame4: String,
frame5: String,
frame6: String,
frame7: String,
frame8: String,
frame9: String,
frame10: String) {
}
To go crazy! The truth is that it is worrisome (because there is no syntax error, or any type)
For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.
This issue happened to me when my machine was out of swap space. Closed several programs and browser tabs and the build suddenly succeeded after 30 minutes of being stuck in place. Nothing to do with derived data, locked files, etc. on my side.

The alerts in my Xcode project doesn't disappear

I'm working with the Google's Ios SDK, and recently i updated the file that contained the SDK. The problem is that i get these errors saying that the files doesn't exists, but they actually exist and works fine.
These are some of the errors (there is about 80 alerts)
So, what can i do?
Thanks!
This what i tried for the last error, but the alert doesn't disappear
If you're using XCode with source control integration ensure you have added those files to the repository. Once you have the files in question added/tracked in git/svn these warnings should disappear.
Also, it never hurts to Command-Option-Shift-K (clean) the project and re-open after you've tracked those files.
See this SO post for possible approaches.

Xcode 7 crash every time I try to print something in the debugger console

I've searched around and can't find anything on this.
Using Swift 2 and Xcode Version 7.0.1 (7A1001). Every time I execute something in the debugger console, Xcode crashes.
The project is not very big, and has less than 10 third party frameworks.
I can't think of much more information that's relevant, but I'm sure there's more, so please do ask me if there's anything I should add to my question that would help.
I've of course cleaned build and derived data.
It's driving me insane. Thanks!
UPDATE 16/11/12
Submitted rdar://23559366.
How are you maintaining your third party frameworks? Via Carthage?
If so then this is probably your issue: https://github.com/Carthage/Carthage/issues/924
This is an issue if the location of the /Carthage/Build/iOS folder is in a different location to where it was produced (i.e if it was compiled on a different machine and the absolute file path has changed).
A temporary fix would be to run carthage build --no-use-binaries on your machine to rebuild the symbols using the current absolute file path working around the bug.
But if you wasn't using carthage then its probably not your issue so sorry
I had similar problem with Xcode whenever I hit breakpoint.
In case you see this screen right before your Xcode crashes - you are lucky and my fix might save you. All you need to do is open this window and in the Project Navigator, select any file that you want, so that instead of that white blank view you would get your code. After this you are most likely will be able to successfully stop your app at your breakpoint and perform the debug.
I am not sure why this happens, but I suspect that the reason is Debug View Hierarchy mode, which you might have triggered prior to setting you breakpoint and trying to stop at it. At least this is when it happens to me.
I have similar problem earlier.
If you try to print non-optional variable and unfortunately it holds nil value then it breaks/crash. so that make sure declare all possible variables as "Optional type".

Xcode stalls on "loading" when trying to create new project

Xcode 6 never gets past "Loading" when I try to create a new project. I actually was able to create a new project yesterday, but I decided to just ditch it completely (deleted). Clearly there must be a bad file somewhere, possibly related to the project I deleted, since I also see the same stalling behavior now with Xcode 5.1, which has worked fine for creating new projects in the past. Xcode 6 has worked fine when starting with an already existing project and still appears to do so. I did not see this exact problem in your data base, though one person saw the project creation freeze before reaching the stage I get to. Their solution was to delete Xcode and every possible file related to it, which I'm a little squeamish about, since I don't want to affect existing projects, and don't have an understanding of what the various files are for.
Deleting the DerivedData of Xcode should fix the issue. You can do this by heading to ~/Library/Developer/XCode/DerivedData (with a Finder window open press cmd+G) and deleting all the subfolders of it.
This is embarrassing, but if it could happen to me, maybe it could happen to someone else. The problem was that the window that came up after the second step in defining the type of project to be created, the one in which you choose where to save the project's files, extended off the bottom of the screen, so that only the very tops of the buttons were visible. Eventually, I realized the one to the far right might be the one to click to continue. Which it was. Feel free to delete this question.

Resources