Xcode - duplicate Target - new Target fails to build - xcode

using Xcode 3.2.5 on 10.6.6 (10J521) and now 10J537.
I have an Xcode project containing 1 Target: "MyApp". It builds and runs successfully.
As well as source and resource files, the Target contains a "Copy Files" build phase which copies "Sparkle.framework" in. The framework is in the same directory as the project.
I want to duplicate this Target. Steps taken:
Did "Clean all Targets".
Right-clicked on the "MyApp" Target within Xcode, and then chose "Duplicate".
Renamed the duplicated target to "MyAppTarget2".
Selected "MyAppTarget2" as the Active Target from the popup menu in the top-left.
Did "Build".
The problem:
error: Sparkle/Sparkle.h: No such file or directory
At the line:
#import <Sparkle/Sparkle.h> // In MyAppDelegate.mm
This is puzzling! Further info:
Each Build step appears to have been replicated in the duplicated Target, including the "Copy Files" phase.
The Sparkle.framework itself exists in the project's folder.
In the "Link Binaries with Library" phase of both "MyApp" and "MyAppTarget2", I am linking to the Sparkle.framework at the above location. A "Get Info" on the linked binary reports that it is a member of both Targets.
If I right-click on the Sparkle.framework file within the "Copy Files" build phase of the duplicated Target, and select "Reveal in Finder", then the correct Sparkle.framework file is shown. The required file exists at Sparkle.framework/Headers/Sparkle.h
If I switch back to the original "MyApp" target, it builds and runs successfully.
Am I doing something obviously wrong here? Thanks.
[EDIT - SOLVED]

I had a look at the Build settings for each supposedly-identical Target.
Under "Framework Search Paths", the first Target had this:
$(inherited) "$(SRCROOT)"
But the duplicated Target had this path:
$(inherited) \"$(SRCROOT)\"
It appears that Xcode incorrectly escaped the path during the duplication process. Ouch.

I know you have already solved this issue yourself, but I thought I'd share my fix for this issue (as it has happened to me several times). I've always been able to get rid of this error by deleting the file in question and just recreating it. I have no idea why this works... but, as is often the case with XCode, there seems to be some Voodoo at work.

Build Phase copy is still broken in 12.5! It does only copy a few of the source targets build phases. What a crap IDE.

Related

Automatically add files other than source files to 'Compile Sources' build phase in Xcode 5

I have a custom build rule for a file type, which I setup according to this blog post. The build rule is working fine and my file is compiled.
But if I add a new file of this type to the project and I select the targets, the file is currently added to the "Copy Bundle Resources" phase. Instead, I'd like to have it added to the "Compile Sources" phase automatically (if I don't do this, the build rule won't kick in).
Is there a flag or something I can set so Xcode recognizes my files as "source files"?

xcodebuild cannot find header in embedded projects

I have a project embed another project, and the xcode GUI build was successful, but in command line xcodebuild failed as such.
fatal error: 'OHAttributedLabel/OHAttributedLabel.h' file not found
#import <OHAttributedLabel/OHAttributedLabel.h>
^
1 error generated.
but I had this in the project HEADER SEARCH PATH (where the h is located)
${PROJECT_DIR}/MyProject/Vendor/OHAttributedLabel/Source
the problem is the header is located in the "OHAttributedLabel/Source" folder, while the import statement is looking for header under OHAttributedLabel folder, I don't want to touch the embedded project directory structure, what can I do in this case?
The best way is to modify the embedded project to publish the header files:
Select the embedded project in xCode
Select the applicable target.
Click on the build phases
Expand "Copy Headers" section and add OHAttributedLabel.h file.
Select your main project
Select the applicable target.
Click on build phases.
Click on Target dependencies.
Make sure that the embedded project is added as a dependency.
Try to run the app
If the above doesn't work double-check the order of the build phases. E.g. make sure that the "Target Dependencies" build phase is before "Compile sources".

XCode - Changes to static libraries doesn't cause the build system to relink the executable

I have a project "blackjack" containing a project (as a child) called "GameLib", which in turn contains many projects such as "Core-iOS". I have libCore-iOS.a added to "Link Binary With Libraries," but changing a .cpp/.mm file in the static libraries doesn't cause the executable to be linked against the new .a file. The .a file is being compiled with the changes. Why is the build system broken, and how do I fix it?
You need to configure all of your targets' dependencies.
blackjack
libCore-iOS.a << dependency
If Xcode's automatic dependency detection fails, then configure libCore-iOS target as a dependency explicitly. That then solves it.
If you have found automatic dependency detection in error, please consider submitting a bug report with projects attached. I have found errors in it, but was unable (erm.. unwilling) to submit projects for them to debug the issue.
To define an Explicit Dependency:
Open the "blackjack" Project in Xcode
Select the "blackjack" Project in the Project Navigator (Top-Level)
Select the "blackjack" Target
Choose "Build Phases" tab
Click '+' in "Target Dependencies" phase, and add libGameLib target as a dependency
Click '+' in "Link Binary With Libraries" phase, and add libGameLib
Now disable "Find Implicit Dependencies" in all schemes
Restart Xcode
Clean and Build Project
That should be all that's needed to create an explicit dependency, unless you have made some atypical mods to your build settings.

How to get Xcode to refresh folder references on device?

I created a folder reference by doing the following:
Created a folder on disk. Added whatever files are meant to be in it.
In Xcode
---> Add files to project
---> Clicked on folder
---> Unchecked copy files if necessary
--->Clicked create folder references for any added folders
The problem:
Whenever I make changes to files in the folder (add/delete) etc. The changes are picked up in Xcode. (You can see the changes in project navigator). These changes are not there when I run on the simulator. Deleting the application on the simulator does not help. Only when I click "Reset content and Settings" in the simulator, does it pick up the changes.
I already have added the following script to my build phases:
touch -cm "${BACKGROUND_TEXTURES}"
It is run after compiling, but before copying bundle resources. My bundle resources contain this folder.
I'm not sure whether the script matters, since Xcode picks up the changes with to without it. It's the simulator that doesn't get updated, unless I manually set "Reset content and settings".
What is the correct way to solve my problem?
EDIT: I have tried Clean, then Build, but that doesn't seem to make any difference.
Example:
I create "Images" folder at project folder, and I "create folder references for any added folders".
Next I add touch -cm ${SRCROOT}/../../Images to Run Script,And I drag "Run Script" before to "Compile Sources"
clean and build,it's ok.

XCode 3.1.2, header file not found

I have been trying to build a code that has dependencies with other header files that are not in the project directory. I added the paths to these header files in both HEADER_PATH and USER_PATH. However, I still see error while building. It says that the file is not found. I verified that the file exist in the path added to the header search path in project settings.
How do I make sure that all my header files referenced in the project is included and the paths are being picked by Xcode during compilation?
I tried copying all the files to the project with no luck. This is the first time iam using Xcode, so its kind of frustrating. Iam a linux guy and comfortable with make files. Is there a Make file for xcode which i can modify to include the header file directories.
You might want to check the order of your source files in your target's build phases to ensure that your dependencies are compiled before your source files that reference them.
Select your project in the Project Navigator.
Select your target.
Click on the Build Phases tab.
Click on Compile Sources to expand the section.
Drag the dependencies to the top of the list.
Are you sure you spelled the header file name correctly ? Is the case correct ? Did you use user quotes "" rather than system quotes <> ?
Assuming you've checked all the obvious things such as the above then one other thing to try is to quit Xcode, delete the "build" folder in your project directory, and try again - sometimes the build folder gets in a pickle internally.

Resources