static library builds in debug configuration but not in release configuration - ios

I get a 'Lexical/Preprocessor Issue "*.h" not found' error when I build for release.
But it builds perfect fine if I set the build configuration to Debug.
I have this static library project in the same workspace, so I am assuming it builds every time I build my project just like CocoaPods.
When I look in the build folder, the .a file is not copied over. But it is there for the debug config. Maybe it is trying to call a header before the static library is built.
I have looked all over stack overflow and I feel like I have tried everything. This is not a duplicate.
I have -ObjC in other linker flags.
I have checked the Prefix Header
Update: The User Header Search Path is "$(BUILT_PRODUCTS_DIR)" both debug and release
Thanks for your help.

For your project target Build Settings, look for "Search Paths->Header Search Path". Compare your Release and Debug settings here.
Also look into the "Build Location" for the library project for Release and Debug.

Related

React Native xcode project "Header Search Path"

Following the steps from React Native official tutorial, the xcode project created by "react-native init MyFirstRNProject" won't compile. It complains "React/xxxxx.h" can't be found.
After further investigation of this xcode project, I figured the "React" target contains a build phase "Copy Headers" which copies all exposed headers into a weird location:
"MyFirstRNProject/node_modules/react-native/React/build/Debug-iphonesimulator/include/React"
OK, cool, at least we got the header location. We can change the copied location to somewhere else that better than this. So whichever the project that do "#import < React/xxxxx.h >" should have above path in "Header Search Path" in build settings. Unfortunately, all projects have "Header Search Path" empty. And that's why I'm getting tons of header not found error.
OK, let's add it. Now it finds headers, but compilation still failed, see reference below:
https://github.com/facebook/react-native/issues/21482
The discussion above saying that removing the "Header Search Path" of the projects will solve the problem. But we know that without header search path, it again can't find React headers.
Just curious now, I don't think my setup is wrong, does anyone has the same issue?
I had the same problem on fresh install of Xcode 10.1
There are few steps to follow to compile the new project after react-native init appName
In Xcode, Select File -> Project/Workspace Settings. You will see a Build System option to select the Legacy Build System as shown below
Change Advanced settings, and set Build Location to Custom and change paths to Relative to Workspace and Build/ to build/Build/ as showed.
3. User Debug for command-line builds(for react-native run-ios to work properly)
Clear your project
After this manipulations(don't need set header search paths) you'll be able to build and run empty project via Xcode or CLI

iOS Linking library in xcconfig

I'm building a library. And I want it to compile and contain another one (which is googleConversion) but I need to do it with xcconfig files (because for some build I want to not include the library for example)
Following: Link binary with static library in xcconfig
So what I did was add in my xcconfig file:
LIBRARY_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0
OTHER_LDFLAGS =$(inherited) -ObjC -L$(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0 -lGoogleConversionTracking
which let me compile without warning, but don't include the library in my .a
the only way I managed to do it is adding the library in the build phase in Link Binary With Library.
But it's not something I can do if I want to be able to automate my different type of builds
It sounds like it should be very simple ;(
Maybe some other configuration is preventing those lines to work?
I tried checking my logs and I can see in my "check dependencies" in Libtool export path I can see the resolved path of my OTHER_LDFLAGS (which disapear when I remove it from my xcconfig) but not the -lGoogleConversionTracking which exist when I put my lib in the build phase.
(I have more things happening, like nothing in libtool if I completly remove the panel from the build phases, but it could make sense in a way and it's not a big deal)
Thank you in advance!
Finaly got it!!!!
It because of an old xcode bug that was solved in xcode 6.
https://tarunsharmaios.wordpress.com/2014/09/12/xcode6-static-library-linking-broken/
BlockquoteXcode will no longer pass options in the build setting OTHER_LDFLAGS to libtool when building static libraries, nor will it pass options in OTHER_LIBTOOLFLAGS to the Mach-O linker when building any other kind of product. Previously all options in both settings would be passed to both tools. Make sure that options are in the correct build setting for the product type, static library, or other component being built. (4285249)
In my case it looks like:
LIBRARY_SEARCH_PATHS = $(inherited) "${SRCROOT}/thirdparties/CardIO-5.1.0"
OTHER_LDFLAGS = $(inherited) -ObjC -lz -lc++ -lCardIO
But my libs placed inside source folder in a same level with the *.xcodeproj-file.
I think that paths with "\..\" won't work for xcode.
This issue can be resolved with a script phase in your scheme.
Open your scheme via Product->Scheme->Manage Schemes.
Add the New run script action in the Build->Pre-actions
Script should copy file libGoogleConversionTracking.a to the ${SRCROOT}
Set new path for a LIBRARY_SEARCH_PATHS in *.xcconfig file

Frameworks and Libraries missing on the SVN checkout, XCode 5

I checkout a version from SVN, but when i run the project it shows Linker errors and missing frameworks. I solved the problem by adding again the frameworks and missing '.a' files from the folder to Build Phases-> Link Binary with Libraries and also I cleared the Library search path and Framework search paths to make the project run.
But when I checkout from SVN each time I encounter these same errors, how to set the relative path for the Libraries and frameworks. Every member of the project is encountering the same error when they checkout on their Mac machine. How to resolve this error.
Any help is appreciated.
In the below screen the search path shows only the local path, how to change it to absolute path so that every time it can fetch from XCode itself.
Click on 'Framework Search Paths' and make changes as shown in below image.

Archiving xcode project that contains static library

I created a project with static library.
When I tried to archive, It fails and library Headers are missing.
But when I build the app, it works fine.
And in build folder headers, bundle resources and library are created outside app file.
Is it possible to create these file in app file and archive
or any other process available for archiving?
Thanks in advance.
If you are able to build the app but not archive then it seems that the build settings that you are using for archive build configuration (probably Release) is not correct. Quick test will be to change the build configuration for archive to same as build, most probably Debug (you can do that in Product->Scheme->Edit Scheme).
To fix this you can open the Build Settings for your target, search for "Header Search Path", click the ">" to open this setting and fix it for the build configuration that is used by archive (i.e. make it same as the build configuration used by Build)

xcodebuild failure clang:error no such file or directory:

Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.
The error is:
clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'
This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:
~/Library/Developer/Xcode/DerivedData
Any ideas?
To fix this, go to your project settings, go to Targets and select your main project target. Then go to Build phases. Under Target dependencies add the static library project.
This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.
I had the same problem, but for a resource file .m
I opened target -> build phases -> Compile sources
and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)
For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.
In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.
In Target > Build Phases > Compile Sources each of the duplicates showed with no "...in" after them. Each one caused the clang error.
After removing all of the duplicates that Xcode collected, the project compiled and ran.
It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder). 🤨
My xCode info is:
I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:
clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
clang-4.0: error: cannot specify -o when generating multiple output files
others
Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.
Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:
as you can see the InstalledDir is incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered.
To fix this problem (in my case that I will not need anaconda any more): (edited)
1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner).
2.- Re-install xCode
After reinstalling xCode, if you type again clang --version, you'll get this:
More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092
Hopefully, this info helps some else.
Best
Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...
Sometimes Xcode performs weird.
You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.
I had the same problem while I was archiving my target. I removed the library and the build succeeded.
For me it was because I had removed a package or pod. I ran pod install and it fixed it
Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.
add the missing files to the xcode, then everything will work fine.
Run this command :
$ conda deactivate

Resources