All the information I can find, regarding Xcode and library headers, seems to be some manual steps like copying the header files, which is at the very least prone to errors. Another option seems to be modifying the User Header Search Paths
property in the build settings. I tried setting the User Header Search Paths
and Header Search Paths
to point to the folders:
I have tried many values in there: Libraries/**
, $(PROJECT_DIR)/../cpr/build
(I have added the libcpr
repo as a submodule, so that's the build output folder) and many other variations. Nothing works.
Here is the repo with my current progress. To generate the artifacts:
- Initialize the submodule
cd cpr
mkdir build && cd build && cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../ios.toolchain.cmake -DPLATFORM=OS64COMBINED -DENABLE_STRICT_TRY_COMPILE=ON -DDEPLOYMENT_TARGET=13.0 -DBUILD_SHARED_LIBS=OFF
- Before compilation you will have to fix an implicit conversion on one header file (cpr/include/body.h just add (int) in the line where the error pops up)
cmake --build . --config Release
That generates the artifact and you should be able to open the .xcodeworkspace
file in the iOS
folder from the root repo.
Any Help would be greatly appreciated!
CodePudding user response:
Great findings, Oscar!
So, the issue is really Xcode not knowing where to find the header files, and the solution (as you already found out) is simply to use the right search path(s). You have to use HEADER_SEARCH_PATHS
(USER_HEADER_SEARCH_PATHS
only works for quote includes).
diff --git a/ios/libcprtest.xcodeproj/project.pbxproj b/ios/libcprtest.xcodeproj/project.pbxproj
index f16a88c..38d64da 100644
--- a/ios/libcprtest.xcodeproj/project.pbxproj
b/ios/libcprtest.xcodeproj/project.pbxproj
@@ -599,6 599,7 @@
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
"\"$(PODS_TARGET_SRCROOT)/include/\"",
"\"$(SRCROOT)/../cpr\"/**",
);
INFOPLIST_FILE = libcprtest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
@@ -619,7 620,7 @@
PRODUCT_NAME = libcprtest;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
- USER_HEADER_SEARCH_PATHS = "Libraries/**";
USER_HEADER_SEARCH_PATHS = "";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@@ -672,6 673,7 @@
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
"\"$(PODS_TARGET_SRCROOT)/include/\"",
"\"$(SRCROOT)/../cpr\"/**",
);
INFOPLIST_FILE = libcprtest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
@@ -691,7 693,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = libcprtest;
SWIFT_VERSION = 5.0;
- USER_HEADER_SEARCH_PATHS = "Libraries/**";
USER_HEADER_SEARCH_PATHS = "";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Alternatively, you could add just the include directories (instead of recursively searching the vendor source / build folder).
// from repo root
find ./cpr -type d -name include | xargs -I {} echo "\"\$(SRCROOT)/.{}\""
"$(SRCROOT)/../cpr/include"
"$(SRCROOT)/../cpr/build/include"
"$(SRCROOT)/../cpr/build/_deps/curl-src/plan9/include"
"$(SRCROOT)/../cpr/build/_deps/curl-src/include"
Cheers!