Change Other Swift Flags gives build error - ios

I'm creating multiple targets for development, test, production, QA etc.. When I do that I want to differentiate this targets by changing "other swift flags". As default, It shows as in below screenshot.
I want to change that "-D" to "Prod". I think because I use Cocoapods, I'm getting build error. My Pods xcconfig file is in below;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '#executable_path/Frameworks' '#loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "Alamofire"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
I'm getting below error
:0: error: unknown argument: '-PROD'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

When you are adding processor macros you have to define them with the prefix -D so, in your need to add -DPROD, like this

Related

No such module 'Alamofire' in Xcode 10

I got the project folder from iOS developer.
I try to 'Archive' this to the app store, but there is an error.
the error is "No Such Module 'Alamofire' ~ "
I've looked at a lot of Stack Overflows.
I think my project has a different directory.
iOS developer can't even ask what the problem is because they haven't been contacted. Who can see what's wrong?
Many of the answers say "podfile," but there is no file named podfile in my project directory, but instead in the pods folder.Only xccconfig files exist.
The project folder structure is
= APPLICATION
== APPLICATION
== APPLICATION Tests
== Pods
and
in pods Folder has two file
( Pods-APPLICATION.debug.xcconfig ),
( Pods-APPLICATION.release.xcconfig )
The content is as follows:
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '#executable_path/Frameworks' '#loader_path/Frameworks'
OTHER_LDFLAGS = $(inherited) -framework "Alamofire"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
it's possible that the project you got doesn't include the Alamofire pod.
open terminal go to the directory of the Project and open the pods w\
open Podfile -a Xcode
check if the Alamofire pod is in the file, if not write the following
pod 'Alamofire'
save the file and write
pod install
in the terminal
if the Alamofire is already in the pod file then type
pod update
in the terminal, and that should solve your problem.
in case your Project doesn't have a Podfile use
pod init
that will create a Podfile in your project directory.

Libtool: can't locate file for: -lPods-RCTMapboxGL

There is a problem at the linking stage of my React Native project. The library libRCTMapboxGL.a is causing this problem.
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-RCTMapboxGL
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-RCTMapboxGL is not an object file (not allowed in a library)
The file libRCTMapboxGL.a is not being created in /Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/ as consequence of the error with -lPods-RCTMapboxGL. However, the files seem to exist:
/Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios/Pods/Target Support Files/Pods-RCTMapboxGL/Pods-RCTMapboxGL.debug.xcconfig
/Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios/Pods/Target Support Files/Pods-RCTMapboxGL/Pods-RCTMapboxGL.release.xcconfig
Pods-RCTMapboxGL is not an object file looks strange in the error message, the content of the files is:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public"
OTHER_LDFLAGS = $(inherited) -ObjC
PODS_BUILD_DIR = $BUILD_DIR
PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}/Pods
The setup was done according this tutorial. Firstly using CocoaPods and then I manually verified if all the settings and files are in place.
Full error log:
Libtool /Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/libRCTMapboxGL.a normal x86_64
cd /Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -L/Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator -L/Users/bobby/Downloads/mapbox-gl-ios-0.2.17 -L/Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios/RCTMapboxGL -filelist /Users/user/Developer/RNProject/ios/build/Build/Intermediates/RCTMapboxGL.build/Debug-iphonesimulator/RCTMapboxGL.build/Objects-normal/x86_64/RCTMapboxGL.LinkFileList -lPods-RCTMapboxGL -o /Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/libRCTMapboxGL.a
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-RCTMapboxGL
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-RCTMapboxGL is not an object file (not allowed in a library)
The problem was that I used pod init inside the MapboxGL directory, which created the extra files. Removing the generated files solved the problem.

Tesseract "_OBJC_CLASS_$_G8Tesseract", referenced from:

<<< xcode linker error message >>>
"_OBJC_CLASS_$_G8Tesseract", referenced from:objc-class-ref in CalendarViewController.o
ld: symbol(s) not found for architecture x86_64
<<< import header file >>>
import "TesseractOCRiOS/TesseractOCR/TesseractOCR.h"
<<< podfile >>>
platform :ios, '9.0'
target 'toeicMap' do
pod 'TesseractOCRiOS', :git => 'https://github.com/gali8/Tesseract-OCR-iOS.git'
end
<<< pod install message >>>
hirata-MacBook-Pro:myMap+pod hirata$ pod install
Analyzing dependencies
Downloading dependencies
Installing TesseractOCRiOS 4.0.0 (was 3.4.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
[!] The toeicMap [Debug] target overrides the CLANG_CXX_LIBRARY build setting defined in Pods/Target Support Files/Pods-toeicMap/Pods-toeicMap.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the$(inherited)` flag, or
- Remove the build settings from the target.
[!] The toeicMap [Release] target overrides the CLANG_CXX_LIBRARY build setting defined in Pods/Target Support Files/Pods-toeicMap/Pods-toeicMap.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the$(inherited)` flag, or
- Remove the build settings from the target.
hirata-MacBook-Pro:myMap+pod hirata$
<<< Target Support Files/Pods-toeicMap/Pods-toeicMap.debug.xcconfig >>>
CLANG_CXX_LIBRARY = compiler-default
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/TesseractOCRiOS"
LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/TesseractOCRiOS" $(inherited) "${PODS_ROOT}/TesseractOCRiOS/TesseractOCR/lib"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/TesseractOCRiOS"
OTHER_LDFLAGS = $(inherited) -ObjC -weak_library /usr/lib/libstdc++.6.0.9.dylib -l"TesseractOCRiOS" -l"lept" -l"stdc++" -l"tesseract_all" -framework "Foundation" -framework "UIKit"
PODS_BUILD_DIR = $BUILD_DIR
PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}/Pods
pod version = 1.0.1
Any help is appreciated!

use_frameworks! Cocoapods, can't find header file for non-cocoapods framework

I am using Cocoapods in my project, but I also want to use frameworks that are not managed by Cocoapods. I recently tried to switch to frameworks using the use_frameworks! command in my podfile, but the result is that the build fails because it can't find a header from my third-party framework. In the xcconfig file for my project, I have FRAMEWORK_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/vendor, which worked in the past (vendor being where the .framework file is stored).
I don't know much about this topic; my attempt at solving this was to add a HEADER_SEARCH_PATHS setting to the xcconfig file with the same settings as the FRAMEWORK_SEARCH_PATHS, which did not solve the problem. Any help would be appreciated.
EDIT: upon further investigation into the problem I think I better understand what is causing this behavior, though I'm no closer to a resolution. The Xcconfig configuration I'm using is set up approximately like this for the debug scheme:
Pods-ProjectName.debug.xcconfig -- the CocoaPods created xcconfig file for the project. Contents are roughly as follows:
FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '#executable_path/Frameworks' '#loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/x.framework/Headers" -iquote "$PODS_FRAMEWORK_BUILD_PATH/y.framework/Headers" -iquote "$PODS_FRAMEWORK_BUILD_PATH/z.framework/Headers" -iquote "$PODS_FRAMEWORK_BUILD_PATH/a.framework/Headers"
OTHER_LDFLAGS = $(inherited) -ObjC -framework "x" -framework "y" -framework "z" -framework "a"
OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-ProjectName
PODS_ROOT = ${SRCROOT}/Pods
ProjectName.xcconfig - contents are as follows:
APPLICATION_EXTENSION_API_ONLY = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/vendor
WARNING_CFLAGS = $(inherited) -include "$(SOURCE_ROOT)/ProjectName/ProjectNameVersion.h"
INFOPLIST_FILE = ProjectName/Info.plist
PRODUCT_NAME = ProjectName
SKIP_INSTALL = YES
ProjectNameDebug.xcconfig - includes both of the prior xcconfig files, is the project's xcconfig file. In case it matters, here's the contents:
#include "ProjectName.xcconfig"
<h1>include "../Pods/Target Support Files/Pods-ProjectName/Pods-ProjectName.debug.xcconfig"
The thing is, what I'm actually seeing when I open the xcporoject file and go to Build Settings->Framework Search Paths is bulid/Debug-iphoneos/Pods-ProjectName. So somehow my vendor search path is getting overwritten.
Apologies for the formatting, SO didn't want to highlight this stuff as code, and in some cases even tried to make it bold...

Cocoapods <RestKit/RestKit.h> not found

I have a really hard time install RestKit into my project using CocoaPods. I get the not found error.
My Pods.xcconfig looks like this:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/AFNetworking" "${PODS_ROOT}/Headers/ISO8601DateFormatterValueTransformer" "${PODS_ROOT}/Headers/RKValueTransformers" "${PODS_ROOT}/Headers/RestKit" "${PODS_ROOT}/Headers/RestKit/CoreData" "${PODS_ROOT}/Headers/RestKit/Network" "${PODS_ROOT}/Headers/RestKit/ObjectMapping" "${PODS_ROOT}/Headers/RestKit/Support" "${PODS_ROOT}/Headers/SDWebImage" "${PODS_ROOT}/Headers/SOCKit" "${PODS_ROOT}/Headers/SSKeychain" "${PODS_ROOT}/Headers/SVProgressHUD" "${PODS_ROOT}/Headers/TTTAttributedLabel" "${PODS_ROOT}/Headers/TransitionKit" "${PODS_ROOT}/Headers/Vendor/LibComponentLogging/Core" "${PODS_ROOT}/Headers/Vendor/LibComponentLogging/NSLog"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/AFNetworking" -isystem "${PODS_ROOT}/Headers/ISO8601DateFormatterValueTransformer" -isystem "${PODS_ROOT}/Headers/RKValueTransformers" -isystem "${PODS_ROOT}/Headers/RestKit" -isystem "${PODS_ROOT}/Headers/RestKit/CoreData" -isystem "${PODS_ROOT}/Headers/RestKit/Network" -isystem "${PODS_ROOT}/Headers/RestKit/ObjectMapping" -isystem "${PODS_ROOT}/Headers/RestKit/Support" -isystem "${PODS_ROOT}/Headers/SDWebImage" -isystem "${PODS_ROOT}/Headers/SOCKit" -isystem "${PODS_ROOT}/Headers/SSKeychain" -isystem "${PODS_ROOT}/Headers/SVProgressHUD" -isystem "${PODS_ROOT}/Headers/TTTAttributedLabel" -isystem "${PODS_ROOT}/Headers/TransitionKit" -isystem "${PODS_ROOT}/Headers/Vendor/LibComponentLogging/Core" -isystem "${PODS_ROOT}/Headers/Vendor/LibComponentLogging/NSLog"
OTHER_LDFLAGS = -ObjC -framework CFNetwork -framework CoreData -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework MobileCoreServices -framework QuartzCore -framework Security -framework SystemConfiguration
PODS_ROOT = ${SRCROOT}/Pods
Podfile like so:
platform :ios, '7.0'
pod 'TTTAttributedLabel'
pod 'SVProgressHUD', :head
pod 'SDWebImage', '~>3.6'
pod 'SSKeychain'
pod 'RestKit', '0.23.1'
My Project settings in in the other linker flags includes:
$(inherited)
And the header search paths does also include:
$(inherited)
"$(BUILT_PRODUCTS_DIR)/../../Headers"
My target configuration is like so:
How can I fix this issue?
In my case this issue was related to pods configuration.
Step to resolve.
IMP: Backup your project before doing any configuration changes.
Find the file where the variable PODS_ROOT is defined in your project. It will be defined under Pods-<Project Name>.debug.xcconfig and Pods-<Project Name>.release.xcconfigfiles.
Reveal/Show both files in Finder , it will be under the folder /Pods/Target Support Files/Pods-<Project Name>/
Delete both files from your project (DO NOT trash, only remove the reference)
Now from your project navigator , open build-debug.xcconfig
Replace the following line ,
#include "../pods-debug.xcconfig"
with the following line,
#include "../Pods-<Your Project Name>.debug.xcconfig"
and in build-release.xcconfig replace the following line ,
#include "../pods-release.xcconfig"
with the following line,
#include "../Pods-<Your Project Name>.release.xcconfig"
Replace the original file pods-debug.xcconfig and pods-release.xcconfig files under your project folder with the files Pods-<Your Project Name>.debug.xcconfig and Pods-<Your Project Name>.release.xcconfig respectively from the folder /Pods/Target Support Files/Pods-<Project Name>/.
Add back the new configuration files Pods-<Your Project Name>.debug.xcconfig and Pods-<Your Project Name>.release.xcconfig to your project.
Confirm both your project and target is referring to pods-debug.xcconfig/pods-release.xcconfig (Select Project File then select 'info' tab, under that expand 'Configurations')
Confirm 'Build Settings/Header Search Paths' contains $(inherited)
Reopen your project and do a clean build.
Explaining the issue
The pod configuration was not properly loaded to your project , to test this you can simply add "$(PODS_ROOT)/test" under 'Build Settings/Header Search Paths', you can see it is resolving to '/test' , that means the variable PODS_ROOT was not defined and hence it is resolving to empty string. That means the config file where PODS_ROOT is defined not loaded to project settings. Now check the config file set in your Xcode project (Select Project File then select 'info' tab, under that expand 'Configurations') it is referring to build.xcconfig and build-debug.xcconfig/build-release.xcconfig. These files includes the pod config files, but the included config files pods-debug.xcconfig/pods-release.xcconfig doesn't contain the required pod config details. So, now we replaced this with correct config file. You can also try copy paste the content of config files so that we can avoid replacing the files.

Resources