failed to emit precompiled header in Xcode 10.1 - swift4.2

I have updated the code from swift3 to swift4.2 and I was getting warnings so I updated the podfile by reinstalling all the pods and now I am getting the error as:
failed to emit precompiled header '/Users/palak.garg/Library/Developer/Xcode/DerivedData/mySocialChemist-gtbbctpiuhpyzngmqbevmscwbcet/Build/Intermediates.noindex/PrecompiledHeaders/mySocialChemist-Bridging-Header-swift_14WYMBJ6PJP8W-clang_38EYTCGHX7TO1.pch' for bridging header '/Users/palak.garg/Desktop/Code/April current project/Send-a-Script---IOS 2 2 2/mySocialChemist/Classes/mySocialChemist-Bridging-Header.h'
Where mysocialChemist is my project name and mySocialChemist-Bridging-Header.h is bridging header file. Also Showing Recent Messages:
/Users/palak.garg/Desktop/Code/April current project/Send-a-Script---IOS 2 2 2/mySocialChemist/Main/mySocialChemistAppDelegate.h:16:9: 'Braintree/BraintreeVenmo.h' file not found
Where Braintree/BraintreeVenmo is pod I used.
Also, I am getting a warning at the terminal where I updated the pod as shown in the following screenshot:
I tried the following points but nothing worked for me:
I uninstall the pods and reinstall then clean and build the project but nothing worked.
Also in Xcode > Product > Scheme > Edit Scheme > Build options both are checked as shown in image.
Clean the derived data and build the project.
Target > Build Settings > Swift compiler - Custom flag > Other swift flags set $(inherited) as in image.
Target > Build Settings > preprocessor macros set $(inherited)as shown in image
Thanks in advance.

Related

Compile in Xcode Prefix.pch not found

I am a beginner in react-native. I tried to compile the apps, ran the pod install (because I used cocoapods I have to do this, I guess), and opened the generated xcworkspace. After I hit the compile button, this error show up
Showing All Messages
No such file or directory: '/Users/<username>/Library/Developer/Xcode/DerivedData/<project name>-bvczmgvzvgwjpyfsmvczxliopbfo/Build/Intermediates.noindex/PrecompiledHeaders/SharedPrecompiledHeaders/7446126693023229553/Prefix.pch'
The xcconfig file I used already had GCC_PREFIX_HEADER and targeted on correct file. It stated like this
GCC_PREFIX_HEADER = $(SRCROOT)/ExportedProject/Classes/Prefix.pch;
I checked my project's configurations using target "Release" and it pointed to the correct xcconfig file.
I searched around and found this SO. I checked on my Build Settings > Apple Clang - Language - Prefix Header, and it also targeted on the correct path and has the Precompile Prefix Header filled with "Yes".
I tried to use pod-deintegrate; reimport the project; deleted the project and use react-native upgrade, but nothing works.

1196 Duplicate Symbols for architecture React-Native

I tried building my project after doing some updates to my fbsdk, after removing errors for fbsdk related errors, this happens. I tried building to test out the updates but this happens.
This is the error https://i.imgur.com/vdJzHbz.png
I tried commonblocks to No, target.name ==" React" remove from project
Maybe someone can help me solve this.
Open Xcode > Pods > Targets Support Files > Pods-{TARGET-NAME} find
"OTHER_LDFLAGS" and remove only "-ObjC" in these two files:
Pods-{TARGET-NAME}.release.xcconfig &
Pods-{TARGET-NAME}.debug.xcconfig
Go to project main target > Build Settings > Other Linker Flags:
Make sure no "-ObjC" is left in the value
deleted the build/Build folder in ios and run-ios again. maybe It will works
.

Xcode: ld: library not found for -lAFNetworking

Because of this one reason, build always fails...Any ideas about what I could try?
EDIT: the solution is to open the xcworkspace instead of the xcproject!
Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file.
Have the same issue.
What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1 and Adlair Cerecedo-Mendez
Delete the "Pods" project on the left panel of Xcode.
Close Xcode and delete this file in the finder too.
Install pods again.
Open Xcode and clean.
Verify that the build option "Build Active Architecture Only" is set to "NO" for your project but also for your Pods project (selection with left panel).
Click on your project Scheme (top, near the stop button) and "Manage Scheme".
Check, select all your pods libraries and close.
Then, for all libs, select them (scroll the list) and build manually for the selected architecture.
Every time you change your architecture (simulator, device or for archive(Generic iOS Device)) you must do the above step: namely, manually build each libraries by selecting them in your scroll list one by one, and only than build and run your main project.
Seems a bit WTF, but it is the only way I resolve this issue...
I Had this Issue several Times with PODS Libraries.
Here is something you can Try:
Run pod cache clean --all and pod install again.
Check your Header Search Paths and Library Search Paths, Remove all entries and place $(PROJECT_DIR) in recursive mode and $(inherited) as a Second Entry
Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.
Make sure Build Active Architecture Only is set to NO in the Pods project settings.
I'm thinking on two possibilities:
1) Install cocoapods-deintegrate project:
$ gem install cocoapods-deintegrate
Then run $ pod deintegrate, after that run $ pod install again. If it not works, then...
2) You can try open your Pods project and create new scheme for the target that you need, in this case for AFNetworking.
When the static library is created, then add it to your Frameworks references into your main project.
Hope that helps.
I have in project->TARGETS->Build Phases ->Link Binary With Libraries one "extra" framework that remains from recent project. Delate it and all run smoothly
Had a similar issue ... took a while to realize that I had updated my app's "iOS Deployment Target" to iOS 9.0, but the Pods project's "iOS Deployment Target" was still iOS 8.0!!!
I encountered this error when I downloaded some code from github. I tried to build .xcodeproj file but it failed giving the library not found error. I then opened .xcworkspace file and build that file first by clicking Product -> Build for -> Running. The workspace file built fine with no errors. Then in workspace file I changed scheme to the xcode project I was trying to build, and clicked Product -> Run. The app got built and ran with no errors.
I had this issue while using fastlane with a ReactNative project. I had added a dependency that required cocoapods.
My Fastfile looked like this:
...
gym(
scheme: "AppName",
project: "./ios/AppName.xcodeproj"
)
....
And had to change it to the workspace like this:
...
gym(
scheme: "AppName",
workspace: "./ios/AppName.xcworkspace"
)
...
For me all this thing not help. Only delete in Build settings project.
open xcode, from the top left select the pod library that is being shown as not found.Use 'Command B' to build this pod, then again select your target scheme and run.
For me this fixed it.
Use the xcworkspace to build instead of the xcproject?
This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries.

The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig

I have incorporate SpatialIite into a Xcode project which uses a header file from Proj.4, just one header. Both are Xcode projects and have static targets.
I'm trying to migrate from git submodule to Cocoapods. Since static targets seems to be difficult to use with Cocoapods, I just want to have the project built in the usual way. I made podspec for Proj.4. After writing podfile for SpatialLite I got the warnings:
[!] The target `SpatialiteIOS [Debug]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug]` overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug - Release]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug - Release]` overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
I read this issue but I'm pretty clueless to what the warnings mean and what can I do to fix it.
Additionally problem, when I open the workspace as well as opening SpatiaLite project alone, both are targeted to Mac OSX 64, when it is suppose to be an iOS project. My podfile does say "platform :ios".
This definitely works most of the time:
Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.
If you have problem with "...target overrides the GCC_PREPROCESSOR_DEFINITIONS build setting defined in..." then you must add $(inherited) to your target Build Settings -> Preprocessor Macros
There is a conflict between your build settings and the default build settings that Cocoapods wants. To see the Cocoapods build settings, view the .xcconfig file(s) in Pods/Target Support Files/Pods-${PROJECTNAME}/ in your project. For me this file contains:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/Commando"
OTHER_LDFLAGS = -ObjC -framework Foundation -framework QuartzCore -framework UIKit
PODS_ROOT = ${SRCROOT}/Pods
If you are happy with the Cocoapods settings, then go to Build Settings for your project, find the appropriate setting and hit the Delete key. This will use the setting from Cocoapods.
On the other hand, if you have a custom setting that you need to use, then add $(inherited) to that setting.
I've seen these 3 errors for pod command in terminal
pod install
[!] The MY_APP [Debug/Release] target overrides the
HEADER_SEARCH_PATHS ...
[!] The MY_APP [Debug/Release] target
overrides the OTHER_LDFLAGS ...
[!] The MY_APP [Debug/Release] target
overrides the GCC_PREPROCESSOR_DEFINITIONS ...
All these 3 errors would be gone by adding $(inherited) to
Header Search Paths
Other Linker Flags
Preprocessor Macros
in Project -> Target -> Build Settings
And now the command would run without giving any errors
pod install
Just had a similar issue when I ran pod install, I saw the following warnings/errors (related to CLANG_CXX_LIBRARY):
The Error/Warning from Cocoapods
[!] The `Project [Debug]` target overrides the `CLANG_CXX_LIBRARY` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Project [Release]` target overrides the `CLANG_CXX_LIBRARY` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
The Fix
Select your Project so you can see the Build Settings.
Select your Target (AppName under Targets)
Find C++ Standard Library (It will probably be in BOLD - This means it's overridden).
Select the Line (So it's highlighted Blue), and press ⌘ + DELETE (Command + Backspace)
The line should not be bolded anymore and if you run pod install the warnings/errors should have disappeared.
Visual Aid
In your project, find Target -> Build Settings -> Other Linker Flags, select Other Linker Flags, press delete(Mac Keyboard)/Backspace(Normal keyboard) to recover the setting. It works for me.
Example:
Before
After
For me the problem was with my targets tests. I already had the $(inherited) flag in my main app target.
I added it to MyAppTests Other Linker flags. After that when I ran pod install the warning message was gone.
If Xcode complains while linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static library
Clean and build again
The first line of link below saved my day:
To add values to options from your project’s build settings, prepend the value list with $(inherited).
https://github.com/CocoaPods/CocoaPods/wiki/Creating-a-project-that-uses-CocoaPods#faq
Also, do not forget to insert this line at the beginning of your pod file:
platform :iOS, '5.0'
I added $(inherited) but my project was still not compiling. For me problem was flag "Build for active Architecture only", I had to set it to YES.
Xcode Screenshot
Ankish Jain had the answer that worked for me. Here is a screenshot of what to do, as it took me a little bit to find out what exactly to do.
In my case i needed to add $(inherited) to my 'Other Linker Flags' because that is what showed up as Overriding in terminal.
do not forget to insert (or unCommanet) this line at the beginning of your pod file:
platform :iOS, '9.0'
that saves my day
This happens to me every time I add a pod to the podfile.
I constantly try and find the problem but I just go round in circles again and again!
The error messages range, however the way to fix it is the same every time!
Comment out(#) ALL of the pods in the podfile and run pod install in terminal.
Then...
Uncomment out all of the pods in the podfile and run pod install again.
This has worked for me every single time!
When I added the $(inherited) flag to the file in question (in this case it was LIBRARY_SEARCH_PATHS) it led to another error Undefined symbols for architecture arm64: "_swift_getTypeByMangledNameInContextInMetadataState
Changing the following worked and I was able to build:
>LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
- "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", <--- Change this...
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.2/$(PLATFORM_NAME)\"", <--- to this
"\"$(inherited)\"",
> );

In Xcode, how to suppress all warnings in specific source files?

In my application I use 3rd party code that triggers some warnings. I reviewed them and they can be safely ignored.
Now I want to "mark" a file somehow, so Xcode won't show any warnings for the code in that file.
How should I do that?
Select your target and show Build Phases. Then enter the name of the file in the search box, and you should see it listed in the Compile Sources phase. Double-click in the Compiler Flags column for that file and enter -w to turn off all warnings for that file.
Select Project in left navigator and select target go to build phase and Put -w in Build Phase of target file. It will hide all compiler warnings
This works for Xcode 10.2+ and Swift 5
Manual fix:
Add -w -Xanalyzer -analyzer-disable-all-checks to the problematic file from Xcode > Project > Targets > Compile Sources > Double click the file where you want to turn off warnings.
Cocoapods Fix:
If you're trying to suppress warnings from a problematic pod, you can automatically suppress all warnings from the dependency with the inhibit_warnings flag in your podfile:
pod 'Kingfisher', '~> 4.6', :inhibit_warnings => true

Resources