Subito-it / PodBuilder

A tool to precompile CocoaPods pods
Other
284 stars 28 forks source link

Unable to run pod_builder build_all #20

Closed tareksabry1337 closed 4 years ago

tareksabry1337 commented 4 years ago

I'm trying to integrate Pod Builder in my project and it refuses to build when running pod_builder build_all

Podfile Contents:

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

target 'TargetName' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TargetName
  pod 'Amplify'
  pod 'AmplifyPlugins/AWSCognitoAuthPlugin'
  pod 'AWSMobileClient', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'AWSCognitoIdentityProvider', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'RxSwift', '5.1.1'
  pod 'RxCocoa', '5.1.1'
end

But I'm getting

'use_frameworks!' should be declared only once at Podfile root level (not nested in targets)
/Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/lib/pod_builder/podfile.rb:399:in `install_using_frameworks'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/lib/pod_builder/command/build.rb:74:in `call'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/lib/pod_builder/command/build_all.rb:11:in `call'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/exe/pod_builder:371:in `block in parse_commandline'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/exe/pod_builder:370:in `each'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/exe/pod_builder:370:in `parse_commandline'
    /Library/Ruby/Gems/2.6.0/gems/pod-builder-2.0.0/exe/pod_builder:386:in `<top (required)>'
    /usr/local/bin/pod_builder:23:in `load'
    /usr/local/bin/pod_builder:23:in `<main>'

Command failed!

I tried to place the use_frameworks! above targets but no avail.

In addition, the output says

Will skip 'Amplify' which defines script_phase in podspec

Why is it skipping something that has script_phase ?

tareksabry1337 commented 4 years ago

I was able to fix first error by adding use_frameworks! above the targets and then re-running pod_builder init once more, but right now it failed with another error

Oh no! Something went wrong during prebuild phase! Do you want to open the prebuild project to debug the error, you will need to add and run the Pods-Dummy scheme? [Y/N]

And when I ran the prebuild project I got an error that says:

Compiling for iOS 11.0, but module 'AWSMobileClient' has a minimum deployment target of iOS 12.0: /tmp/pod_builder/build/Debug-iphonesimulator/AWSMobileClient/AWSMobileClient.framework/Modules/AWSMobileClient.swiftmodule/x86_64-apple-ios-simulator.swiftmodule
tcamin commented 4 years ago

Why is it skipping something that has script_phase ?

Pods that include script_phases have to be skipped since we cannot make any assumption about the code that will be executed. It may require for example that source code files exists which is no longer true for prebuilt pods.

And when I ran the prebuild project I got an error that says:

As the error states the version of AWSMobileClient you are prebuilding has a minimum deployment target of iOS 12.0.

You should raise the deployment target in the Podfile by adding # platform :ios, '12.0' on top.

tareksabry1337 commented 4 years ago

Now my Podfile looks like this

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

use_frameworks!
target 'TargetName' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for TargetName
  pod 'Amplify'
  pod 'AmplifyPlugins/AWSCognitoAuthPlugin'
  pod 'AWSMobileClient', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'AWSCognitoIdentityProvider', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'RxSwift', '5.1.1'
  pod 'RxCocoa', '5.1.1'
  pod 'CardIO'
end

But I'm still facing the same issue.

Here's my PodBuilder.json if that helps

{
  "project_name": "SimpleHumanEcommerce",
  "spec_overrides": {
    "Google-Mobile-Ads-SDK": {
      "module_name": "GoogleMobileAds"
    },
    "glog": {
      "pod_target_xcconfig": {
        "DEFINES_MODULE": "NO"
      }
    },
    "DoubleConversion": {
      "pod_target_xcconfig": {
        "DEFINES_MODULE": "NO"
      }
    },
    "Folly": {
      "pod_target_xcconfig": {
        "DEFINES_MODULE": "NO"
      }
    },
    "Flipper-DoubleConversion": {
      "pod_target_xcconfig": {
        "DEFINES_MODULE": "NO"
      }
    },
    "Flipper-Folly": {
      "pod_target_xcconfig": {
        "DEFINES_MODULE": "NO"
      }
    },
    "AWSMobileClient": {
        "swift_version": "5.3"
    }
  },
  "skip_licenses": [

  ],
  "skip_pods": [
    "GoogleMaps",
    "React-RCTFabric",
    "React-Core",
    "React-CoreModules"
  ],
  "force_prebuild_pods": [

  ],
  "build_settings": {
    "ENABLE_BITCODE": "NO",
    "GCC_OPTIMIZATION_LEVEL": "s",
    "SWIFT_OPTIMIZATION_LEVEL": "-Osize",
    "SWIFT_COMPILATION_MODE": "wholemodule",
    "CODE_SIGN_IDENTITY": "",
    "CODE_SIGNING_REQUIRED": "NO",
    "CODE_SIGN_ENTITLEMENTS": "",
    "CODE_SIGNING_ALLOWED": "NO"
  },
  "build_settings_overrides": {
    "SBTUITestTunnelClient": {
      "ENABLE_BITCODE": "NO"
    }
  },
  "build_system": "Latest",
  "library_evolution_support": false,
  "license_filename": "Pods-acknowledgements",
  "restore_enabled": true,
  "allow_building_development_pods": false,
  "use_bundler": false,
  "deterministic_build": false,
  "build_for_apple_silicon": false,
  "build_using_repo_paths": false,
  "react_native_project": false
}
tcamin commented 4 years ago

My bad it's platform :ios, '12.0' (without the trailing #)

tareksabry1337 commented 4 years ago
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'

use_frameworks!
target 'MyTarget' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for MyTarget
  pod 'Amplify'
  pod 'AmplifyPlugins/AWSCognitoAuthPlugin'
  pod 'AWSMobileClient', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'AWSCognitoIdentityProvider', :git => 'git@github.com:simplehuman-engineering/aws-sdk-ios.git', :commit => '555b2a8a1963a07988e8e149f1eeb037296376d2'
  pod 'RxSwift', '5.1.1'
  pod 'RxCocoa', '5.1.1'
  pod 'CardIO'
  pod 'GooglePlaces'
end

Still the same issue :(

tcamin commented 4 years ago

Try installing latest beta:

> git clone -b feature/xcframeworks https://github.com/Subito-it/PodBuilder.git
> cd PodBuilder
> sudo rake install

Version 2.1.0.beta.1 should get installed. Verify it by running pod_builder --version

Additionally you'll need to fix the AWSMobileClient podspec which doesn't specify a swift_version by editing the PodBuilder/PodBuilder.json file adding the AWSMobileClient key under spec_overrides

  "spec_overrides": {
    "AWSMobileClient": { 
      "swift_version": "5.0"
    },
    "Google-Mobile-Ads-SDK": {
      "module_name": "GoogleMobileAds"
    },
tareksabry1337 commented 4 years ago

I was able to successfully run the command but there's an still an issue.

Here's the full log

tareksabry@Tareks-MacBook-Pro MyProject % pod_builder build_all

Loading Podfile
Updating local specs repositories

CocoaPods 1.10.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.10.0

Analyzing dependencies
Pre-downloading: `AWSCognitoIdentityProvider` from `git@github.com:simplehuman-engineering/aws-sdk-ios.git`, commit `555b2a8a1963a07988e8e149f1eeb037296376d2`
Pre-downloading: `AWSMobileClient` from `git@github.com:simplehuman-engineering/aws-sdk-ios.git`, commit `555b2a8a1963a07988e8e149f1eeb037296376d2`
Will skip 'Amplify' which defines script_phase in podspec
Checking Podfile.restore
Preparing build Podfile
Initialized empty Git repository in /private/tmp/pod_builder/.git/
Downloading Pods source code
Preparing build
Analyzing dependencies
Pre-downloading: `AWSCognitoIdentityProvider` from `git@github.com:simplehuman-engineering/aws-sdk-ios.git`, commit `555b2a8a1963a07988e8e149f1eeb037296376d2`
Pre-downloading: `AWSMobileClient` from `git@github.com:simplehuman-engineering/aws-sdk-ios.git`, commit `555b2a8a1963a07988e8e149f1eeb037296376d2`
Downloading dependencies
Installing AWSAuthCore (2.17.0)
Installing AWSCognitoIdentityProvider (2.17.0)
Installing AWSCognitoIdentityProviderASF (2.17.0)
Installing AWSCore (2.17.0)
Installing AWSMobileClient (2.17.0)
Installing AWSPluginsCore (1.3.2)
Installing Amplify (1.3.2)
Installing AmplifyPlugins (1.3.2)
Installing RxCocoa (5.1.1)
Installing RxRelay (5.1.1)
Installing RxSwift (5.1.1)
Generating Pods project
Skipping User Project Integration
Built 11 items, copying...
Pod installation complete! There are 12 dependencies from the Podfile and 11 total pods installed.
Build completed in 63 seconds
Cleaning prebuilt folder
Cleaning dSYM folder
Writing licenses
Generating PodBuilder's local podspec
Writing Restore Podfile
Updating Application Podfile
Running pod install
Analyzing dependencies
Downloading dependencies
Installing AWSAuthCore 2.17.0
Installing AWSCognitoIdentityProvider 2.17.0
Installing AWSCognitoIdentityProviderASF 2.17.0
Installing AWSCore 2.17.0
Installing AWSMobileClient 2.17.0
Installing AmplifyPlugins 1.3.2 (was 1.3.1)
Installing RxCocoa 5.1.1
Installing RxRelay 5.1.1
Installing RxSwift 5.1.1
Removing AWSPluginsCore
Generating Pods project

### Command

/usr/local/bin/pod install

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

   CocoaPods : 1.9.3
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15.7 (19H2)
       Xcode : 12.0 (12A7209)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : cocoapods - git - https://github.com/CocoaPods/Specs.git @ 916da241e07b4dd7bdd5e33dcf67404fa30f4098

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

### Plugins

cocoapods-binary      : 0.4.4
cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-rome        : 1.0.1
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

### Podfile

# Autogenerated by PodBuilder (https://github.com/Subito-it/PodBuilder)
# Any change to this file should be done on PodBuilder/Podfile

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

use_frameworks!
target 'MyTarget' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for MyTarget
  pod 'Amplify'
  pod 'AWSAuthCore', :path => 'PodBuilder/Prebuilt/AWSAuthCore' # pb<AmplifyPlugins/AWSCognitoAuthPlugin>
  pod 'AWSCognitoIdentityProviderASF', :path => 'PodBuilder/Prebuilt/AWSCognitoIdentityProviderASF' # pb<AmplifyPlugins/AWSCognitoAuthPlugin>
  pod 'AWSCore', :path => 'PodBuilder/Prebuilt/AWSCore' # pb<AmplifyPlugins/AWSCognitoAuthPlugin>
  pod 'AmplifyPlugins/AWSCognitoAuthPlugin', :path => 'PodBuilder/Prebuilt/AmplifyPlugins' # pb<AmplifyPlugins/AWSCognitoAuthPlugin>
  pod 'AWSMobileClient', :path => 'PodBuilder/Prebuilt/AWSMobileClient' # pb<AWSMobileClient>
  pod 'AWSCognitoIdentityProvider', :path => 'PodBuilder/Prebuilt/AWSCognitoIdentityProvider' # pb<AWSCognitoIdentityProvider>
  pod 'RxSwift', :path => 'PodBuilder/Prebuilt/RxSwift' # pb<RxSwift>
  pod 'RxRelay', :path => 'PodBuilder/Prebuilt/RxRelay' # pb<RxCocoa>
  pod 'RxCocoa', :path => 'PodBuilder/Prebuilt/RxCocoa' # pb<RxCocoa>
  pod 'CardIO'
  pod 'GooglePlaces'
end

pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_duplicate_framework_and_library_names) {}
  require 'pod_builder/podfile/pre_actions_swizzles'

end

### Error

ArgumentError - wrong number of arguments (given 1, expected 2)
/Library/Ruby/Gems/2.6.0/gems/pod-builder-2.1.0.beta.1/lib/pod_builder/podfile/pre_actions_swizzles.rb:26:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:157:in `new'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:157:in `create_embed_frameworks_script'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:33:in `block in install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:145:in `message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb:14:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:130:in `block (2 levels) in install_aggregate_targets'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:128:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:128:in `block in install_aggregate_targets'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:145:in `message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/pods_project_generator.rb:127:in `install_aggregate_targets'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/single_pods_project_generator.rb:20:in `generate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:308:in `block in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:303:in `create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:295:in `generate_pods_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:174:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:162:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=wrong+number+of+arguments+%28given+1%2C+expected+2%29&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
 - Changed CDN repo detection
   https://github.com/CocoaPods/CocoaPods/pull/9212 [closed] [21 comments]
   03 Dec 2019

 - Issues Cloning Spec repo - GitHub taking a very long time to download changes to the Specs Repo
   https://github.com/CocoaPods/CocoaPods/issues/4989 [closed] [73 comments]
   15 Nov 2019

 - Swift dependency in Obj-C project fails linking with the AVFoundation framework
   https://github.com/CocoaPods/CocoaPods/issues/7538 [closed] [19 comments]
   23 Mar 2018

and 1 more at:
https://github.com/cocoapods/cocoapods/search?q=wrong%20number%20of%20arguments%20%28given%201%2C%20expected%202%29&type=Issues&utf8=✓

🎉 done!
tcamin commented 4 years ago

Forgot to check backwards compatibility with CP 1.9.3. If you pull latest changes and run sudo rake install again everything should work.

tareksabry1337 commented 4 years ago

Works perfectly right now ! Any idea when is this going live ?

tareksabry1337 commented 4 years ago

Also one more thing that I noticed, after successfully installing the project isn't running anymore and it's complaining that it's missing required module AWSPluginsCore (Check the log above it even uninstalled it as last step). This can easily be worked around by adding AWSPluginsCore to the Podfile but my question here, shouldn't the builder resolve all required dependencies instead of uninstalling ones that it can't find in Podfile ?

tcamin commented 4 years ago

shouldn't the builder resolve all required dependencies

Yes it should, but there was a particular problem with the AmplifyPlugins/AWSCognitoAuthPlugin pod which should now be solved. Pull again and retry and please let me know if it fixes your problems, thanks!