Can't Build in Xcode 6 - ARC Issues in Apple Frameworks - xcode

Upon updating to Xcode 6, I can no longer build my app. Xcode is throwing errors and warnings like the following:
Error:
/Applications/Xcode-6.0.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectContext.h:121:5:
Pointer to non-const type 'id' with no explicit ownership
Warning:
/Applications/Xcode-6.0.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:206:4:
warning: '__strong' only applies to Objective-C object or block
pointer types; type here is 'const char *' [-Wignored-attributes]
The error is in CoreData.framework, the warning is in Foundation.framework.
Here's a link to my build log: http://pastebin.com/RCgV8Pj1
I've tried deleting and re-adding my frameworks using both drag and drop from the Frameworks directory, and the add button in Project->Build Phases. Neither fixes the error. I also tried deleting the SharedPrecompiledHeaders directory. I also saw this, but his fix doesn't work for me. I have no "Frameworks" directory in my project. I even went as far as re-installing Xcode 6.
I assume this is an error with a build setting someplace, but I don't know what would have changed or what I should update. Initially after using Xcode 6 I couldn't build in Xcode 5 either, but I reverted my xcodeproj and it works fine in the older version.

Make sure you don't have a Frameworks path in your FRAMEWORK_SEARCH_PATHS in project settings or target settings, as it can cause headers to be read from both iPhoneOS.platform and iPhoneSimulator.platform, causing warnings during compilation and errors during linking.
The problem can arise spontaneously if you add/change frameworks in your project and once Xcode's caches have been rebuilt, you also lose the ability to compile backups of your project because the bug is at the Xcode level.
See:
My answer in '__strong' only applies to objective-c object or block pointer types; type here is XXX" warning

This appears to have been fixed by upgrading to OS X 10.10 GM and reinstalling Xcode 6. Not sure which one actually allowed the project to build.
[UPDATE]This didn't permanently fix the issue. It came back after about 5 days.

Related

How Do I Delete A Target In Xcode 9?

Xcode 9 is quite similar to Xcode 8.
I'm building Apple's Open Source IOGraphicsFamily.
In the Products group there is a target called iogdiagnose. Its source produced many compiler errors when I tried to build all my targets, so I removed the group with iogdiagnose's source from my project.
But the iogdiagnose target is still there. It produces a link error - missing main.
Google failed to yield insight. There was the same question for Xcode 6.1, but Xcode 9 is quite different from 6.1.
Building the IOGraphicsFamily driver stack has been a huge PITA. I need my own build so I can enable the driver stack's kprintf logging.
Simply right-click on the target and click on Delete.
I deleted the target by editing the project.pbxproj that's in the .xcodeproj bundle.
That worked just fine however but there must a GUI to delete targets.
The great thing about Xcode is that Apple keeps us sharped-eyed by rearranging the GUI in profound ways with each new release.

Swift build fails: target might include it's own product

Has anyone run into this issue? I was experimenting with porting an existing obj-c app to Swift, and after quite a few successful builds the project will no longer build and immediately gives the error: Unable to run command 'CompileSwift normal' - this target might include its own product. Along with many other 'target might include it's own product errors'.
What I've Tried:
Checking Target Dependencies: There is nothing listed as a target dependency in Build Phases.
I've tried completely deleting the product folders, and have went through all the files multiple times but with no luck.
If I simply replace the Swift files with the old obj-c files it builds fine, no errors at all.
Restoring to a snapshot prior to any Swift modifications results in building as normal, but even if I add a brand new Swift boilerplate file and bridging header, then click build, it fails with the same errors.
I had the same issue. I couldn't work out exactly what was causing it, but realised the same code would build find on a different Xcode 6 install on a different machine.
I solved it by deleting my cached builds, etc, in ~/Library/Developer/Xcode, while Xcode is not running. "Clean" alone from within Xcode didn't do it.
You should find that when you re-launch Xcode your app will build fine.
Deleting my app target from "Build Phases -> Copy Bundle Resources" worked for me. (Somehow it was being included for bundling?)
I could reproduce the problem. In the objc-to-swift bridge header I imported a header of an objc class, which also imports swift-to-objc header. There was a cycle of imports and this could be the reason Xcode complaint.
I think for now it is best to avoid such cyclic importing between swift and objc. You might want to check that out.

Xcode 4.4.1 Error Validating Mac app : CFBundleExecutable of two bundles may not point to the same file

I'm hitting this error after upgrading to Xcode 4.4.1 + 10.8.2. (Both were done at the same time). This is when validating an archive from an Xcode project for the mac app store.
The full error is :
CFBundleexecutable of two bundles may not point to the same file. The following shared bundle path have been found: MyAppName.app/Contents.
I'm not really sure what this means, the same exact source compiled without errors on 10.7.x Xcode 4.3.x. However I need to compile on 10.8.x & XCode 4.4.x+.
After trying a few things, I was able to fix it. The issue here was the Info.plist file was included in the 'copy bundle resources' build phase. Since this file is already copied by XCode elsewhere, it was causing the conflict. I removed the Info.plist from the 'copy bundle resources' build phase, and that fixed the issue.
Due to the unclear message given by XCode, hopefully this will at least help others a bit more quickly in the future.

Xcode shows many errors but program compiles and runs fine (in both simulator and device)

After installing the CocoaLumberjack' log compressor class I've been getting this annoying behavior: Xcode complains that there are many undeclared identifiers and gives me many errors (not warnings but errors with the red icon).
The thing is that I can compile and run my iPad app just fine but Xcode won't do any autocompletion. I tried cleaning the build folder (Product > option + Clean), and also deleting derived data. I've also rebooted to no avail.
As you can imagine this is a pain to work with. I did have this behavior happen before on a previous version of Xcode; it had something to do with stuff in my precompiled headers file but using the solution above would always fix it. I'm currently using Xcode 4.4 (4F250).
Sample error I'm getting:
Semantic Error: use of undeclared identifier 'DDTTYLogger'
The above happens even with classes that I wrote myself and that have not changed since installing the CocoaLumberjack compressor class.
I finally solved this after MANY attempts using the following:
Remove the last #import from my Prefix.pch and build again. Errors would happen (obviously). Put the line back and build again. No errors would show and after 10 seconds or so, errors would come back again.
Repeat the above except instead of the last #import, remove the last TWO imports, then three, four, etc. I did this until I removed five imports and when I put them back and waited, Xcode stopped complaining.
Note that this didn't occur to me at all. I read this solution on a blog somewhere.
Weird bug...
Open build settings and set "Precompile Prefix Header" to "No", that solved my problem.
Kudos for: https://stackoverflow.com/a/7035492/936957
I've been running into these issues constantly on all the latest versions of Xcode, in both Objective-C and Swift.
I noticed today that I was getting the errors in one particular class file. I removed it from some extra targets it was in and the errors finally went away!
I think Xcode has some fundamental bugs with it's handling of multiple targets right now. My theory is that if the other target is not built, you will essentially see errors from that target. Anyway hope this helps someone.
Not bad,
If you follow these Steps-
1-Clean Xcode(Cmd+Shif+K).
2- Clear Derived Data(Cmd+Shift+G).
Enter this path( ~/Library/Developer/Xcode/DerivedData/).
3- Quit and open again Xcode.
This problem can cause by setting "Target Membership" for some files are not the same.
Example:
A class XYZ put in file "a.swift" and it's used in file "b.swift". But "Target Membership" setting of "a.swift" is not the same "Target Membership" setting of b.swift.
Check "Target Membership" setting as below:
I was having issues with a library installed via cocoapods. Going to Build Settings and searching for 'Allow Non-modular Includes In Framework Modules' then setting it to Yes did the trick.
I had it on Xcode 10.1 when I accidentally pressed:
Cmd+Shift+U - ( build for Testing )
try Clean (Cmd+Shift+K) and then:
Cmd+Shift+R ( build for Running )
After update to Xcode 11, I met the same problem. I tried all the mentioned advices (cleaning folders, turning on/off different settings, restarting xCode), but nothing helped. Also, I have a big project in C, so, I'd like to keep using precompiled headers.
Finally I found that simple restart of Mac OS solves the problem! It's really weird behaviour, but I'm happy anyway that I found a solution – it's hard to code when lots of colourful error messages float around.
For me it helped cleanning the project. XCode->Product->Clean
I got the similar type of issue.
Alternate option to fix this is
Open organizer and delete the derived data of your project or delete all the projects in organizer projects tab. It works fine..
I just had the same thing in Xcode 5.1.
I fixed it by making sure there were no blank lines between #import's
I have removed some extra spaces and extra lines from .pch file and it xcode stopped complaining
This happened to me as well, but cleaning didn't fix it. What did was quitting and reopening XCode. Afterwards, all the phantom errors were gone. For those wondering, the tabs you have open when you close will still be open when you reopen.
I had this issue recently. It can be remedied in some cases by deleting the ModuleCache folder inside DerivedData, along with the project folder in DerivedData. Note that Xcode must be quit before doing this.
Running on Xcode Version 10.1 (10B61), I set the build setting "Increase Sharing of Precompiled Headers" to NO. I was working in an .xcworkspace with many projects sharing the same frameworks, and no Objective-C bridging header (meaning I've added no obj-c code myself). I'm not sure when Xcode did away with .pch files by default, but I didn't have any of those in my project.
Open up a terminal and create a nice little function accessible via the command line...
nano ~/.bashrc
add (making the necessary substitutions between the pointy braces)
cycle() {
git stash save "BACKUP"
git checkout <<SOME OTHER BRANCH>>
git branch -D $1
xcodebuild -allowProvisioningUpdates -workspace <<YOUR WORKSPACE>>.xcworkspace -scheme <<YOUR SCHEME>> -configuration Release clean
git checkout $1
}
^X and save it by following the prompts, then enter source ~/.bashrc to make it visible to the current terminal session.
Make sure your branch is pushed to origin, cause we're going to delete it :)
Call the function using cycle <<MY BRANCH>> (once it's run you might want to call git stash pop to restore any working copy changes)
Hope it works for you! Xcode, get on your game!
In my case (mixed objc/swift project) at least part of errors were caused by absence of imports for some used frameworks, e.g. "import UIKit". Project was compiled successfully because frameworks were anyway included in headers in Prefix.pch file. But errors were shown, for example about not finding method defined in UILabel extension, and yes, this extension was without "import UIKit". So I think these errors in most cases depends on Prefix.pch precompilation/updating.
Touching Prefix.pch, cleaning, removing derived data, closing/opening XCode sometimes helps, but not always.
Using SPM, it can be that the Module you import, which you use at the location of the errors, has missing dependencies itself.
In my case I had an error about a missing initializer, XCode trying to use a different one than the one already defined in the other Module. But the project compiled fine! Nothing worked at first. Then I tried first cleaning, and then Product -> Perform Action -> Compile "myfile.swift" and it showed what the missing dependency in the dependency was! Note: This goes recursive. In multiple places a depenendency may have not been declared in the package.swift -> compile the same file repeatedly until it compiles successfully.
So.. it wasn't that the module with the error had a missing dependency, but rather that the direct dependency did miss a Module-dependency declaration in its package.swift declaration.
My explanation is that to generate the Error-output of XCode, Modules get compiled alone on their own. Import errors then show up. But when Modules are built as part of a larger Module, then that large module may import the missing dependency of the broken sub-Module already, making the build pass.

'Compile Sources' not updated while dragging files to a project in Xcode 4.3.2

I am just not sure if this is a bug in Xcode 4.3.2 or is it supposed to be this way.
When I upgraded to Xcode 4.3.2 some time back and dragged some files onto a newly created project, it repeatedly threw linker errors while compiling. All the required frameworks were already linked. Turned out, that these errors disappeared when I went and manually added the .m files that I had manually dragged onto the project, in the Build Settings - Compile Sources.
I have done the same thing in previous versions of Xcode and never had to update the manually update the compile sources myself. I would assume that if any .m file is dragged into the project, the compile sources should be automatically updated.
I don't have any previous version Xcode currently available with me where I can test it, but would like to know if this really is a bug in Xcode 4.3.2 or is there something else that I am missing.
'Add to Targets' needs to be checked while dragging files on to the project.
First : whatever Thunder Rabbit said
Second: I never encountered any problems dragging the .m file but i did encountered problems by dragging an SDK file such as for twitter etc. For that I had to change the library search path in Build Settings.
Third: I also encountered Strip errors in one of the SDKs, the solution of which I mentioned in this question: error in generating archives
Hope the information helps

Resources