78

I just created one new cordova ios project via CLI, and i opened that project in Xcode 7.1 and while running on simulator am getting some error on mainViewController.xib, if we clicked on that error its showing xib file and on top of that showing one warning message "An internal error occurred. Editing functionality may be limited" . So am unable to run this project.

I don't know whether this is due to Xcode bug or cordova bug or any other settings issue in my Xcode.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
Arjun T Raj
  • 3,187
  • 1
  • 21
  • 44
  • 1
    Same problem here. Wish someone give a brief explanation about it. – Tulon Nov 01 '15 at 16:43
  • @Tulon i tried lots of solutions but :( , now i installed xcode 6.1 again. – Arjun T Raj Nov 01 '15 at 16:57
  • Don't be impatient my friend. There should be some answer for it. :) – Tulon Nov 01 '15 at 17:07
  • @Tulon any workaround for this? – Arjun T Raj Nov 02 '15 at 08:53
  • 2
    @Tulon just try product--->archive , and its working fine then i took build then i got http://forum.ionicframework.com/t/cordova-cdvviewcontroller-h-file-not-found-in-xcode-7-1-beta/32232/15 error, so i applied that fix and now its running on simulator am not sure about this fix just try once – Arjun T Raj Nov 02 '15 at 17:45
  • Its not just for cordova. I am experiencing this with a native iOS project. – BangOperator Nov 03 '15 at 05:39
  • @somexyz hi just try product--->archive and chek once , and check all deployment targets also.. – Arjun T Raj Nov 03 '15 at 06:00
  • That solution on the Ionic forum worked for me – FrancescoMussi Nov 04 '15 at 10:03
  • @Arjun T Raj I don't know how or why, the error is not showing anymore. I just restarted my xcode. That's it. :/ – Tulon Nov 07 '15 at 05:01
  • I wish there were a way in Xcode to at least disable the msg bar that auto shows and hides, it happens so often I can't type in a straight line! – Brynjar May 10 '16 at 11:32
  • I don't care about the lousy message but rather would like to turn it off since it jump shifts the edit text by one line which is extremely confusing. – qwerty_so Sep 05 '16 at 10:49
  • What worked for me (not related to Cordova) was to comment-out the source code I'd just copied into the project. The error went away. Then I could reduce the amount of code I'd commented out little by little until I got a "real" error message that made me realize what was wrong with the code I'd added. – RenniePet Jan 26 '17 at 05:34
  • i'm facing same issue on Xcode 9.0 . Need help. tried all of below solutions but not work any of them – Adnan Majeed Oct 10 '17 at 11:03
  • @AdnanMajeed its working fine without any fix (xcode 8+) – Arjun T Raj Oct 10 '17 at 11:12
  • @ArjunTRaj Bro i never face this issue on Xcode 7 or 8. now i'm facing first time this issue on Xcode 9.0. :( And i've tried all the solutions below mention. but no work. – Adnan Majeed Oct 10 '17 at 11:23
  • @AdnanMajeed till now i don't know the actual solution or fix. – Arjun T Raj Oct 10 '17 at 11:40
  • Xcode 9 the same problem – Genevios Jul 03 '18 at 13:42
  • 2
    Apple continue make animoji when the main soft for dev program with thousand bugs – Genevios Jul 03 '18 at 13:43

28 Answers28

34

I had this issue and clearing derived data folder fixed the issue for me

Preferences > Locations > Derived Data > click the arrow to open in Finder > trash it.
jithin
  • 1,412
  • 2
  • 17
  • 27
  • 3
    Worked for me--just to clarify, you just need to delete all the files _in_ this folder, not the folder itself. (Maybe Xcode will recreate the folder if you delete it, but it's probably safer not to.) – James Toomey Jul 29 '17 at 22:01
  • 3
    Side note: Before removing the `DerivedData` folder, Xcode must be entirely closed. – Raptor Feb 12 '19 at 02:37
  • @JamesToomey no there's no risk implication. You can delete the folder and Xcode will recreate immediately and empty. – Matteo Gobbi Jan 24 '23 at 20:55
27

Try this, it's work for me,

Updated NOTE: Mostly this error occurred when you have open 2 different version of Xcode at same time.

Solution: Please close both Xcode and clear derived data.now again try, use one Xcode at a time.

OR

Follow below mention steps ,

1) Trash derived data by two ways either by command or Preferences.

rm -rf ~/Library/Developer/Xcode/DerivedData/

OR

Xcode---> Preferences--->Location--->Derived Data

derived data

2) In Xcode menu go to product clear the project.

enter image description here

3) Disconnect connected device and restart Xcode and system .

enter image description here

follow above steps error will remove.

Hope it's helpful for some one.

Jaywant Khedkar
  • 5,941
  • 2
  • 44
  • 55
13

Fixed the problem in my program, hope this can help someone!

So, this is the process of my fix:

  1. Could not figure out why I was getting this issue, when everything had been working fine.

  2. I tried the following:
    Cleaning project
    Deleting DerivedData
    Creating new, identical View Controllers to see if the issue was just in those particular views. (the same issue occurred)
    Deleting and Reinstalling Xcode
    Restarting my Computer.
    Asking on StackOverflow.
    (Finally) Submitting a TSI, which got redirected to Apple Bug Reporter.

  3. I made a new swift file for the View Controller that was having the issue, and it compiled, showing that is was not an issue with the View Controller itself.

  4. I started getting an error: "Command failed due to signal: Segmentation fault: 11" (on the file associated with the View that did not work), which is really ambiguous. This error looks as if it would be an error occurring in a segue (jumping from one View Controller to another) but the code itself would not compile. After digging into the error, I realized the code stopped compiling at that swift file.

  5. So, I copy-pasted the code from the swift file (the one causing problems) into the Notes application and I deleted the swift file from the Application.

  6. Little by little, I started taking code from the file that did not work (in Notes) and putting it into the file that did work until the error came up:

    Command failed due to signal: Segmentation fault: 11

  7. I started commenting out snippets of the code to isolate the error.

  8. After finding the error line, I realized it was just an error that caused all of these issues. A simple fix that the debugger did not recognize as a routine error. So, I fixed it and it works!

And for those of you less inclined to read

Summary of what your problem may be:

  • Compile-time error in your code that is not recognized by the Xcode debugger!
Raptor
  • 53,206
  • 45
  • 230
  • 366
Ryan Cocuzzo
  • 3,109
  • 7
  • 35
  • 64
  • 2
    This works when you dont have 10.000 lines of codes, multiple targets or cocoapods dependencies I guess. I am gonna go crazy because of this error. – SpaceDust__ May 19 '17 at 18:23
  • Tried a similar process too, it worked, but then, anytime I type in any wrong code, it immediately gives me the "Command failed due to signal: Segmentation fault: 11" and "an internal error..." and it drove me nuts. Deleting derived data and re-adding my linked libraries worked afterwards though – Mofe Ejegi Dec 26 '17 at 05:36
8

I'm in Xcode 7.3 and had the same issue after opening file in xCode 8.0. This worked for me:

Made a product/clean in Xcode, then quit Xcode and clean out all the content in ~/Library/Developer/Xcode/DerivedData manually.

Jay Singh
  • 181
  • 2
  • 6
ZiggyST
  • 587
  • 6
  • 11
3

Just to add to the mix. This started to happen to me out of sudden with Xcode 14.0. There was also "Report a bug" button on the top-right. Clicking on the button created a folder with the bug report and in the log.txt file there there was a reference to IBAgent failure and iPhone SE simulator - the one used for the preview in the interface builder.

Looks like the IBAgent process crashed at some earlier point. I had no idea how to restart this particular process. Cleaning derived data folder & restarting Xcode were not helping.

The whole mac restart fixed the issue. IBAgent is running and opening that same storyboard with no problem.

Reported/Submitted to Apple.

Stanislav Dvoychenko
  • 1,303
  • 1
  • 15
  • 15
2

Close project from File menu and Reopen the project again, the issue is gone.

Chris Ho
  • 295
  • 4
  • 13
2

Mine caused from creating a bad constraint so I fixed the constraint and everything is working now.

Ahmadreza
  • 6,950
  • 5
  • 50
  • 69
1

from my side, its RAM issue. I have remove others application.Then it works normally.

Zahed
  • 73
  • 2
  • 9
1

I was getting this error on Xcode 11.4. I tried all of the above suggestions and none of them worked. I am posting my fix in case it will help someone else. I was using the legacy build system for my project since I had options that were not yet supported with the latest build system. Xcode 11.4 now supports those options. I the value for BuildSystemType to Latest in all of WorkspaceSettings.xcsettings files and then this error went away.

    <key>BuildSystemType</key>
    <string>Latest</string>
Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37
0

I have the same problem. The only way I have found to get round this is to update the target 'Deployment Target' to 8.1 and also the CordovaLib project 'Deployment Target' to 8.1 this allows the app to build and run without the MainViewController error. However this is not a great solution as I assume it no longer supports devices with ios 7.1 installed.

0

I have deleted XCode 7.1 and installed XCode 7.0.1.

http://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_7.0.1/Xcode_7.0.1.dmg

This solved the problem.

joan16v
  • 5,055
  • 4
  • 49
  • 49
  • 2
    just try this fix for 7.1 http://forum.ionicframework.com/t/cordova-cdvviewcontroller-h-file-not-found-in-xcode-7-1-beta/32232/15 – Arjun T Raj Nov 05 '15 at 17:36
0

I updated XCode to 7.1.1 and this resolved the issue.

Geekoder
  • 1,531
  • 10
  • 21
  • I have 7.1.1. and I have still this issue. – mcfly soft Dec 15 '15 at 08:49
  • 1) If you are directly opening the project, make sure you are opening in XCode 7.1.1. I have multiple XCode installed so I set XCode7.1.1 as default. 2) Clean All Target and run again. Also try to delete the module cache and build folder. – Geekoder Dec 16 '15 at 10:20
  • I have Xcode 7.3 and I have the same issue. Do anyone found a solution for this problem ? – Mohammed Mar 29 '16 at 14:20
  • Why the -1? It solved for me. Just one of the answers. – Geekoder Mar 30 '16 at 12:21
  • Xcode 7.3.1 and the issue still exists... It is dependent on your exact source code though I suspect. – Brynjar May 10 '16 at 11:30
0

I changed Xcode - Preferences - Text Editing, ticked on 'Code Folding Ribbon' and 'Focus code blocks on hover'.

Cleaned the project and it removed the source editing error.

Alvin George
  • 14,148
  • 92
  • 64
0

Yesterday I had this problem too. I remember I've had it before 1 year too and I remember how to fix it. The reason for the error (in my case) was an error in the code in AppDelegate. Sometimes errors in AppDelegate are the reason for this behaviour of xCode. So if You want to fix it, first try commenting Your code in AppDelegate function by function, until you find the function with the error. Once you find it start uncommenting piece by piece the code in that particular function until you see which code line is breaking everything. Believe me ... This will save you lots of time searching the internet.

Hristo Atanasov
  • 1,236
  • 2
  • 18
  • 25
  • In some cases could be an error in other files except AppDell too. In order to find the problematic piece of code quicker, try commenting the last edited/written code before the problem has occurred .. :) – Hristo Atanasov Apr 20 '16 at 13:59
0

Xcode 7.3.1

In my case, the error was caused by the following line:

print("|" + board[x][y])

Changed to:

print("| \(board[x][y])")

After that, I did a Product -> Clean (Command+Shift+K) That fixed the issue.

PS: board[x][y] is a [[Character]], if that matters. I copy-pasted my Java Class into Xcode to edit it into Swift.

Alex Ureche
  • 351
  • 2
  • 7
0

Running Xcode 7.3.1, I had the same error message appear while editing a .xib file. Performance would stall, and Xcode often became unresponsive. Filed a bug report, and in the meantime came across this line of code in the .m file associated with the most problematic .xib:

NSString *check = [formatter stringFromDate:date];/

The "/" was not being flagged as an error, and the project had built and run many times with this in place. After removing the "/", performance improved dramatically, and the error message has only appeared a couple of times, briefly, since then and by now not for several days.

So far, this seems to be a case of a glitch in the debugger.

Jase68
  • 276
  • 2
  • 7
0

As for me problem was in ternary operator (single line if statement). Version 7.3.1

Che
  • 501
  • 2
  • 10
0

FWIW, here's what fixed this for me:

I was performing an operation on a value in a dictionary:

_outcomes[key] *= multiplier

I didn't realize that Swift would treat the value as an optional even though the dictionary is not an optional in this class.

changing to the following worked:

_outcomes[key]! *= multiplier
Michael James
  • 492
  • 1
  • 6
  • 19
0

I just had this issue today and it really got me frustrated for awhile. First I got the error "unable to boot the simulator" and I couldn't load the simulator and then my storyboard started doing this and I got an internal error.

I tried the other solutions mentioned here including cleaning and rebuilding, deleting the DerivedData folder but none worked. I upgraded my OS to Sierra and that solved the problem for me.

Hope it helps.

Community
  • 1
  • 1
TheBen
  • 3,410
  • 3
  • 26
  • 51
0

This has been happening to me on Swift 3.1, Xcode 8.3.2 for a month, I was coding okay, But it came to a point that all the text was only plain text, no colours, no auto complete, no indent. What a torture.....

Xcode was showing an error for NSAttributedString, but it was compiling fine, I could even see the underlined button in the app no problem. When I removed this code xcode went back to normal. How strange.

Took me days to figure out. I checked out every single commit from github until I found a version of my project that doesnt throw An internal error occurred. Source editor functionality is limited. error.

Then I compared the commit versions and I figured this started to happen when I edited UIButton text thru the code.

Error caused because of NSAttributedString I wanted to underline to the button text as following

    let titleAttributes:[String : Any] = [NSForegroundColorAttributeName : Constants.forgotPassColor, NSUnderlineStyleAttributeName : NSUnderlineStyle.styleSingle.rawValue]
    let localizedForgotPass = NSLocalizedString("forgotPassword", tableName: "Localizable", comment: "forgot button text")
    let titleString = NSAttributedString(string: localizedForgotPass, attributes: titleAttributes)
    forgetPasswordButton.setAttributedTitle(titleString, for: .normal)

Removing this solved the problem. There is something wrong with NSAttributedString in Swift 3.1

SpaceDust__
  • 4,844
  • 4
  • 43
  • 82
0

Unfortunately, this error is pretty generic and doesn't point to an actual cause. If you look at the error report generated by Xcode, you might be able to get more context to figure out what is going on.

Common causes include:

  • Incorrect permissions / ownership set on files.
  • Manually deleting files in ~/Library/Developer.
  • Installing buggy 3rd party kexts (especially security or firewall software).
Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
0

This happened to me in Xcode 10.2, while editing .xib file. Trying to clear de derived data didn't help me. What solved the problem was change the device for prototyping in the interface builder, it forced the IB to render again and solved the problem. enter image description here

Hugo Jordao
  • 786
  • 8
  • 9
0

Also happens when you declare non-swift/wrong data types like Long, boolean etc. So stupid.

rajeswari ratala
  • 650
  • 7
  • 14
0

Super specific but one of compile-time errors that can cause this is putting the keyword 'optional' before a function in a non-objc protocol.

Logan George
  • 141
  • 8
0

It happened to me because I copied buttons from old XIB files to the storyboard. So i deleted the buttons, and all is ok. I am guessing apple added some non compatible button XMLs in the new storyboard.

GeneCode
  • 7,545
  • 8
  • 50
  • 85
0

I had this problem yesterday, and after some digging, I solved the problem which was very stupid in my case. I discovered that I put an environment object inside a class function, like this:

class SomeHelpers {
    static func someFunc(_ value: Bool) {
        @EnvironmentObject var userData: UserData // << HERE
    }
}

I removed that line, and the strange error gone away.

Sami Almalki
  • 588
  • 2
  • 17
0

I solved this problem on XCode 13.4 by disconnecting the device (iPhone) and restarting XCode. Before that I tried to clean Derived Data and Build Folder - didn't help.

Denis Kutlubaev
  • 15,320
  • 6
  • 84
  • 70
0

Jan 2023, Xcode 14 - this error still happening. I was able to get off easy: clean, file, exit Xcode, reboot MBP. Went away.

user3741598
  • 297
  • 1
  • 12