React Native xcode project "Header Search Path" - ios

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

Related

No such module 'RxBlocking' in test target

I'm using Carthage for setting up my project's RxSwift dependency. And recently, I tried to use XCFrameworks instead with the command carthage update --platform ios --use-xcframeworks. I've set up all that is needed to be set (eg. changing the .frameworks to .xcframeworks in the Link Binary With Libraries in the targets' Build Phase, etc). It worked and I can run or test in the simulator, until today that is. When I was trying to do the tests this morning, all of a sudden it failed (although it worked fine before) with the error No such module 'RxBlocking'. I've double-checked it and the xcframework has already been built in the Carthage/Build folder, and the xcframework has already been added to the test target's settings.
I've tried all of these but it all failed:
Setting the $(PROJECT_DIR)/Carthage/Build to the Framework Search Paths for the target
Deleting DerivedData/ and/or Carthage/ folders
Resetting the Mac
Can anybody help me to fix this? BTW, I'm on XCode 12.4 and Swift 5. Thanks.
This is actually because of the Apple tools that can't search for the correct Frameworks Search Path. The fix is in this link: https://github.com/ReactiveX/RxSwift/issues/2292#issuecomment-804045119

React native "'AIRMapCoordinate.h' file not found" error

I stuck with a problem with Xcode. I upgraded one package for my react-native project (react-native-track-player#2.0.0-rc13) and after that when I tried to build the project, it does have problems with some headers in the "react-native-maps#0.26.1" package. It shows this error:
'AIRMapCoordinate.h' file not found
I realized that this error happening because Xcode can't find those headers and those headers are in this directory:
$(SRCROOT)/../node_modules/react-native-maps/lib/ios/AirMaps
So I added this path to "Header search paths" but it still can't find those headers. I also delete pods and re-install them and cleaned the project build folder but I still have the same problem.
Do you have any ideas about what goes wrong here?

iOS Cocoapods -pod(MBProgressHUD) installed give error stuck at "Analyzing dependencies" and "Header file missing"

I have installed 2 pods MBProgessHUD and PEPhotocropEditor it's working correctly till now but suddenly I got error for MBProgressHUD.h file not available. And I tried it with pod update and again pod install command but still not able to solve the problem. When I fier both the command terminal stucked at
Analysing dependencies.
and pods are looking in red color.
My problem is solved with following procedure.
1) Take Backup of your Project to other place.
2) open Terminal , and go to your project directory with cd command.
3) first type this command
setup you pod:
$ pod repo remove master
$ pod setup
$ pod install
Note
It takes time. so, don't panic wait for few minuts.
EDIT :-
After completing this all if you find error like
MBProgressHUD.h file not found ( any of pod related header file)
you need to follow this procedure also.
you need to Check if the pod header files are correctly symlinked in Pods/Headers. (All imagae give with correct setting)
WIKI or Cocoapods Troubleshooting gives explaination in brief.
1) If something doesn’t seem to work, first of all ensure that you are not completely overriding any options set from the Pods.xcconfig file in your project’s build settings. To add values to options from your project’s build settings, prepend the value list with $(inherited).
2) If Xcode can’t find the headers of the dependencies:
Check if the pod header files are correctly symlinked in Pods/Headers and you are not overriding the HEADER_SEARCH_PATHS (see #1).
Make sure your project is using the Pods.xcconfig. To check this select your project file, then select it in the second pane again and open the Info section in the third pane. Under configurations you should select Pods.xcconfig for each configurations requiring your installed pods.
If Xcode still can’t find them, as a last resort you can prepend your imports, e.g. #import "Pods/SSZipArchive.h"
Don't need to include below step if only Headerfile missing Error.
Below line and image give for reference if some one can't find proper option.
3) If you're getting errors about unrecognized C compiler command line options, e.g. cc1obj: error: unrecognized command line option "-Wno-sign-conversion":
Make sure your project build settings are configured to use "Apple LLVM compiler" (clang)
Are you setting the CC, CPP or CXX environment variable, e.g. in your ~/.profile? This may interfere with the Xcode build process. Remove the environment variable from your ~/.profile.
~/ .profile location
1)open Settings > General
2) Scroll to the bottom and open Profiles. If you do not see a "Profiles" section, you do not have a configuration profile installed.
In the "Profiles" section, select the profile you wish to remove.
4) If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
![Edit scheme][6]
Add the Pods static library, and make sure it's at the top of the list
Clean and build again.
If that doesn't work, verify that the source for the spec you are trying to include has been pulled from github. Do this by looking in
/Pods/. If it is empty (it should not be), verify that the ~/.cocoapods/master//.podspec has the correct git hub url in it.
If still doesn't work, check your XCode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".
Xcode Build Location Setting:-
If you tried to submit app to App Store, and found that "Product" > "Archive" produce nothing in "Organizer":
In Xcode "Build Settings", find "Skip Install". Set the value for "Release" to "NO" on your application target. Build again and it should work.

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.

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