Strange, Sudden compiler fail error in Xcode for iPhone dev - iphone

What is the following error caused by? I did not make any significant changes and suddenly it started appearing:
Linking /Users/JimB/Desktop/iPhone Dev/Games4Kids/build/Debug-iphonesimulator/ETFanClub.app/Games4Kids(1 error)
duplicate symbol .objc_category_nameNSString_HTTPExtensions in (path)ViewController3 and (path)ViewController1
Command /Xcode 3.1.4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

The symbol .objc_category_nameNSString_HTTPExtensions is duplicated, meaning the category NSString(HTTPExtensions) is declared twice ViewController3 and ViewController1.
Check that you don't have #implementation's in the headers #import-ed by both of these files, and they don't both have #implementation NSString(HTTPExtensions) simultaneously.

Related

Abort Trap: 6 error after upgrading to Xcode 14

I just updated my Xcode to Version 14.1 (14B47b) from version 13.4. When I try to run my SwiftUI project in the live preview, the "Abort Trap" errors showed everywhere in the project.
Part of the error log is as below:
CompileSwift normal x86_64 /Users/apple/Downloads/SwapSpot/SwapU/ViewModels/ItemVMs/ItemGridViewModel.swift (in target 'SwapU' from project 'SwapU')
unknown:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
unknown:0: note: SmallVector unable to grow. Requested capacity (4294967297) is larger than maximum value for size type (4294967295)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
I found a post that answers as such:
We will not observe "Abort: trap 6", if under Build Settings, we are using "Optimize for Speed" in Debug, instead of "No Optimization"
We can also avoid "Abort: trap 6", if we change the following code
guard let batchUpdateResult = batchUpdateResult else { return }
to
guard let batchUpdateResult2 = batchUpdateResult else { return }
I tried both methods mentioned above. Renaming the guard let variable did not work at all. Changing the optimization level in the target removed all the Abort Trap errors, and the project runs successfully in the simulator.
However, the live preview stopped working due to the optimization level. The new error is stated below:
OptimizationLevelError: not building -Onone
"SwapU.app" needs -Onone Swift optimization level to use previews
I believe this is a swift compiler error. Can anyone help me avoid this while keeping the live preview working?

Realm Migration Swift

I added a new Class ,newClass, to my Realm file through Realm Studio to allow users to manage an array of items. I also created swift file to manage the new class in XCode.
Since running the app immediately after doing the above, all my data from the firstClass, has disappeared (not a problem the user adds all data in this class on startup, I can repopulate whilst testing the app.)
My app now crashes whenever it reaches any code let realm = try! Realm(). I have commented out or removed references to these to see if it is a localised problem, but it still continuous to crash with the following similar errors depending on the VC it crashes on when during let realm = try! Realm().
schema version 1
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=1 "Provided schema version 0 is less than last set version 1." UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1., Error Code=1}: file /Users/UserName/Desktop/AppName/AppName/Custom VC's/AddDataToRealmViewController.swift, line 168
2020-06-27 13:23:10.481817+0100 AppName[4498:173994] Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=1 "Provided schema version 0 is less than last set version 1." UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1., Error Code=1}: file /Users/UserName/Desktop/AppName/AppName/Custom VC's/AddDataToRealmViewController.swift, line 168
After doing a little bit of reading around, it suggest I need to migrate my realm file to the new schema? Before I attempt this, would this be the correct course of action to take?

Xcode 8 random command failed due to signal segmentation fault 11

I have a strange problem with the new Xcode 8 (no beta version) and swift3.
Once every other 3-4 times that I compile my code I get a 'command failed due to signal segmentation fault 11' error. I just need to enter new empty line, or sometimes changing some spaces, or add a comment (everywhere in the code) and the error disappears and I can compile again.
This is really strange because I'm not changing anything in the code! And sometimes I can compile and it works, then I don't change anything, I compile again and I get the error.
This is really annoying!
I have noticed this is happening since I have installed several 'Firebase' pods (Firebase, Firebase/Auth etc...). But I need them.
Anyone has any suggestion?
PS: I have set the Enable Bitcode of my project to No as many solution suggested, but nothing. In the error message it is not indicated any swift page where the error can be, an example is:
While loading members for 'Class_name' at
While deserializing 'func_name' (FuncDecl #42)
'func_name' is this one:
public class func loginUser(fir_user: FIRUser) {
let user = SFUser()
user.email = fir_user.email
user.isLogged = true
try! sfRealm.write() {
sfRealm.add(user, update:true)
}
var userToAdd = [String:AnyObject]()
userToAdd["email"] = fir_user.email! as NSString
let ref=FIRDatabase.database().reference()
let usersRef = ref.child(childName)
usersRef.setValue([key:value])
}
But then, as I said, I can just enter an empty row in another file and it compiles!
Thanks
I have the same issue i just figure out that i was using xcode 8.1 and the project's working copy was in xcode 8.2.1 so i just re install xcode 8.2.1 and problem got solved. Hope other can get the help trough this.
Ok, it seems that I have found the solution: it is a problem with Firebase and cocoapods, so 2 solutions:
Download Firebase and import into your project
I, instead, updated cocoapods to the last version and it worked. Upgraded Firebase - Now Getting Swift Compile Error
In my case there was some type checking issue deep down the compiler so the editor didn't give error in the gutter but on building the project I was getting signal setmentation fault 11 error:
1. While type-checking 'GetStoreAPIRequestModel' at /Users/.../StoreAPIModel.swift:9:1
2. While type-checking expression at [/Users/.../StoreAPIModel.swift:15:18 - line:15:31] RangeText="[Dictionary]()"
3. While resolving type [Dictionary] at [/Users/.../StoreAPIModel.swift:15:18 - line:15:29] RangeText="[Dictionary]"
So I changed my code from:
var stores = [Dictionary]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as! Dictionary).getModel())
}
}
}
To (more descriptive dictionary):
var stores = [[String : Any]]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as [String : AnyObject]).getModel())
}
}
}
This is tricky problem. Issue can be with line of code or syntax. I was getting similar error and it was due to incorrect usage of dictionary. I was trying to increment the value of dictionary element.
Solution is to triage the code, detailed error provide which module has issue, so try commenting part of code until you find the line which is causing the issue.
Hi i had the same issue with FireBase , my problem was that i was extending FIRStorageReference and FIRDatabaseReference and some time it compile successfully some time i get
command failed due to signal segmentation fault 11
so i removed that files and implement the method other way , now everything works fine.
Found my problem when this occurred. (No cocoapods.) I thought I had left the program in a working state, but I was wrong. I am writing a straightforward command-line program. What it does is somewhat general, so I defined all the strings that make it specific in let statements at the top of the program so that I could someday use the program in a different context.
Since that was working so well, I thought I'd be clever and do the same with a filter of an array of dictionaries. I turned:
list.filter { $0["SearchStrings"] == nil }
into:
let test = { $0["SearchStrings"] == nil }
// ...
list.filter(test)
meaning to continue working on the let, but I never went back and did that. Building gave me the segmentation fault error. Defining test as a function fixed the problem.
(Incidentally, I understand how to strip a filtering function down to the terse braces notation in the context of the call to Array.filter, and why that works, but I don't understand why I can't assign the brace expression to a constant and use it as such.)

Strange Xcode error

When I run my app, i get one error and i dont know how to fix it. Can someone help me?
Here is the error:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Picture: http://imageshack.us/photo/my-images/200/screenshot20110609at256.png/
Thanks
The causative problem is the error immediately preceding that one, the duplicate symbol error.
gcc-4.2 failed with exit code 1 Error Occurs due to some of your file or frame work are duplicated check it out which file is in you target link file or in your framework are repeated.
from your log message "didUpdate" may be repeated in your project look for that...
May be this is helpful to You.
From the error message, it seems like didUpdate is defined more than once in your code. Search for didUpdate on your workspace and make sure it's only being defined once.
Either you are redefining variable or you are probably importing a *.m file somewhere in your project.Try importing corresponding *.h file.

iphone: co-processor offset out of range

i have a strange compiling problem with xcode and iphone. my game is almost finish but now i got suddently this compiling error:
{standard input}:6108:co-processor offset out of range
gcc-4.2 failed with exit code 1
this only happens if i compile the release version for the device. the debug version and both versions for the simulator works. clean targets and recompile don't work.
strangly enough that error only happens if i add a line of code to one specific source file and only between these lines:
[_sharedDirector checkAndPutScoreToHighscore:(int)[player score]];
gameOverScreen = YES;
gameOverScreenSlideY = 320.0f;
[buttonManager activateButtonWithID:replayButton];
[buttonManager activateButtonWithID:menuButton];
so when i put a random line between this lines of code i get that error.
i do not know what causes this error. i had opened the sourcecode file to "show as assembly file" just for fun but i don't think this has caused the error.
has anybode a hint for me what could be going on? i am searching the web for over 3 hours and thats very frustrating.
You most likely found a compiler bug. You really should switch to the LLVM compiler (clang).