Why does Xcode use the old build path after moving a project's containing directory? - xcode

I have created a simple OSX Command Line App project with Xcode 6.3, called Foo, and set the location of Foo to ~/Desktop. Building and running the project is fine. To be clear, the project path is ~/Desktop/Foo/Foo.xcodeproj.
If I move the project's containing directory ~/Desktop/Foo to, say ~/Desktop/tmp/Foo, open ~/Desktop/tmp/Foo/Foo.xcodeproj, and then build the project, I see that Xcode creates ~/Desktop/Foo/build/ and so on. It seems that Xcode is still using the old build path rather than the build directory that is relative to the project (~/Desktop/tmp/Foo/build/).
Why is this? I am using a typical installation of Xcode and have not modified any configuration of Xcode nor the project or its build settings. Xcode 5 definitely did not behave this way.
Yes, the project has been cleaned.

I can only attribute this to accumulated cruft after installing, removing, and updating Xcode to various 6.x betas over the past year.
After deleting Xcode configuration via defaults delete com.apple.dt.Xcode, things are behaving as expected.

Related

xcodebuild clean deletes non-target files in BUILD_DIR - new in Xcode 12.5

I have our Xcode build system setup to place all build products in a pair of directories, one for Debug configuration and the other for Release using the build setting
BUILD_DIR = /Library/DevWork/BuildProducts
specified in a shared .xconfig file.
This worked fine up through Xcode 12.4 as the xcodebuild clean command would delete only the target and leave all the other files in the build products directory intact.
New with Xcode 12.5, xcodebuild clean deletes the entire contents of the build products directory. Is there a way to disable this behavior?
New with Xcode 12.5, xcodebuild clean deletes the entire contents of the build products directory. Is there a way to disable this behavior?
The behavior isn't actually new with Xcode 12.5; it's been part of the "new build system" since it was introduced in Xcode 10:
The new build system uses the “clean build folder” behavior. The legacy “clean” behavior is not supported.
The "legacy" build system has been deprecated for a while. I don't know if it's still available at all in Xcode 12.5, but whether it is or not, it's time to make the move to the new system.
Is there a way to disable this behavior?
No.
If you really need to keep old build artifacts around, you could add a post-build script that copies them to another location.

XCode 9 unable to build - linker fails with "File not found" on object files - project builds fine in XCode 8.3.3

Here's a frustrating one. My project builds perfectly in 8.x versions of XCode, and yet in 9.x versions, it fails consistently in the linker phase, as the linker is unable to find the .o file for a seemingly random class.
For example, in one build it will be unable to find the intermediate object file for my UIWindow subclass:
In other builds, other files may be identified as the culprit, with the same "file not found" linker error.
So, clearly there is a disconnect in the linker phase. I can understand that. But I cannot make it work to save my life.
Here's what DIDN'T work:
• Deleting derived data
• Cleaning and option-cleaning
• In the .swift file inspector, removing the file from the target and re-adding to target
• Renaming the target
• Deleting the supposedly erroneous files from the project, and moving to trash, then re-adding the files to the project and target.
• Switching advanced workspace settings for Build Settings from "XCode default" to "Legacy"
• Updating XCode from 9.0 to 9.0.1
• Deintegrating Cocoapods and reinstalling them
Jeez.
So, none of the usual suspects are at play here.
Additional details :
• When I look in the folder specified in the linker error message, the .o files are NOT THERE. (Are they not being created? Is there a setting for that?)
• Using Mac OS High Sierra on a MacBook Pro Retina 15
So there's my conundrum.
Does anyone know why XCode 9 would either not be creating .o files, or would be unable to find those files, for a project that build perfectly in previous versions of XCode?
Thanks!
The only solution I found was admittedly pretty painful. I created a new project and then re-imported all the files and dependencies into the new project. Then setup all the build settings, etc. At that point the project was back to building and working fine.
If this happened again, I would try deleting the .xcworkspace file and re-generating it with pod install first before starting a new project.
May this not happen to you.

SpriteBuilder - how to update Cocos2d

It has been awhile since I have used SpriteBuilder with Cocos2d. I am trying to create a new project from SpriteBuilder that I can modify in Xcode. From SpriteBuilder I go to 'File > Open Project in Xcode". This opens Xcode with the new project. When I build the project I get over 40 errors (e.g. 'UIAccelerometer' is deprecated: first deprecated in iOS 5.0 - UIAccelerometer has been replaced by the CoreMotion framework.). It looks like I need to update my Cocos2d. So I went to the repo here and found this statement in the README: "SpriteBuilder also allows you to update the Cocos2D version in your project, to newest version, making it trivial to always keep you project updated to latest Cocos2D version." So it looks like it should be easy to do it, but I can't figure it out. Any ideas?
Xcode Version: 7.1 (7B91b)
SpriteBuilder Version: 1.4.9
SpriteBuilder Revision: eea568a5c7
I'm not sure how you can update cocos2d directly from Spritebuilder, but rather than rely on SpriteBuilder to perform the update, you can do it manually.
You can get the most up to date version of cocos2d by downloading the project straight from its repository on Github. If you want to clone the repository from the command line, the command is:
git clone --recursive https://github.com/cocos2d/cocos2d-objc.git
This will download the latest version of Cocos2D (and its dependencies). Now to update the project. Navigate to the new version and copy three folders: cocos2d, cocos2d-ui and external. These three folders contain the changes that need to be moved into your project.
The next part is finding the location of Cocos2D in your project—it's located in the folder named cocos2d-iphone inside the project. Pasting the new folders will prompt a warning that you are trying to replace folders that exist already. For the current updated version of cocos2d, this shouldn't be a problem.
Then, you'll want to "Clean" your project and set your iOS Deployment Target to 8.0.
As a safety precaution, you should then clean the project build folder. You can find the "Clean Build Folder..." by holding the option key (⌥) while selecting the "Product" drop down. (Note that this is different from just using "Clean".)

Crashlytics file not found

Recently opened a project that I had compiled and submitted to Apple.
I haven't touched it for a couple of months but I'm getting this odd compile error at:
#import <Crashlytics/Crashlytics.h>
The error reads:
'Crashlytics/Crashlytics.h' file not found
Clearly the framework can't be found but I'm puzzled as to why, when the project was working a few months ago, it's suddenly stopped.
Any suggestions why?
Xcode: 4.6.3
Mac OS X: 10.8.4
Just add $(SRCROOT) to the Framework Search Paths in Project Build Settings (Search Paths).
Crashlytics installation process drops its Crashlytics.framework to your project folder (or creates the symlink).
If you moved Crashlytics.framework somewhere deeper in the project folder hierarchy - set 'recursive' to the right or just point directly to its parent folder in Header Search Paths:
$(SRCROOT)/Path/to/the/folder/containing/Crashlytics.framework
Delete frameworks from you project and disk. Check that you have the newest version of Fabric plugin.
Copy frameworks from plugin folder to desktop with this commands:
ditto -xk ~/Library/Caches/com.crashlytics.mac/5b91b14e832a7b1c29441ec5ba109810/sdks/ios/com.twitter.crashlytics.ios-default.zip ~/Desktop/
ditto -xk ~/Library/Caches/com.crashlytics.mac/5b91b14e832a7b1c29441ec5ba109810/sdks/ios/io.fabric.sdk.ios-default.zip ~/Desktop/
Add frameworks from desktop to your project.
Info from: https://twittercommunity.com/t/error-upgrading-from-crashlytics-on-ios/36196/2
I'd recommend just using CocoaPods to add the Crashlytics framework. No need to care about paths anymore.
Podfile:
pod 'Crashlytics', '~> 3.4.1'
Script Build Phase for dSYM Upload:
./Pods/Crashlytics/iOS/Crashlytics.framework/run <your_crashlytics_id>
Import:
#import <Crashlytics/Crashlytics.h>
For me, this worked:
Remove the fabric and crashlytics frameworks from your project, and delete the files from the disk for our project.
Comment the lines in your appdelegate.m file, if you added them for the following:
import Fabric/Fabric.h
import Crashlytics/Crashlytics.h
and
[Fabric with:#[CrashlyticsKit]];
In the fabric app, choose "New app", and select your Xcode project file
Recopy the build script and build as instructed. The build step is why you needed to comment the lines above-- it won't work if you leave those lines in.
After the build script runs, it will prompt you to drag the frameworks from the app window into your project navigator. This will copy the latest versions of he frameworks (which include the .h files) into your project
I have tried manually downloading, and copying from other projects, but this is the only way I could recover after losing the frameworks files for an app.
In my case, the Framework was in the project folder, but not in the Project Navigator. I dragged it to the project and everything worked fine.
I've had this issue working with distributed teams (through github) after checking in then checking out Crashlytics. The Crashlytics.framework will only have one folder inside it -- "Versions". You need to save a version of the contents inside Crashlytics.framework to another location, then copy-paste them into Crashlytics.framework later.
Remove Crashlytics.framework from the project and disk. Copy and add it again. It helped me.
In my case, I was migrating from an old Crashlytics install through the Mac app to Cocoapods. A lot of the answers to this question recommend completely removing everything and starting over. I started doing this and noticed a discrepancy between code found in Fabric's documentation and the code shown in the Fabric app during the step where it tells you what to copy into your Run Script Build Phase.
Fabric's documentation has double quotes surrounding the entire string: "${PODS_ROOT}/Fabric/Fabric.framework/run <Your_API_Key> <Your_Build_Secret>"
The Fabric App only had double quotes around the path to the run executable: "${PODS_ROOT}/Fabric/Fabric.framework/run" <Your_API_Key> <Your_Build_Secret>
So before you delete everything and start over, try updating your Run Script Build Phase to this:
"${PODS_ROOT}/Fabric/Fabric.framework/run" <Your_API_Key> <Your_Build_Secret>
I have changed the name of the working folder and Craslytics fails. Check this in Build Settings (Search Paths).
Good luck!
I have tried to play with the frameworks search path and relocating & reconnecting the framework file; checked the build settings (Link binary with libraries section) but the error persisted.
Finally, I have reinstalled the framework, which only takes 2-3 minutes. The problem might be caused by that you have relocated the Crashlytics.framework to another subfolder from the root directory, but I am not sure about the exact reason.
Delete everything regarding to the Crashlytics
Start crashlytics app, login and select your project
Add run script
Drag & drop the .framework file (I have kept it in the root folder)
Add the import and startWithAPIKey statements back
Completely Remove the Crashlytics Frameworks on your proj include the shell script in App Build Phases Run Script.
Reinstall the Fabric follow the guide,everything will be OK.
I had previously upgraded to Fabric and had no issues. A couple of days later, I reopened the same project and had the missing crashlytics.h file problem.
I couldn't simply reinstall from the plugin due to a non compiling project (I had so many CLS_LOG messages and references to the missing crashlytics.h file in my project, it would have taken a long time to remove them just to allow the build to work - refactor wouldn't work on CLS_LOG).
So instead, I deleted the crashlytics.framework from my project and did the following to reinstate it from the plug in directly:
Download the Fabric plugin again and double click the zip file to unpack the Fabric application.
Right click the Fabric icon and "Show Package Contents"
Copy the Crashlytics.framework folder to your Desktop and then re-add it to your project via File -> Add Files to ....
If step 3 doesn't work for you, you can also add crashlytics.framework to your project folder on your computer directly, and then also add it into your project list via Xcode same as in step 3 but uncheck "Copy Items if Needed" as you already put the files there yourself.
My project then compiled and worked fine again.
In terms of a guess as to why the file went missing? Part of the upgrade process got me to delete the old frameworks and then run the scripts etc. from the plugin. I think what happened is later when I emptied my trash, that some references were lost. I also had the problem where I'd put Crashlytics into my .gitignore file so it disappeared out of ALL my projects every committed which wasn't great.
Hope this helps someone!
I have same error.
Please try pod update
and fix it.
If FirebaseCrashlytics 9.0.0 installed , problem will be fixed.
stalling FirebaseCoreDiagnostics 9.0.0 (was 8.9.0)
Installing FirebaseCoreExtension (9.0.0)
Installing FirebaseCoreInternal (9.0.0)
//hrer
Installing FirebaseCrashlytics 9.0.0 (was 8.9.0)
Installing FirebaseFirestore 9.0.0 (was 8.9.1)
Installing FirebaseInstallations 9.0.0 (was 8.9.0)

Best build dir location to use in Xcode

I'm consolidating my Xcode/TextMate setup and is interested in where you put your build dir.
Some years ago I started out having the build dir in the same dir as my xcodeproj file.
However it became a mess when my project became a multi project with a applications and frameworks and tests, so I started using ../build as the build dir, so that all the sub projects used the same dir. However Spotlight is indexing this build dir and TextMate's global find is unusable when there is a build dir in the project.
I'm thinking either using ~/.build or /build as Xcode's build dir.
What build dir do you use and why?
If you let Xcode create the build directory then it shouldn't get indexed by Spotlight (Xcode sets an extended attribute on the directory specifically to make this happen). If it's a build directory from an old project that been upgraded, or a build directory that you created manually, then this won't be the case and it will get indexed. You can either add this attribute manually if it's missing, or perhaps delete the build directory and let Xcode re-create it. Once you have this sorted out you should be good to go with your common build folder scheme.
The extended attribute is com.apple.XcodeGenerated.

Resources