failed to find protobuf header file - protobuf-c

I pod Protobuf-C++ in my ios app, but build failed, build error log looks like this
- NOTE | [iOS] xcodebuild: Protobuf-C++/src/google/protobuf/io/zero_copy_stream.cc:35:10: fatal error: 'google/protobuf/io/zero_copy_stream.h' file not found
- NOTE | [iOS] xcodebuild: Protobuf-C++/src/google/protobuf/wrappers.pb.cc:4:10: fatal error: 'google/protobuf/wrappers.pb.h' file not found
anyone knonw how to fix this ? my protobuf version is 3.11.3

problem like this
'google/protobuf/any.h' file not found
'google/protobuf/arena_test_util.h' file not found
'google/protobuf/util/delimited_message_util.h' file not found
maybe other file not found.
the way to fix it:
way to fix
1. select 'Pods'
2. select 'Protobuf-C++'
3. select 'Build Settings'
4. search 'search path'
5. select 'Header Search Paths'
6. add '$(SRCROOT)/Protobuf-C++/src'

It works for meļ¼Œthanks a lot! #Rome
i also checked podspec file of Protofbuf, it has missed this config but others does "xcconfig":
{
"HEADER_SEARCH_PATHS": "$(PODS_ROOT)/SQLCipher",
......
}
which looks like same to your solution

#Rome's solution is quite helpful, but after a pod install, I have to do the same thing again manually. So I try to improve it and with this solution, no extra work is needed.
Put the following code in your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
# print "target=", target, "\n"
if target.name == "Protobuf-C++"
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = '$(SRCROOT)/Protobuf-C++/src'
end
end
end
end
In addition, if you have some C++ code that uses protobuf (i.e. includes it), you may also need to do the following in your xxx.podspec:
s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '$(SRCROOT)/Protobuf-C++/src',
}

Related

Configure ac code fails to detect libXI presence

I am currently executing the configure script of gtk. It tests for the presence of XInput, and it stops the execution with the error message:"configure: error: *** XInput2 extension not found. Check 'config.log' for more details.
Looking at config.log, it says "configure:23050: error: *** XInput2 extension not found. Check 'config.log' for more details."
So, the same except for the line number.
Then I decided to look at configure.ac. There I found the full Xi detection test that it is:
if $PKG_CONFIG --exists "xi" ; then
X_PACKAGES="$X_PACKAGES xi"
GTK_PACKAGES_FOR_X="$GTK_PACKAGES_FOR_X xi"
AC_CHECK_HEADER(X11/extensions/XInput2.h,
have_xinput2=yes
AC_DEFINE(XINPUT_2, 1, [Define to 1 if XInput 2.0 is available]))
gtk_save_LIBS="$LIBS"
LIBS="$LIBS -lXi"
# Note that we also check that the XIScrollClassInfo struct is defined,
# because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(), but not the XIScrollClassInfo struct.
AC_CHECK_FUNC([XIAllowTouchEvents],
[AC_CHECK_MEMBER([XIScrollClassInfo.number],
have_xinput2_2=yes
AC_DEFINE(XINPUT_2_2, 1, [Define to 1 if XInput 2.2 is available]),
have_xinput2_2=no,
[[#include <X11/extensions/XInput2.h>]])])
LIBS="$gtk_save_LIBS"
if test "x$have_xinput2_2" = "xyes"; then
X_EXTENSIONS="$X_EXTENSIONS XI2.2"
else
X_EXTENSIONS="$X_EXTENSIONS XI2"
fi
fi
AS_IF([test "x$have_xinput2" != "xyes"],
[AC_MSG_ERROR([*** XInput2 extension not found. Check 'config.log' for more details.])])
I am no expert about setting configure.ac, but I thought that this line: "if $PKG_CONFIG --exists "xi" ; then" would be satisfied by this parameter that I pass to configure:
PKG_CONFIG_PATH=:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/lib/pkgconfig/
Also this line:
AC_CHECK_HEADER(X11/extensions/XInput2.h,
have_xinput2=yes
AC_DEFINE(XINPUT_2, 1, [Define to 1 if XInput 2.0 is available]))
could not have been satisfied by this parameter that I pass to configure?
CPPFLAGS=-I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/include/
I am a bit lost as to why it doesn't detect nothing.
A curious point that I read in the documentation is that there is a parameter called: --disable-xinput.
Well I am passing it to configure and it obviously didn't disable the test. So I would appreciate any suggestions about how to change the test to try to figure out what is wrong with it (or with my system)
Solution found
If I replace:
if $PKG_CONFIG --exists "xi" ; then
on configure.ac, by:
if $PKG_CONFIG --print-errors --exists "xi" ; then
and then execute autoconf, it will generate a new configure based on this "new" configure.ac that will print all the required libraries that should be passed to configure.
First it was the .pc file of libXi, then the pc. file of Inputproto (that I had to download and install) an so on. I also really had to add libXi's include dir to CPPFLAGS, so it could find XInput2.h.
My final configure command was:
LD_LIBRARY_PATH=/media/34GB/Arquivos-de-Programas-Linux/Glib-2.41.2/lib/ CPPFLAGS="-I/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/include/ -I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xorgproto-2018.1/include/ -I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/include/" LDFLAGS="-L/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/lib/" ./configure --prefix=/media/34GB/Arquivos-de-Programas-Linux/Gtk+-3.4.0 PKG_CONFIG_PATH=/media/34GB/Arquivos-de-Programas-Linux/Glib-2.41.2/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Atk-2.15.4/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.30.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Pixman-0.18.4/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Fontconfig-2.8.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Freetype-2.2.1/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Png-1.2.14/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xi-1.5.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Inputproto-1.5.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xorgproto-2018.1/share/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xcb-1.4/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Pthread-stubs-0.1/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xau-1.0.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/xorg/Xext-1.1.1/lib/pkgconfig/

Patch a C header file in sysroot?

I am trying to compile an apps. The compilation failed with this error below.
recipe-sysroot/usr/include/linux/stat.h:59:2: error: declaration does not declare anything [-fpermissive]
| 59 | __s32 __reserved;
This can be easily fixed by modifying __s32 __reserved into __s32 reserved in the stat.h file.
Now I want to make a "proper fix" of this C header file in sysroot. Note that I have figured that my stat.h file (and sysroots files in general) is a hardlink. Considering the last statements, is a patch the way to fix my issue? If so, how to patch a sysroot file?
Thank you
No, we can't patch sysroot.
However i let the original code an I just added the following in my .bb recipe:
TARGET_CFLAGS += " -fpermissive "

CoreML in Cocoapod (pod spec lint won't work)

I am attempting to update my cocoapod. Since the last update, I have added a .coreml file and not when I try pod spec lint, I am getting some errors. Things I've done:
Added s.resources = "JacquardToolkit/**/*.mlmodel" to my .podspec file
There was also a few name changes with my .coreml file. Ultimately I want to include only ForceTouch.coreml, so I also need help to get rid of the references to Forcetouch.coreml and ForceTouch2.coreml.
Here is the error message I get in terminal...
try this:
add the MLModel to your spec.source_files in your podspec:
spec.source_files = 'Classes/**/*.{swift,mlmodel,mlmodelc}'
You may also need this if it fails to compile because codegen language is not set:
spec.xcconfig = {'COREML_CODEGEN_LANGUAGE' => 'Swift', 'COREML_CODEGEN_SWIFT_GLOBAL_MODULE' => 'NO'}

CommonCrypto for Framework in podspec

I am going mad on how could I make this podspec work.
I'm developing a swift framework, CommonCrypto is needed. After many problems to make it work for every for every teams (Cordova, React), this is how CommonCrypto is implemented :
I got an aggregate target CommonCryptoModuleMap with a run script in its build phase :
if [ -d "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap" ]; then
echo "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap directory already exists, so skipping the rest of the script."
exit 0
fi
mkdir -p "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap"
cat <<EOF > "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap/module.modulemap"
module CommonCrypto [system] {
header "${SDKROOT}/usr/include/CommonCrypto/CommonCrypto.h"
export *
}
EOF
But now, the goal is to implement it as a dependence of another Framework in Swift. So I have to specified the target dependency in the podspec.
I got no problem to build or archive it from Xcode.
Here is my Podspec :
Pod::Spec.new do |s|
s.name = "AFrameworkHasNoName"
s.version = "0.1.5"
s.summary = "Foo bar"
s.homepage = "https://github.com/MyRepository_ios"
s.license = "License"
s.author = { "Veesla" => "valentin.cousien#gmail.com" }
s.source = { :git => "git#github.com:MyRepository_ios.git", :tag => "develop" }
s.swift_version = "4.0"
s.platform = :ios, "8.0"
s.requires_arc = true
s.exclude_files = "AFrameworkHasNoNameTests/*"
s.source_files = "AFrameworkHasNoName/**/*.{h,m,swift}"
s.module_name = "AFrameworkHasNoName"
end
Here is the error :
- WARN | source: The version should be included in the Git tag.
- WARN | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
- WARN | url: The URL (https://github.com/MyRepository_ios) is not reachable.
- WARN | [iOS] license: Unable to find a license file
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- ERROR | [iOS] xcodebuild: MyFileImportingCommonCrypto.swift:10:8: error: no such module 'CommonCrypto'
Thanks for your responses
Nevermind, It seems like I'm not the only failing to include CommonCrypto in a SDK included in another SDK.
I just bypass the problem by including CryptoSwift (using only pure Swift). It works perfectly for me. It's a bit heavy but you don't have to deal with modulemap files and C library... Pretty easy to work with, nice implementation
Here the link of CryptoSwift : https://github.com/krzyzanowskim/CryptoSwift
Hope it will help one of you !
PS : can anyone explain me why did I get down voted ? :(

access parent project OTHER_SWIFT_FLAGS from pod

Building a custom pod for a private framework, in my main project i use custom OTHER_SWIFT_FLAGS.
In theory it should be possible to override the settings of the pod during the install based on the main project but there is no documentation on how to do so.
So far my attempts failed, any hint?
Looks like project(https://guides.cocoapods.org/syntax/podfile.html#project) should be the way to go but again, no documentation.
So basically it looks like this.
Accessing the xcode project, then accessing the pod and looping through each config to set the proper value.
post_install do |installer|
require 'xcodeproj'
project_path = 'pathTo/myProj.xcodeproj' # path to your xcode project
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
if target.name == 'myTarget' # name of the target in your main project containing the custom flag
installer.pods_project.targets.each do |podTarget|
if podTarget.name == 'myPod' #name of your pod
target.build_configurations.each do |targetConfig|
podTarget.build_configurations.each do |podConfig|
podConfig.build_settings["OTHER_SWIFT_FLAGS"] = targetConfig.build_settings["OTHER_SWIFT_FLAGS"]
end
end
end
end
end
end