CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.54k stars 2.63k forks source link

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

Open dshackelford opened 3 years ago

dshackelford commented 3 years ago

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--verbosefor 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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

dnkoutso commented 3 years ago

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.

tinchovictory commented 3 years ago

@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.

dshackelford commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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.

GuoZhiQiang commented 3 years ago

Thanks @tinchovictory @hibrq