From 952bbecfe9320b4e99cba072b8bdf9abad18d546 Mon Sep 17 00:00:00 2001 From: Mirko Galimberti Date: Sat, 23 Sep 2023 17:01:31 +0200 Subject: [PATCH] Do not use full path for system libraries and frameworks in `.xcodeproj` (#867) --- .ci/test_project.sh | 17 ++++++++++++++++- kivy_ios/recipes/zbarlight/__init__.py | 3 ++- kivy_ios/toolchain.py | 18 ++++++++---------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.ci/test_project.sh b/.ci/test_project.sh index accb4537..131b3951 100755 --- a/.ci/test_project.sh +++ b/.ci/test_project.sh @@ -5,7 +5,22 @@ set -eo pipefail toolchain create Touchtracer kivy-ci-clone/examples/demo/touchtracer +# If runner arch is arm64, then the simulator arch is arm64, +# otherwise it's x86_64 +if [ $(arch) == "arm64" ]; then + SIM_ARCH="arm64" +else + SIM_ARCH="x86_64" +fi + +# Build for iOS xcodebuild -project touchtracer-ios/touchtracer.xcodeproj \ -scheme touchtracer \ -destination generic/platform=iOS\ - clean build CODE_SIGNING_ALLOWED=NO | xcpretty \ No newline at end of file + clean build CODE_SIGNING_ALLOWED=NO | xcpretty + +# Build for iOS Simulator +xcodebuild -project touchtracer-ios/touchtracer.xcodeproj \ + -scheme touchtracer \ + -destination 'generic/platform=iOS Simulator' \ + clean build CODE_SIGNING_ALLOWED=NO ARCHS=$SIM_ARCH | xcpretty \ No newline at end of file diff --git a/kivy_ios/recipes/zbarlight/__init__.py b/kivy_ios/recipes/zbarlight/__init__.py index d503d045..d7be0296 100755 --- a/kivy_ios/recipes/zbarlight/__init__.py +++ b/kivy_ios/recipes/zbarlight/__init__.py @@ -12,7 +12,8 @@ class ZbarLightRecipe(Recipe): url = "https://github.com/Polyconseil/zbarlight/archive/{version}.tar.gz" library = "zbarlight.a" depends = ["hostpython3", "python3", "libzbar"] - pbx_libraries = ["libz", "libbz2", "libc++", "libsqlite3", "CoreMotion"] + pbx_libraries = ["libz", "libbz2", "libc++", "libsqlite3"] + pbx_frameworks = ["CoreMotion"] include_per_platform = True def get_zbar_env(self, plat): diff --git a/kivy_ios/toolchain.py b/kivy_ios/toolchain.py index 0633e531..1fdaee05 100755 --- a/kivy_ios/toolchain.py +++ b/kivy_ios/toolchain.py @@ -1332,7 +1332,6 @@ def update_pbxproj(filename, pbx_frameworks=None): logger.info("Analysis of {}".format(filename)) project = XcodeProject.load(filename) - sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip() group = project.get_or_create_group("Frameworks") g_classes = project.get_or_create_group("Classes") @@ -1343,8 +1342,9 @@ def update_pbxproj(filename, pbx_frameworks=None): f_path = join(ctx.dist_dir, "frameworks", framework_name) else: logger.info("Ensure {} is in the project (pbx_frameworks, system)".format(framework)) - f_path = join(sysroot, "System", "Library", "Frameworks", - "{}.framework".format(framework)) + # We do not need to specify the full path to the framework, as + # Xcode will search for it in the SDKs. + f_path = framework_name project.add_file( f_path, parent=group, @@ -1356,13 +1356,11 @@ def update_pbxproj(filename, pbx_frameworks=None): ), ) for library in pbx_libraries: - logger.info("Ensure {} is in the project (pbx_libraries, dylib+tbd)".format(library)) - f_path = join(sysroot, "usr", "lib", - "{}.dylib".format(library)) - project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=False) - f_path = join(sysroot, "usr", "lib", - "{}.tbd".format(library)) - project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=False) + library_name = f"{library}.tbd" + logger.info("Ensure {} is in the project (pbx_libraries, tbd)".format(library)) + # We do not need to specify the full path to the library, as + # Xcode will search for it in the SDKs. + project.add_file(library_name, parent=group, tree="DEVELOPER_DIR", force=False) for xcframework in xcframeworks: logger.info("Ensure {} is in the project (xcframework)".format(xcframework)) project.add_file(