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

Xcode 12 Clang: Error in PodSpec Validation due to architectures #10104

Open
dshackelford opened this issue Sep 29, 2020 · 10 comments
Open

Xcode 12 Clang: Error in PodSpec Validation due to architectures #10104

dshackelford opened this issue Sep 29, 2020 · 10 comments
Labels
s6:need sample Needs a sample project that reproduces the issue

Comments

@dshackelford
Copy link

Report

Hello, I recently updated to Xcode 12 and I am having errors with pushing my private podspec to my repo. It has to do with a dependency that I don't have control over, that I believe has an error with their valid Architecture definitions.

I have read other posts/issues on this git hub page about how to write Post_installs for installing a pod via a podfile, but I am trying to validate a podspec in which has a spec.dependency that is the issue. I am able to install the pod directly via podfile after adjusting the self-defined VALID_ARCHS setting in the build settings to include x86_64. Is there a similar Post_Install command I can add to my PodSpec?

I'm not sure you can help me since I'm not even sure what the problem is exactly, but I was hoping maybe I could get some information. Let me know if you need any more information. Thanks.

What did you do?

Run pod repo push MyPodSpecs DroneKit.podspec

What did you expect to happen?

I expected DroneKit to be added to MyPodSpecs successfully.

What happened instead?

I got an error while validating spec:
ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.

So I ran with --verbose, and found mention of a clang error:

ld: building for iOS Simulator, but linking in dylib built for iOS, file '/var/folders/pn/4cgjvr1j7mzbnl55pfnzlgr00000gq/T/CocoaPods-Lint-20200929-48311-11st24n-DroneKit/Pods/DJI-SDK-iOS/iOS_Mobile_SDK/DJISDK.framework/DJISDK' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

The following build commands failed: Ld /Users/dylan/Library/Developer/Xcode/DerivedData/App-ckgszeaogfkgqlddwiywgfcjzsrb/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/DroneKit.build/Objects-normal/arm64/Binary/DroneKit normal arm64 (1 failure)

CocoaPods Environment

Stack

   CocoaPods : 1.10.0.rc.1
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15.5 (19F101)
       Xcode : 12.0.1 (12A7300)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : 17-scm-mypodspecs - git - http://192.155.17.3: 4444/scm/mypodspecs @ e6116cadf35ab4asdf33bfd134461c09dsafab3c9439c3

               DMEPodSpecs - git - http://dylans@192.155.17.3:4444/scm/mypodspecs @ fa9234c65d8908243565353459d4223acasdfac03972c

              master - git - https://github.com/CocoaPods/Specs.git @ a2333afbe6192da5c142612cb17e4f55e51c8a1

               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'

source 'https://github.com/CocoaPods/Specs.git'
source 'http://192.155.17.3: 4444/scm/mypodspecs.git'


def pods
 pod 'DJI-SDK-iOS','4.13.1'
end

target 'DroneKit' do
  use_frameworks!
  pods
end

target 'DroneKitTests' do
  inherit! :search_paths
  use_frameworks!
  pods
end

PodSpec

Pod::Spec.new do |spec|
spec.name         = "DroneKit"
spec.version      = "0.0.10"
spec.summary      = "Provide interface with common Drone logic systems"
spec.description  = "Container for Flight controller states, flight logger, and other common drone logic systems."

spec.homepage     = "http://192.155.17.3:4444/scm/dronekit.git"

spec.license      = { :type => "MIT", :file => "LICENSE" }

spec.author       = { "Dylan" => "dylan@myEmail.com" }

spec.platform     = :ios, "11.0"
spec.swift_version = "5.0"

spec.source       = { :git => "http://192.155.17.3:4444/scm/dronekit.git", :tag => "#{spec.version}" }

spec.source_files  = "DroneKit/**/*.{swift}"
spec.exclude_files = "Classes/Exclude"

spec.dependency "DJI-SDK-iOS"

end
@dnkoutso
Copy link
Contributor

This is probably the same or similar issue around VALID_ARCHS being deprecated in Xcode 12 and EXCLUDED_ARCHS needed.

Thanks for the report.

@tinchovictory
Copy link

Xcode 12 includes simulators supporting arm64 architecture (for the new apple silicon mac), so many framework need to be compiled again to include the arm64 slice for the simulator. Meanwhile, you should exclude the arm64 architecture of the simulator while compiling, otherwise it's gonna fail because it can't find the arm64 slice.

Unfortunately, pod lib lint fails if your pod dependes on another without the arm64 support for the simulator. Adding any configuration to the Podfile won't fix it since pod lib lint internally creates a new workspace only based on the .podspec. In my case I was able to succesfully run pod lib lint by adding:

s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

if the development pod has a direct dependency with the pod missing the arm64 slice. But on pods failing because of a transitive dependency I only need to add:

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

Here is a great stackoverflow post on how to solve the issue.
The same issue was also reported in #9967

After trying many days, I couldn't find any better solution.

@dnkoutso
Copy link
Contributor

@tinchovictory makes sense. I assume your pod is a pre-built binary pod? Or does this fail with pods that have sources?

@dnkoutso
Copy link
Contributor

The podspec specified here btw is a private pod. I will need an easy to repro case with a source pod or a pre-built binary pod.

@dnkoutso dnkoutso added s6:need sample Needs a sample project that reproduces the issue s1:awaiting input Waiting for input from the original author labels Sep 29, 2020
@tinchovictory
Copy link

@dnkoutso yes I have the issue with Google Analytics which is a pre-build pod. But I also have the same problem with Realm. They have an open issue related to this.

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 29, 2020
@dshackelford
Copy link
Author

Yes, this is a private podspec.

I am unable to create a "reproducible" case for you at this time. But using @tinchovictory 's recommendation of adding excluded architectures in the podspec fixed the problem for now, and I am able to push my private podspec without any clang errors.

I have let the creators of the dependent pod know of the issue and await their response/update.

Thanks!

@hibrq
Copy link

hibrq commented Sep 30, 2020

A static framework build from mars (https://github.com/Tencent/mars) only supports ARM64 and x86_64
When validation is performed, an error is reported,
The following build commands (pod lib lint) failed: Ld /Users/... /Objects-normal/i386/Binary/HILog normal i386
I need to add configuration in xxx.podspec : s.pod_target_xcconfig = { 'VALID_ARCHS' => 'armv7 arm64 x86_64'} and it's work.
This error occurred because mars did not contain i386 (32-bit) architecture(I think), so I removed i386 from VALID_ARCHS.
However, Mars only supports ARM64 and X86_64 architectures, and I added ARMV7 to VALID_ARCHS to get this right.
That might be a little unreasonable .

@ElizaSapir
Copy link

hey,

Choose the right section to resolve it on your side.

For SDK owners:

The solution is to open the podspec and add below:

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'}
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'}
s.ios.deployment_target  = '10.0' // not required

For SDK users:

  1. Navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture.

image

  1. On Podfile add:
post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

@tinchovictory
Copy link

@ElizaSapir SDK owners should only add those lines to the podspec if they depend on another SDK which is missing the arm64 slice for simulators. But this is a temporary fix. Hopefully, the SDK's dependencies add the arm64 slice for simulators in the near future. When that happens, we need to remove those lines, otherwise we will be breaking compatibility for new macs.

bsiegel added a commit to Azure/azure-sdk-for-ios that referenced this issue Oct 23, 2020
See the problem description in CocoaPods/CocoaPods#10104 (comment)

The long-term fix is to include support for the arm64 simulator in the
framework, ideally by creating an xcframework instead of making the fat
binary larger.
bsiegel added a commit to Azure/azure-sdk-for-ios that referenced this issue Oct 23, 2020
* Split out the subspecs into a set of individual podspec files

* Workaround Xcode 12 issue requiring Apple silicon arch

See the problem description in CocoaPods/CocoaPods#10104 (comment)

The long-term fix is to include support for the arm64 simulator in the
framework, ideally by creating an xcframework instead of making the fat
binary larger.

Co-authored-by: Brandon Siegel <brsiegel@microsoft.com>
@GuoZhiQiang
Copy link

Thanks @tinchovictory @hibrq

JoeyTeng added a commit to octaface/FlutterToast that referenced this issue Sep 14, 2021
JoeyTeng added a commit to octaface/Agora-Flutter-SDK that referenced this issue Sep 14, 2021
Suggested solution is obtained from CocoaPods/CocoaPods#10104 (comment)

This issue has been found since Flutter 2.5.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s6:need sample Needs a sample project that reproduces the issue
Projects
None yet
Development

No branches or pull requests

6 participants