Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request square#104 from square/xcode_version_object_version
Browse files Browse the repository at this point in the history
Add support to specify xcode version as a parameter
  • Loading branch information
dnkoutso authored Jan 6, 2021
2 parents 33c0c45 + 67a7c08 commit d7b655f
Show file tree
Hide file tree
Showing 568 changed files with 4,893 additions and 2,317 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GIT
PATH
remote: .
specs:
cocoapods-generate (2.1.1)
cocoapods-generate (2.2.0)
cocoapods-disable-podfile-validations (~> 0.1.1)

GEM
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Options:
and a podfile are specified
--single-workspace Whether to produce a single workspace for
all podspecs specified.
--xcode-version=xcode_version The Xcode version to use for producing the
consumer sample project
```
<!-- end cli usage -->

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.2.0
5 changes: 5 additions & 0 deletions lib/cocoapods/generate/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def ===(other)
value
end

coerce_to_version = lambda do |value|
Pod::Version.new(value)
end

coerce_to_pathname = lambda do |path|
path && Pathname(path).expand_path
end
Expand Down Expand Up @@ -205,6 +209,7 @@ def ===(other)
option :warn_for_multiple_pod_sources, BOOLEAN, '(use_podfile && podfile) ? podfile.installation_options.warn_for_multiple_pod_sources : false', 'Whether installation should warn when a pod is found in multiple sources', nil, nil, coerce_to_bool
option :use_modular_headers, BOOLEAN, 'false', 'Whether the target should be generated as a clang module, treating dependencies as modules, as if `use_modular_headers!` were specified. Will error if both this option and a podfile are specified', nil, nil, coerce_to_bool
option :single_workspace, BOOLEAN, 'false', 'Whether to produce a single workspace for all podspecs specified.', nil, nil, coerce_to_bool
option :xcode_version, Pod::Version, 'Pod::Version.new(\'9.3\')', 'The Xcode version to use for producing the consumer sample project', 'xcode_version', nil, coerce_to_version

options.freeze
options.each do |o|
Expand Down
20 changes: 19 additions & 1 deletion lib/cocoapods/generate/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ module Generate
# given a configuration and a generated podfile.
#
class Installer
DEFAULT_XCODE_VERSION = '9.3'.freeze

XCODE_VERSION_TO_OBJECT_VERSION = {
'12.0' => 54,
'11.4' => 53,
'11.0' => 52,
'10.0' => 51,
'9.3' => 50,
'8.0' => 48,
'6.3' => 47,
'3.2' => 46,
'3.1' => 45
}.freeze

# @return [Configuration]
# the configuration to use when installing
#
Expand Down Expand Up @@ -93,7 +107,11 @@ def open_app_project(recreate: false)
if !recreate && app_project_path.exist?
Xcodeproj::Project.open(app_project_path)
else
Xcodeproj::Project.new(app_project_path)
version_key = XCODE_VERSION_TO_OBJECT_VERSION.keys.find do |k|
configuration.xcode_version >= Pod::Version.new(k)
end || DEFAULT_XCODE_VERSION
object_version = XCODE_VERSION_TO_OBJECT_VERSION[version_key]
Xcodeproj::Project.new(app_project_path, false, object_version)
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/cocoapods/command/gen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
and a podfile are specified
--single-workspace Whether to produce a single workspace for
all podspecs specified.
--xcode-version=xcode_version The Xcode version to use for producing the
consumer sample project
HELP
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/cocoapods/generate/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
single_workspace: false,
use_podfile: false,
use_podfile_plugins: false,
warn_for_multiple_pod_sources: false
warn_for_multiple_pod_sources: false,
xcode_version: Pod::Version.new('9.3')
)
end
end
Expand Down Expand Up @@ -62,7 +63,8 @@
share_schemes_for_development_pods: true,
warn_for_multiple_pod_sources: false,
use_modular_headers: false,
single_workspace: false }
single_workspace: false,
xcode_version: 9.3 }
TO_S
end

Expand Down
52 changes: 45 additions & 7 deletions spec/cocoapods/generate/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

it { should_not be_nil }

describe_method 'create_app_project' do
before do
podfile.defined_in_file = config.gen_dir_for_specs(podspecs).join('Podfile.yaml')
end
before do
podfile.defined_in_file = config.gen_dir_for_specs(podspecs).join('Podfile.yaml')
end

after do
FileUtils.rm_rf gen_directory
end
after do
FileUtils.rm_rf gen_directory
end

describe_method 'create_app_project' do
it 'should create all targets across all specs for app project' do
expect(subject.targets.map(&:name)).to eq(%w[App-macOS App-iOS App-tvOS App-watchOS])
end
Expand Down Expand Up @@ -55,4 +55,42 @@
end
end
end

describe_method 'open_app_project' do
context 'without specifying xcode-version parameter' do
it 'sets correct default object version' do
expect(subject.object_version).to eq '50'
end
end

context 'with specifying xcode version parameter' do
let(:config_options) do
{ podfile: podfile, lockfile: lockfile, use_podfile: !!podfile,
use_lockfile_versions: !!lockfile, gen_directory: gen_directory, xcode_version: Pod::Version.new('10.0') }
end
it 'sets correct object version' do
expect(subject.object_version).to eq '51'
end
end

context 'with specifying an unknown xcode version parameter' do
let(:config_options) do
{ podfile: podfile, lockfile: lockfile, use_podfile: !!podfile,
use_lockfile_versions: !!lockfile, gen_directory: gen_directory, xcode_version: Pod::Version.new('1.0') }
end
it 'sets correct object version' do
expect(subject.object_version).to eq '50'
end
end

context 'with specifying the closest xcode version parameter' do
let(:config_options) do
{ podfile: podfile, lockfile: lockfile, use_podfile: !!podfile,
use_lockfile_versions: !!lockfile, gen_directory: gen_directory, xcode_version: Pod::Version.new('10.1') }
end
it 'sets correct object version' do
expect(subject.object_version).to eq '51'
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ CLAIDE_DISABLE_AUTO_WRAP=TRUE COCOAPODS_SKIP_CACHE=TRUE COCOAPODS_VALIDATOR_SKIP
share_schemes_for_development_pods: true,
warn_for_multiple_pod_sources: false,
use_modular_headers: false,
single_workspace: false }
single_workspace: false,
xcode_version: 9.3 }

Generating workspace in `gen/Foo`
Cleaning gen install directory
Expand Down
60 changes: 34 additions & 26 deletions spec/integration/app_host_source_dir/after/gen/Foo/Foo.xcodeproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ Targets:
CODE_SIGN_IDENTITY: iPhone Developer
INFOPLIST_FILE: "${SRCROOT}/App-iOS/Info.plist"
IPHONEOS_DEPLOYMENT_TARGET: '9.0'
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/Frameworks"
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: iphoneos
SWIFT_VERSION: '4.0'
Expand All @@ -177,7 +179,9 @@ Targets:
CODE_SIGN_IDENTITY: iPhone Developer
INFOPLIST_FILE: "${SRCROOT}/App-iOS/Info.plist"
IPHONEOS_DEPLOYMENT_TARGET: '9.0'
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/Frameworks"
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: iphoneos
SWIFT_VERSION: '4.0'
Expand All @@ -186,14 +190,13 @@ Targets:
Build Phases:
- "[CP] Embed Pods Frameworks":
Input File List Paths:
[]
- "${PODS_ROOT}/Target Support Files/Pods-App-iOS/Pods-App-iOS-frameworks-${CONFIGURATION}-input-files.xcfilelist"
Input Paths:
- "${BUILT_PRODUCTS_DIR}/Foo-iOS/Foo.framework"
- "${PODS_ROOT}/Target Support Files/Pods-App-iOS/Pods-App-iOS-frameworks.sh"
Output File List Paths:
[]
Output File List Paths:
- "${PODS_ROOT}/Target Support Files/Pods-App-iOS/Pods-App-iOS-frameworks-${CONFIGURATION}-output-files.xcfilelist"
Output Paths:
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Foo.framework"
[]
Shell Path: "/bin/sh"
Shell Script: "\"${PODS_ROOT}/Target Support Files/Pods-App-iOS/Pods-App-iOS-frameworks.sh\"\n"
- Frameworks:
Expand All @@ -215,7 +218,9 @@ Targets:
CLANG_ENABLE_OBJC_WEAK: NO
CODE_SIGN_IDENTITY: "-"
COMBINE_HIDPI_IMAGES: YES
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/../Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/../Frameworks"
MACOSX_DEPLOYMENT_TARGET: '10.10'
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: macosx
Expand All @@ -227,22 +232,23 @@ Targets:
CLANG_ENABLE_OBJC_WEAK: NO
CODE_SIGN_IDENTITY: "-"
COMBINE_HIDPI_IMAGES: YES
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/../Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/../Frameworks"
MACOSX_DEPLOYMENT_TARGET: '10.10'
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: macosx
SWIFT_VERSION: '4.0'
Build Phases:
- "[CP] Embed Pods Frameworks":
Input File List Paths:
[]
- "${PODS_ROOT}/Target Support Files/Pods-App-macOS/Pods-App-macOS-frameworks-${CONFIGURATION}-input-files.xcfilelist"
Input Paths:
- "${BUILT_PRODUCTS_DIR}/Foo-macOS/Foo.framework"
- "${PODS_ROOT}/Target Support Files/Pods-App-macOS/Pods-App-macOS-frameworks.sh"
Output File List Paths:
[]
Output File List Paths:
- "${PODS_ROOT}/Target Support Files/Pods-App-macOS/Pods-App-macOS-frameworks-${CONFIGURATION}-output-files.xcfilelist"
Output Paths:
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Foo.framework"
[]
Shell Path: "/bin/sh"
Shell Script: "\"${PODS_ROOT}/Target Support Files/Pods-App-macOS/Pods-App-macOS-frameworks.sh\"\n"
- Frameworks:
Expand All @@ -262,7 +268,9 @@ Targets:
Build Settings:
ASSETCATALOG_COMPILER_APPICON_NAME: "App Icon & Top Shelf Image"
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME: LaunchImage
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/Frameworks"
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: appletvos
SWIFT_VERSION: '4.0'
Expand All @@ -273,7 +281,9 @@ Targets:
Build Settings:
ASSETCATALOG_COMPILER_APPICON_NAME: "App Icon & Top Shelf Image"
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME: LaunchImage
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks"
LD_RUNPATH_SEARCH_PATHS:
- "$(inherited)"
- "@executable_path/Frameworks"
PRODUCT_BUNDLE_IDENTIFIER: "org.cocoapods-generate.${PRODUCT_NAME:rfc1034identifier}"
SDKROOT: appletvos
SWIFT_VERSION: '4.0'
Expand All @@ -283,14 +293,13 @@ Targets:
Build Phases:
- "[CP] Embed Pods Frameworks":
Input File List Paths:
[]
- "${PODS_ROOT}/Target Support Files/Pods-App-tvOS/Pods-App-tvOS-frameworks-${CONFIGURATION}-input-files.xcfilelist"
Input Paths:
- "${BUILT_PRODUCTS_DIR}/Foo-tvOS/Foo.framework"
- "${PODS_ROOT}/Target Support Files/Pods-App-tvOS/Pods-App-tvOS-frameworks.sh"
Output File List Paths:
[]
Output File List Paths:
- "${PODS_ROOT}/Target Support Files/Pods-App-tvOS/Pods-App-tvOS-frameworks-${CONFIGURATION}-output-files.xcfilelist"
Output Paths:
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Foo.framework"
[]
Shell Path: "/bin/sh"
Shell Script: "\"${PODS_ROOT}/Target Support Files/Pods-App-tvOS/Pods-App-tvOS-frameworks.sh\"\n"
- Frameworks:
Expand Down Expand Up @@ -329,14 +338,13 @@ Targets:
Build Phases:
- "[CP] Embed Pods Frameworks":
Input File List Paths:
[]
- "${PODS_ROOT}/Target Support Files/Pods-App-watchOS/Pods-App-watchOS-frameworks-${CONFIGURATION}-input-files.xcfilelist"
Input Paths:
- "${BUILT_PRODUCTS_DIR}/Foo-watchOS/Foo.framework"
- "${PODS_ROOT}/Target Support Files/Pods-App-watchOS/Pods-App-watchOS-frameworks.sh"
Output File List Paths:
[]
Output File List Paths:
- "${PODS_ROOT}/Target Support Files/Pods-App-watchOS/Pods-App-watchOS-frameworks-${CONFIGURATION}-output-files.xcfilelist"
Output Paths:
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Foo.framework"
[]
Shell Path: "/bin/sh"
Shell Script: "\"${PODS_ROOT}/Target Support Files/Pods-App-watchOS/Pods-App-watchOS-frameworks.sh\"\n"
- Frameworks:
Expand Down
Loading

0 comments on commit d7b655f

Please sign in to comment.