XCode warning - duplicate CMakeLists.txt while trying to change project name - objective-c

I tried to change the name of my xcode project, (which uses the cocos2d framework), but for some reason my main files folder (the one that contains all the .h and .mm files) wouldn't change the name. so then i manually clicked under "MyProj TARGETS -> Build Settings" and manually changed the fields:
Info.plist File
Header Search Paths
User Header Search Paths
Prefix Header
to be using "MyProj/" instead of "PrevName/" (the previous name i had named the project) but now i'm getting these two strange warnings:
Warning: Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/MyProj-fzlkaghtvjzkgkenbpejhzwvxsft/Build/Products/Debug-iphonesimulator/MyProj.app/CMakeLists.txt
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'MyProj/Resources/Info.plist'.
you'll see that this is also mentioned under: http://www.cocos2d-iphone.org/forum/topic/33245 but no one has answered this part
and i tried to look under Xcode warning: "Multiple build commands for output file" to see under "Build Phases -> Copy Bundle Resource"... and indeed, there were 2 CMakeLists.txt files. one is:
MyProj/libs/Box2D
and the other is:
MyProj/libs/kazmath/src
which one do i need? or do i need both, since i think xcode used to be compiling with both??
i should mention that my project seems to be running okay right now if i leave the warnings in. but i don't like warnings that i don't understand, and i know that i could just swap my source/assets to a new project to get rid of the warning, but i'd like to know for future reference how to properly rename everything in a xcode project.
Thanks

Oh wow... I had no idea the traffic on stackoverflow is so low these days...(or at least for xcode & iOS dev) sighs
Anyways, I think I figured out a fix.
I read apple developer guilde for the second Warning
For the first Warning, I looked at another file that I had created, and I compared my project's settings to the other project's settings. (such a simple solution, duh, why didn't I think of this >_<) and it turns out, under Copy Bundle Resources, you're only supposed to have:
Your .png files and other resources used in code (but NOT your plist file, for the very reason given in the link above)
iTunesArtwork
ChangeLog
Actually, i'm not sure if you even need #2 or #3. I'll give an upvote to whoever experiments with it. So.... the solution is to simply remove all those other CMakeLists and cmakes and all that junk, including plist :)

Related

Xcode cannot find ProductModuleName-Swift.h

I'm attempting to import my "-Swift.h" file into one of my Objective-C .h files but xcode keeps telling me that the file doesn't exist
#import "Aesculus-Swift.h"
If I command click on the file name it will take me to the generated header file so I know it exists. Why is xcode not able to find it?
This seems like just another issue with Xcode and it's complex tool chain of static analysers and compilers.
Openradar lists radar://21362856 - Swift to Objective-C bridging is unreliable. I am sure there are more but I stopped looking after finding one for this example.
The author imarcelv notes in the description:
I asked a Swift engineer at WWDC in a lab and even he didn't know how to fix this issue.
Steps to Reproduce:
Add a ramdom Swift class to an Objective-C project
Add the #import "ModuleName-Swift.h" file that Xcode generates automatically
Try to use it or just try to compile the project
From time to time it simply doesn't work
It's probably best to file a radar on this issue as it seems that others are already calling it out.
One other thing you could try...
Historically, it was possible for Xcode to completely lose it's syntax highlighting and you could always find out what files the static analyser was giving up on by increasing log level of clang.
I'm not sure if it's still relevant but if I was in your position I'd be trying this command:
defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3
This generates logs you can search with using Console.app for just xcode to highlight the messages. You'll want to trash the derived data of your project to force it to re-compile things.
Although not the same issue as what you're seeing, I have had this post on the syntax highlighting issue bookmarked for years for the above defaults write command to try in times like these.
I solved this recently by adding the following entry to my .xcconfig (you could add it in Xcode's Build Settings > User Header Search Paths if you prefer).
USER_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/MyFramework.framework/Headers
This tells the compiler to search for headers in the build output directory, which is where Xcode puts the generated header (at least in the case of this framework).
In my case this is a directory like ~/Library/Developer/Xcode/DerivedData/MyProject-LongCode/Build/Products/Debug-iphonesimulator/MyFramework.framework/Headers/MyFramework. You might find your generated header in there too.
Xcode's header and dependency management is a hot mess, and it's not surprising that it doesn't work for you.
I had trouble with this stuff & found that your -Swift file is the Product name of your Target ( not just the name of your Target ) . I found the details here helpful: http://ericasadun.com/2014/08/21/swift-calling-swift-functions-from-objective-c/
When you encounter such situation, just find your kinda "ProductName-Swift.h" file by just cmnd+click on it (even if xcode shows warning about it is not found, the #import "Aesculus-Swift.h" string is still clickable) and then in opened code editor window choose context menu and "Show in Finder" item, then explicitly add it to your project.

Xcode: all .h files lost syntax coloring

I had a project that was working for almost a week then suddenly all my .h files lost code completion/syntax coloring.The only changes i could think of was i changed my target's name and then when i created a new set of .h and .m files this started.
Okay I have checked everything on this topic which was commonly an issue in xcode 3 and 4, i tried all solutions like
Clean/rebuild/restart Xcode
Remove Derived Data
Precompile Prefix Header to No
Add "$(SRCROOT)/**" to header search path
Nothing has worked, any help would be appreciated.Also my Xcode version is 6.1.1.
Try these Solutions:-
You can able to fix that issue by change build settings like this, PreCompile Prefix Headers :NO
I've been doing this, and it's worked multiple times for me (after trying all of the above previously).
Now I just hit space, backspace (the mac version) and rebuild... works nice. Then, remember to scroll (sometimes the colors don't show up until you scroll somewhere)
Find your prefix file: "ProjectName_prefix.pch".
Comment out some line. (basically change it)
Build your project, doesn't matter if it fails or not.
Uncomment it.
Build again.
I'm betting only step 2 (modify the prefix) is what does it, but these essentially get you back to running. Suddenly everything magically recolors itself and completes functions.
Good luck if that doesn't fix it, perhaps try doing this to your dependency pch files (three20 or FB api's)
Okay I found out what the problem was, in my case i had changed the target name and in the process the project name also.
This resulted in the change of path of the prefix header when actually the file was still at the old path. Changing it to the old path fixed the problem.
The prefix header path can be found in Build settings.
usually something like ProjectName/Prefixfilename.pch

Precompiled Header with Constants issue

I have a few constants files "Constants.h" in my project that I am including in the Prefix.pch file to be available to all the classes in my project. They just contain a bunch of #define statements.
My classes don't recognize these constants (no autocomplete) and Xcode gives me "Undeclared Identifier" errors every time I use them. However when I run the project everything works fine (set to ignore errors).
Is there any way I can get rid of these warnings? #pragma ignore them in the prefix file or something? I've tried many options, including setting "precompile prefix header" to NO in build settings.
Any ideas?
EDIT:
I have tried deleting derived data and cleaning / deleting build folder to no avail.
It might be worth noting that I have 3 targets in my project, and another project within this project.
Also, some of the #imports import normal classes. Like a category extension on UIFont and an Analytics class. Could this affect it?
To fix this, I had to change the 'Precompile Prefix Header' flag to NO in my target's Build Settings. By doing this you'll lose any build performance achieved by having a cached compiled header file, but in my case, my Prefix Header is pretty small so I wont see a hit in the time it takes to build.
Try deleting the project derived data. Xcode sometimes needs to re-index your project to remove "errors" such as this.
Organizer > Projects > Your Project
Click on the "Delete" button to the right of the Derived Data row.
Immediately quit Xcode, and then reopen.
I had the PCH file importing .h file with a lot of macros (specifically, I use the MJGAvailability header that warns when I use features that are newer than my deployment target).
Replacing:
#import "MJGAvailability.h"
with
#include "MJGAvailability.h"
solved this issue for me.
I had a preprocessor macro in one of my targets that I moved from 'preprocessor macros' to 'preprocessor macros not used in precompiled headers' and that solved the problem.

build failed with: ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController

I am getting this error suddenly when running my app via iPhone simulator:
clang: error: linker command failed with exit code 1 (use -v to see
invocation):
ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController in
.../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/Algebra5.build/Objects-normal/i386/ExercisesViewController.o
and
.../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/PSLE
Algebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o
for architecture i386
What is it all about?
It look like the class Algebra5FirstViewController is compile multiple time.
Can you make sure that the .m and .mm is only included once in your project sources in Xcode? You can also confirm this by checking in the compile log (last icon at the right, next to the breakpoints icon) and see that confirm that it is only compiled once.
Also, if this class is part of a library that you link against and you have a class with the same name, you could have the same error.
Finally, you can try a clean and rebuild, just in case the old object files are still present and there is some junk in the compiled files. Just in case...
EDIT
I also note that the second reference is made in the file for ExercisesViewController. Maybe there is something in this file. Either you #imported the Algebra5FirstViewController file instead of the .h, or the ExercisesViewController has #implementation (Algebra5FirstViewController) instead of #implementation (ExercisesViewController), or there was some junk with this file that will cleaned with a Clean an Rebuild.
That can happen if the same .m file is referenced multiple times in your target's "Compile Sources" section in "Build Phases". Remove duplicate entries and you should be fine.
also had this problem by declaring a const * NSString in the header file (incorrectly) instead of the implementation file (correctly)
I got this issue because I accidentally imported the .m instead of the .h. Hope reading this saves someone with same problem some time.
I had same problem. Got it solved!
If you have imported any files into project then check .m (main) file for same does exists in Targets (Project Name) -> Build Phases -> Compile Sources.
If file does not exists then include it using (+) Add button shown.
Also, if duplicate files exists (if any) then delete it.
Now press cmd+shift+k to clean the project. New Build should not display this error.
I got a similar error when adding files from another project, like #paiego explained. My error was that I didn't check "Add to targets". As explained above, I deleted the references and added the files again but this time checking "Add to targets".
I was getting similar error and I got it resolved this way.
Try to set Build Active Architecture Only to NO for 'Pods' project and
your app's target
In one case, I saw this error when dragging a new class' .h and .m into the project. The only solution I found was to remove the references to these files and then add them back via the project menu.
I met it when import a ViewController.m in TableViewController. Try to delete '#import "ViewController.m"' if it exited. Hope this help!
'linker command failed with exit code 1 (use -v to see invocation)'- I got this error when running a phonegap application on iPhone. I changed Build Active Architecture Only to Yes and it worked fine.
It seems that for m, I dragged the files into the project and after that didn't work, clicked file "add files to project". Both were the incorrect approach. just drag it into the projects folder (in finder) that houses the other .h and .m files.
once i got
18 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1
For me this was due to that i have used "const NSInteger" in my switch case.
What i did is change the const NSInteger to enum, and replace the reference with enum values.
This fixed the error for me.
This happens either, some files are missing in the "Compile Sources" section, or duplicate entries are found for some file(s). In my case, I had duplicate entries for two files, I deleted one entry for each of the files, that solved my problem. Hope this helps.
I found this article that provided a solution for me. It pertains to Xcode 7 where the default for No Common Blocks is Yes rather than No in previous versions.
This is a quote from the article:
The problem seems to be that the "No common blocks" in the "Apple LLVM
6.1 - Code Generation" section in the Build settings pane is set to Yes, in the latest version of Xcode.
This caused what I will describe as circular references where a class that was included in my Compile Sources was referenced via a #import in another source file (appDelegate.m). This caused duplicate blocks for variables that were declared in the original base class.
Changing the value to No immediately enabled my app to compile and resolved my problem.
I'm posting a new answer to this because I ran into this error and had to use a different solution that I think is specific to iOS 9.
I had to explicitly disable the Enable Bitcode in Build Settings, which is automatically turned on in the update.
Referenced answer: New warnings in iOS 9
[XCODE 7.1 UPDATE]
First Option That Worked:
I changed the Deployment Target from 7.1 to 8.1 and the error went away.
Hope that helps someone.
UPDATE (day 2): Second time I'm back here in 2 days.
On day 2 I started to get more errors in addition to this annoying error. The problem was a conflicting file that Xcode didn't recognize. I used the links below as help:
"_OBJC_CLASS_$_viewsampleViewController", referenced from:
‘ld: warning: directory not found for option’
And ultimately:
"_OBJC_CLASS_$_viewsampleViewController", referenced from:
I was deleting everything from the FrameWork Search Paths + Compile Resources + Run Script Phases + the pods and then re-installing them again to ultimately find success.
The issue on my size (on day 2) was more of a problem with conflicting files or files that Xcode didn't recognize.
But ultimately, removing everything (mentioned above and in the links), cleaning a lot of times and reinstalling the pods/frameworks/run script phases helped.
Really hope this helps someone.
Running Xcode 4.6.3 on OSX 10.7.5 was able to fix this error by changing Architectures to Native Architecture of Build Machine from $(NATIVE_ARCH_ACTUAL).
I received this once by (accidentally) importing both the .h and .m files into the same class.
I got this error while implementing a subclass without the necessary framework added (MPMoviePlayerController without the MediaPlayer framework, in this example)
I got this same issue when working with Bolts.framework. It turns out that when Bolts gets corrupted, no amount of re-importing will fix the issue. I had to go back to the original download file and reimport it completely from scratch. This fixed it right away. It was such a weird issue that it took me forever to figure it out... hopefully this tip will spare some of you from the same frustrations :)
This occurred for me when I named a UILabel reference and an int the same thing, I didn't get an error when I typed it only when I tried to run it so I didn't realize that that was the problem, but if you have something like a label which is the "score" and you call it score, and name an int which is the score also score then this problem occurs.
Variations on this issue can occur if you have a missing library or file. Check there aren't any missing files in your Project Explorer: they'll be written in red if Xcode can't find them.
"Link Binary With Libraries" had old project name pod library. Fixed after removal.
List item
Project
Build Phases
Link Binary With Libraries
Remove deprecated library.
I had this same issue with a library, and I tried all of the answers listed here and nothing helped.
I ended up simply removing the library from Link Binary With Libraries and then re-adding it and it worked fine.
The only (and unfailing) way to resolve this issue is building test from command line:
xcodebuild -workspace MyProject.xcworkspace/ -scheme MyScheme -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' test
So, at this point, your compilation will surely fail but you'll see all linking problem. In my case, I had several problem such as:
ld: framework 'Foo' not found
To resolve this, you need to on your target, BuildSettings->Linking->OtherLinkerFlags and remove 'Foo' framework .
Use of unresolved identifier 'ClassName' .
To resolve this, I need to add/check file's target membership to UITest target too.
Other possible problems will be raised by xcodebuild and you can easily fix it.
Simply cleaning CMD + SHIFT + K, then building CMD + B worked for me.
In my case I had a reference to a library in Other Linker Flags. Removing it got rid of the error.
I had the same error.
I had imported a audio frame work that i was no longer using. I removed it (DO NOT DELETE IT!) and it built successfully.

Multiple build commands warning while building - Objective C

When I build my iPhone Project in XCode, I'm getting the following warning.
[WARN]Warning: Multiple build commands for output file /Users/SilentCoder/Library/Developer/Xcode/DerivedData/myProject-csfqcpziyuvhbiatwwjtkkmwbxwv/Build/Products/Debug-iphonesimulator/myProject.app/car.png
I don't understand what does that mean. I have made targets for both iPhone and iPad for my project.
It's likely that you have specified the resource to be copied to your bundle/resources twice.
(check your copy resource build phases)
Works for me.
Check the list of resources in Project - Target - Build Phases - Copy Bundle Resources Section and remove the resources references.
I create my own first framework following [http://www.raywenderlich.com/65964/create-a-framework-for-ios] (How to Create a Framework for iOS), appearing the same warning.
And I have no extra resources but two source code files (.h and .m).
Lastly, I found that the .h file appears in two place, one is Copy Files, the other is Copy Header, and I delete latter one, the warning disappeared
NB: you get the exact same error message in a slightly different situation: if a header file appears twice in Xcode's internal list of header-files to export.
If the affected file has a .h suffix, then ... instead of removing from the "Copy Bundle Resources" phase, you need to remove from the "Copy Headers" phase.
(NB: this ought to be impossible, and XCode SHOULD NOT allow it to happen, but Xcode's handling of header files is terrible (and doesn't adhere to the standards :( ), so it's quite easy to end up with this "duplicated commands for the same header file" problem)