I have an XCode 6 project with two targets - an iOS 8 app and an iOS 8 extension. I share a constants file across both targets.
I made the mistake of declaring a const int without an extern or static prefix in the header, which resulted in the duplicate symbols linker error.
This erroneous declaration has existed for the past several revisions of the project, and the constants header has been included in MULTIPLE files since day one.
Why then, did I start getting the error only recently - after I made a change to the project file by removing the Main.storyboard - and that too ONLY on the simulator build?
Note: This has happened before
Further background on when the error started occurring:
I removed an unused Main.storyboard from the project file, and immediately after, started getting this linker error. I knew this error should not be occurring now, since the relevant constant had been used for ages.
I fixed the error anyway (by declaring the const as an extern instead), but now started getting some other errors.
I was now convinced there wasn't anything wrong with the code, and it was just XCode mucking up. So to test I ONCE AGAIN removed the Main.storyboard, and the weird errors (sorry I don't have a record) were back again, with zero changes to code.
To confirm further, I checked out a complete prior commit (which had worked flawlessly, and still had the Main.storyboard) on the same machine. This time, without any changes to the code, the project or Main.storyboard, I saw the same errors.
This confirmed that there wasn't any problem with my actual pbxproj and source files, but some problem in the data XCode had cached (somewhere).
Note that clearing the DerivedData folder didn't help either.
The roundabout point being, XCode definitely seems to be at fault whether for throwing the error suddenly or not throwing it all this while. But I'm checking if there could be another logical explanation for why XCode suddenly seemed to "change" its behavior.
Just check that you haven't #imported a .m file by mistake, instead of a .h. This has caused the duplicate symbol error for me in the past.
Related
I have recently updated to macOS 13.0 and for that minimum XCode Version required is 14.x series. But my existing project never getting successfully building. Its getting stuck at some point.
Its not getting failed. Build process screenshot is attached below. Its not pointing to any specific class. Seems like there are lots of classes which are getting compiled successfully at last but still build process is stuck at some point:
Seen similar threads like below on apple pages but nothing seems working. Does anyone got resolution?
Xcode 14 project compile error
XCode 14 compile errors immediately disappear or do not appear at all
Something similar has happened to me in the past on a number of occasions. If the Swift compiler is hanging mid-build, usually the issue is that there is some expression that is too complex for Swift to do the type inference on.
What you need to do is first find the exact statement that is causing the hang. This is how I do it:
First find out which source file is causing the problem. Look at the build log to figure this out (the build log can be located by looking at the reports navigator ⌘9 ). Find the build log and click on it. The build log will appear in an editor window.
One of the compiles will still be in progress and its file is the one you want.
The next thing to do is comment out all the code and recompile. This time the compilation will finish (if you have the right file, or there is only one) but probably with a lot of errors. Then you add the code back in, function by function, until one of them causes the compilation to hang again. If it's not obvious which line of the function is causing the problem, comment it out again and then add the lines back one by one until the compilation breaks again.
Once you have located the line, you need to simplify the type inference on that line. If it's a closure, try adding an explicit declaration for its parameters and return type. If it involves some complex array, try adding a type annotation to its declaration. Also try breaking down complex expressions into multiple simpler expressions.
There's no one size fits all answer to this but usually, once you have located the exact line that is causing the problem, it should be reasonably obvious how to fix it.
I am updating a legacy project which was built in objective-c. I am currently battling 2 issues with that project.
The legacy project has enabled lot of compiler flags and building the project throws this warning conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull' for stuff like this - (nullable instancetype)init NS_UNAVAILABLE
I understand why it is showing it and I believe it is showing this warning because the project has --Wnullability-declspec flag ON.
I can turn it off and the warning disappears. However, if I put it back then the warning does not come back. I got baffled by it. I cleaned up the project and made sure there are no filters set but still could not figure out why xcode stops showing the warning.
(I do know the correct fix is not to remove the flag and I know how to fix the issue in the code. I am just amused the xcode stops showing the warnings). So, I am trying to figure how why xcode behaves this way.
The warning which is coming is actually in the library header which this project includes.
I own that library. So, I tried to add that compiler option(--Wnullability-declspec) to that libs source code and see if I get the warning. But I don't see that warning in that libs source code.
So, the other question which I have is why I get the warning in the project which includes this library and not in the actual library.
I get this Xcode 6 warning: "Argument unused during compilation", and I get several .d files in the Issue Navigator.
Some background of how the project is organized will probably point to where my issue lies. I have two targets, and they have slightly different settings. One is for the automated build, and the other is the development one. The Develop does not have this warnings. The automated build one was duplicated from the Develop one. Of course, Xcode generated different plist files, so I had to make sure they both used the same to not have to maintain duplicate settings. I also had to change the Product Name, since the auto build one would otherwise export with it's funny name (it has _CI appended to the name of the App). That would cause some issue.
Also, I'm using Cocoa Pods, in case this might have to do with the issue?
I'm using both Swift and Objective C, and I have unit tests set up.
Here's what the warning looks like, exactly:
Argument unused during compilation: '-MF /Users/user.name/Library/Developer/Xcode/DerivedData/App_iOS-akqwlfytlhwajobqkbaqgojblmet/Build/Intermediates/App_iOS.build/Debug-iphonesimulator/App_iOS_CI.build/Objects-normal/x86_64/MenuModel.d'
Hope this helps pinpoint the issue.
Thanks in advance.
My app crashes on build. Here's the error in it's entirety:
DataModelVersionCompile /Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd XXXXXXXXXX/WMMGDataModel.xcdatamodeld
cd "/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX"
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc -XD_MOMC_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -XD_MOMC_IOS_TARGET_VERSION=8.1 -MOMC_PLATFORMS iphonesimulator /Users/AAAAAAA/Desktop/Everything\ from\ DT\ 1:20:15/App\ projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld /Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld/WMMGDataModel 5.xcdatamodel:WMMGAccount.attribute: error: WMMGAccount.attribute must have a defined type
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld:0: error: Compilation failed for data model at path '/Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd/WMMGDataModel 5.mom'
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc failed with exit code 1
The relevant part seems to be:
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld/WMMGDataModel 5.xcdatamodel:WMMGAccount.attribute: error: WMMGAccount.attribute must have a defined type
I've gone into my xcdatamodel, but can't find any attributes that aren't properly defined by type. One suspicious thing I'm seeing is the reference to WMMGDataModel 5. I'm up to version 8 in my model, and can't even find version 5.
This crash began after a recent automatic migration (using MagicalRecord) in which I added an attribute to one of the entities and then recreated the Managed Object Subclass (yes, the new subclass contains the new, properly defined attribute). I've added attributes before, but this is the first time I've encountered this issue.
I've cleaned the thing, quit and restarted Xcode, still crashes. Anybody have any ideas? I also deleted the DerivedData folder for the project. Still won't build.
Edit:
I just recreated all my managed subclass files. Still no dice--same error message.
Edit:
I tried running another project as a control, and got this message:
Unable to run app in Simulator
An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code = 4)
So I quit Xcode and the simulator, restarted Xcode. Same error.
Yet more info
I restarted the computer and tried again, but am still getting "Build Failed" with the same error message.
If anyone else has run into anything like this, I sure would appreciate some guidance here... :)
Final edit
Please see solution in my answer below...
Ok, I finally cured the problem with a decision to delete my xcdatamodeld and rebuild the entire model. Some research into how to do this yielded a less destructive and less risky method in this answer.
Here's hoping it will help someone else with this problem.
Thanks to all who took a look!
I've never had the problem you describe, but have a few suggestions. Apologies if you've already tried these:
First, in the model editor, can you access the model version 5 that you suspect is the problem, eg.:
If it's there, you can hopefully fix the attribute error. If it doesn't appear there, have you tried right-click in the Project Navigator and select "Show in Finder":
Then in Finder looking for the version 5?
I've been using RestKit in a project for the last couple of months without any issues. I have it set up as per the instructions on the Github wiki. Today Xcode hung while connecting to the simulator. I had just edited some trivial UI code completely unrelated to anything touching RestKit. I had to force quit Xcode and restart. When I restarted and compiled again, RestKit built successfully but I got a string of Errors related to my application. On closer inspection they are all related to RestKit. There are a cascade of errors starting in RKRequestSerializable then spreading out to every RestKit class that references it.
The first error is 'Expected a type' for the line:
#protocol RKRequestSerializable
then 'Expected selector for Objective-C method' for the line:
- (NSString*)HTTPHeaderValueForContentType;
then 'Expected a method body' for:
#optional
The first thing I did was revert the changes I had made since the last successful compile, but this made no difference. I then rolled RestKit back in case I had accidentally made a change, but this had no effect. I have tried deleting derived data, deleting and re-adding RestKit, but nothing has any effect. My project will not compile.
The strangest thing is that RestKit compiles successfully. The errors are from the compilation of my project. I've lost three hours on this so far and would greatly appreciate any input or suggestions as to how I might solve this.
Are you still building for the simulator? I've seen this behavior after an XCode crash. The Schema gets set to OS X 64 bit or something else and RestKit doesn't compile there.