Xcode Archive won't find header file in subproject - xcode

So frustrated with XCode right now. I can build and run from code perfectly fine. However, trying to archive is a disaster.
I created a project, then dragged the .xcodeproj into XCode on the project navigator. Shows up fine, cool. Parent project build settings:
Other linker flags: -all_load, -ObjC
Target Dependencies : CocoaLibSpotify (subproject I'm incorporating)
Link Binary with Libraries : libCocoaLibSpotify.a
When I build my project, the following lines work
#import "CocoaLibSpotify.h"
#import <CocoaLibSpotify.h>
However, when I archive, my project fails to find these files. It's worth noting that the subproject files aren't in the same directory as the parent project. However, isn't that the point of the target dependency/link binary with library? Why is it failing to archive? This seems like it should be a lot easier than it's being.
Thanks.
Edit: Errors from compiling
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/AppDelegate.m:12:
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/GUI/ViewControllers/LoginViewControll er.h:9:
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/GUI/BaseViewController.h:10:
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/Model/Managers/Managers.h:9:
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/Model/Managers/AppLogicManager.h:11:
In file included from /Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/Model/CoreData/CoreDataObjects.h:13:
/Users/ericharmon/Projects/teamsync/teamsync/TeamSync/Classes/Model/CoreData/Track.h:13:9: fatal error: 'CocoaLibSpotify.h' file not found
#import <CocoaLibSpotify.h>
^
1 error generated.`

Archive uses a different directory structure when building, which can be a pain. I've found success by adding the following to the User Header Search Paths build setting of your application's target:
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include" (including the quotes).
Also, make sure Always Search User Paths is set to Yes.
In addition, I have $CONFIGURATION_BUILD_DIR/include in my Header Search Paths setting, but I don't think that'll help archiving.

Related

Issue with build "dlib" to Xcode

I have to try to use dlib for my project.
However, when I try to build it, I receive a message about:
"_USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives"
For solving this issue
I tried to add it new project
I deleted every existing path or data
I tried to build it on "Release mode"
I have still receive a message:
"_USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives"
Please, solve my curiosity!
You can check the link for dlib integration. Also check the following things for configuration.
1.Header search path for the lib folder. for e.g. $(PROJECT_DIR)/lib where lib folder contains libdlib.a and dlib header files.
2.Check the Preprocessor macros in build setting whether properly
set or not.
3.Create the Objective c++(change .m to .mm extension) wrapper class which can execute both c++ and objective c code.
*Note import dlib header files in wrapper class not in the main.m or app-delegate otherwise it will gives error.
Also check the Reference.

MBProgressHud Swift Compile Error when Archiving

I already finished my project, it works and runs perfectly on the simulator or in my own device. When I select to Archive the project to upload de build to Itunes Connect, I get all these compile errors
"Use of undeclared type MBProgressHUD"
"Use of unresolved identifier MPProgressHUD"
And so on..
NOTE: I'm using CocoaPods for this library
What solved it for me was adding import MBProgressHUD in the classes where I use this library, not only in the Bridge-Header.h
Navigate to your project build settings and find the “Swift Compiler – Code Generation” section (You may find it faster to type in “Swift Compiler” into the search box to narrow down the results)
Next to “Objective-C Bridging Header” you will need to add the name/path of your header file. If your file resides in your project’s root folder simply put the name of the header file there. Examples: “ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.
Refer this link http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/
Welcome to Cocoapods Hell (a.k.a. : where the magic ends), where one must dive into his project build settings and make sense of what went wrong...
It's very hard to answer to you, as any number of reasons might be causing that.
Do you use the same target for Build / Run & Archive ? It might be because your libPods.a isn't copied into your Archive target
Have you installed Pods using pod install , have you tried playing that command again. (yes, faced with magic going wrong, one can sometimes rely on magic to save him again)
'Build' and 'Archive' product often differ in the build configuration they use (Build most of the time uses 'debug' configuration, while Archive uses 'release' configuration... ). Check your Pods configuration files (debug/release) and make sure they both include your MBProgressHud. Also, in your Project 'Info', check which pods Xcode configuration files are selected for 'debug' and 'release'
Good luck !
(PS : as MBProgressHud is a single file, and one you can often change, another solution is to get rid of Cocoapods and just copy/paste it)

Cannot include files from /usr/local/include even though they are present

I'm not able to compile a project under Xcode Version 4.6.3 (4H1503) when using files located in /usr/local. The error is 'cryptopp/cryptlib.h' file not found. This is similar to a number of other questions, but the 'try this' mentioned in the other topics have not helped.
I have a directory with headers in them. The directory is /usr/local/ios-armv7/include. Within that directory the headers are located in cryptopp/. I am including the files with both #include <cryptopp/cryptlib.h> and #include "cryptopp/cryptlib.h".
In Xcode, I have /usr/local/ios-armv7/include and /usr/local/ios-armv7/include/cryptopp set in every place that will take a path for headers or include files. There are no target overrides. I verified the paths are being added to the command line through -I switches.
I've tried toggling ALWAYS_SEARCH_USER_PATHS. I've tried toggling recursive. I've also tried adding and removing the trailing slash (/). In between each attempts, I perform a full clean. I also used Organizer to remove all data. I even tried using a different compiler (GCC-4.2, which appears completely broken).
What is the trick to get Xcode to honor my search path?
Wow...What a pain. I just figured it out (was fighting this same issue for some time).
It looks like there are two sets of settings, one for the project, and one for the target.
Look to the left of your build settings pane. If you have the project highlighted, hit the 'targets' icon, and then you'll see there is another set of build settings. As soon as I added '/usr/local/include' to my 'Header Search Paths' section, it found the external headers.
I tracked this problem down to permissions on usr/local/ios-arm7. The permissions were 0600. I'm not sure how/why Finder was able to view them since I did not have permission. After chmod -R 0644 usr/local/ios-arm7, everything worked as expected. I could also remove all the extra paths I threw at the project.

Xcode 4.2 — add derived files to project

I'm using bison parser generator in my Xcode 4 project. I've written custom build rule for generating C++-source file from *.y grammar file:
/usr/local/bin/bison
--defines="${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.hpp"
--output="${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.cpp"
--verbose "${INPUT_FILE_PATH}"
As you can see, Xcode places generated files in $DERIVED_FILES_DIR folder. Now I need to export generated header file grammar.hpp with object files as library.
The problem is that Xcode doesn't allow export files, that aren't included in project.
The first solution, as it seems, is to create a group with absolute path set to $DERIVED_FILES_DIR. Well, it actually works until I change my build settings to build Release configuration, since $DERIVED_FILES_DIR is dependent on build settings.
The second solution is somehow set group path to literally variable, i.e.
path = $DERIVED_FILES_DIR
So far I've found two possible ways to do it: How to reference files with environment variables? and File references relative to DERIVED_FILE_DIR in Xcode. Either way doesn't work for me.
Maybe someone knows better way to add generated files to project?
Your best options are:
Generate the files in your SRCROOT
Generate the files in BUILT_PRODUCTS_DIR
These both have "Relative to..." options that should allow you to add the files to your project.
I ended up generating files in ${SRCROOT} directory with custom make build target using Makefile that handles regenerating derived files. I just added these generated files to project, and made all actual build target depend on this make target.

OCMock test fails to build: Foundation/Foundation.h : No such file or directory

I am a Xcode beginner, and am facing some problems in compiling an OCMock test. I have added the OCMock.framework in "Groups & Files", and then added a very basic OCMock test from the Unit testing target, basically for Canary testing.
When I compile the OCMockTests.m file, the system returns around 38 errors pointing out all the imported headers that is in OCMock.Framework files to be non-existent, and in the top comes "Foundation/Foundation.h : No such file or directory". But when I compile the OCMock.Framework, then everything succeeds. I tried replacing Foundation.h with NSObject.h, but the system is not even able to find that.
I reckon it is some linker error....the system is somehow probably not able to get the location of Sentest.Framework. BTW, I have updated the Executable info - environment variable - DYLD_FALLBACK_FRAMEWORK_PATH with the correct (?) Sentest framework path (the argument is "-Sentest All"), that is of the IphoneOS folder.
Need your advices...thanks a bunch.
~ Sayan
See Colin Barrett's "OCMock and the iPhone" tutorial.

Resources