Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.10.0.beta.2 - XCFrameworks + static libs error #10058

Closed
1 task done
omarzl opened this issue Sep 15, 2020 · 7 comments
Closed
1 task done

1.10.0.beta.2 - XCFrameworks + static libs error #10058

omarzl opened this issue Sep 15, 2020 · 7 comments
Milestone

Comments

@omarzl
Copy link

omarzl commented Sep 15, 2020

Report

What did you do?

We are migrating some code to static libraries using xcframeworks and we want to distribute it via Cocoapods.
In the demo there is a StaticLib folder with an xcframework that has only one class and its podspec, also there is an Example project with its Podfile.

I added the xcframework to the vendored_frameworks and after running pod install I noticed that it is setup in the Library Search Paths

image

But if I try to compile it gives me a No such module 'StaticLib' error, I found out that Xcode can't find the StaticLib.swiftmodule so I modified the SWIFT_INCLUDE_PATHS using the s.user_target_xcconfig in the StaticLib.podspec

  s.user_target_xcconfig = {
          'SWIFT_INCLUDE_PATHS' => '"${PODS_XCFRAMEWORKS_BUILD_DIR}/'+"#{s.name}"+'"'
    }

I read this PR #9720 but it only says that the ${HEADER_SEARCH_PATHS} adds the static library headers but mine is not Obj-C, its pure Swift.

Also its good to say that I built the xcframework using the xcodebuild command:

xcodebuild -create-xcframework \
  -library "./simulator/libStaticLib.a" \
  -library "./device/libStaticLib.a" \
  -output StaticLib.xcframework

I would like to ask if I am doing something wrong or its missing something at Cocoapods code to include the SWIFT_INCLUDE_PATHS part, I could leave it like that and it works but maybe its not the correct way.


Also I noticed another issue, when I try to run the project in a device it gives me this error:

Showing All Messages
PhaseScriptExecution [CP]\ Copy\ XCFrameworks /Users/omarzl/Library/Developer/Xcode/DerivedData/Example-agbiraqwkorixiaticfzihjlzlqf/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/StaticLib.build/Script-AAC1A020DC1628778E27A016D0C23F2D.sh (in target 'StaticLib' from project 'Pods')
    cd /Users/omarzl/Documents/CocoaPodsSupport/Example/Pods
    /bin/sh -c /Users/omarzl/Library/Developer/Xcode/DerivedData/Example-agbiraqwkorixiaticfzihjlzlqf/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/StaticLib.build/Script-AAC1A020DC1628778E27A016D0C23F2D.sh

warning: [CP] Unable to find matching .xcframework slice in '/Users/omarzl/Documents/CocoaPodsSupport/Example/Pods/../../StaticLib/StaticLib.xcframework StaticLib library ios-arm64 ios-x86_64-simulator' for the current build architectures (arm64).

The xcframework has a correct slice for arm64 but the StaticLib-xcframeworks.sh script can't find it.

I changed line 50 from:

local target_arch_regex="[_\-]${target_arch}[\/_\-]"

to:

local target_arch_regex="[_\-]*${target_arch}[\/_\-]*"

And it compiles, copies the slice to the XCFrameworkIntermediates folder and it runs correctly, maybe the regex should be modified?

CocoaPods Environment

Stack

   CocoaPods : 1.10.0.beta.2
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15.4 (19E287)
       Xcode : 11.5 (11E608c)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

claide-plugins        : 0.9.2
cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

Podfile

platform :ios, "12.0"
use_modular_headers!

target 'Example' do
  pod 'StaticLib', :path => '../StaticLib'
end

Project that demonstrates the issue

DemoProject.zip

@dnkoutso
Copy link
Contributor

@omarzl thanks for the great report.

A PR landed for 1.10.0.rc.1 https://github.com/CocoaPods/CocoaPods/pull/10027/files that changes the regex, does that fix the issue? Can you try it?

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 15, 2020
@omarzl
Copy link
Author

omarzl commented Sep 15, 2020

@dnkoutso Thank you for the response, I just tested it and its working fine!

PhaseScriptExecution [CP] Copy XCFrameworks
Selected xcframework slice ios-arm64

Regarding the SWIFT_INCLUDE_PATHS configuration, do you know if I am missing something?

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 15, 2020
@dnkoutso
Copy link
Contributor

Sorry I am not sure what to recommend for SWIFT_INCLUDE_PATHS.

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 15, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@igor-makarov
Copy link
Contributor

Just ran into this today, probably have a fix. FYI @dnkoutso

@LowAmmo
Copy link

LowAmmo commented Dec 10, 2021

Checking with those that might know more about what is causing the problem, if there is a good chance this will fix the issue called out in #10204 ?

@dnkoutso dnkoutso added this to the 1.11.3 milestone Feb 25, 2022
@xuzhongping
Copy link
Contributor

@igor-makarov Hi,After I saw this problem, I tried it. If I use a swift dynamic xcframework, there will still be problems. I noticed that the SWIFT_INCLUDE_PATHS in the Pods-xxx-config.xcconfig file uses "${PODS_CONFIGURATION_BUILD_DIR}/libname", which is correct It should be to use "${PODS_XCFRAMEWORKS_BUILD_DIR}/libname", I modified the demo of the author of this issue:CocoaPodsSupport 2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants