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

Archive fails with multiple platform xcframeworks in Xcode 14 #3335

Open
ldakhoa opened this issue Apr 20, 2023 · 0 comments
Open

Archive fails with multiple platform xcframeworks in Xcode 14 #3335

ldakhoa opened this issue Apr 20, 2023 · 0 comments

Comments

@ldakhoa
Copy link

ldakhoa commented Apr 20, 2023

  • carthage install method: [x] .pkg, [ ] homebrew, [x] source
  • which carthage: /Users/MYNAME/bin/carthage
  • carthage version: 0.39.0
  • xcodebuild -version: Test from 14.0 to 14.2
  • Are you using --no-build: No
  • Are you using --no-use-binaries: No
  • Are you using --use-submodules: No
  • Are you using --cache-builds: No
  • Are you using --new-resolver: No
  • Are you using --use-xcframeworks: Yes

In my company, we use Carthage (actually Fastlane Carthage) to generate xcframework for our internal SDKs, which works fine before Xcode 14.

However, when we upgraded to Xcode 14, only iOS SDKs worked, and every other multi-platform SDK (e.g the SecurityKit below has iOS and watchOS) failed as an Archive step.
When deep into the issue, I've found that Carthage is using flag sdk to archive the scheme. As Apple's recommendation:

The system determines the architectures and SDK according to build settings when running the command with the -destination flag, like the example above. Avoid common errors by using this flag rather than -arch and -sdk.
To build an archive for a different platform, adjust the value for -destination. Replacing this value with "generic/platform=iOS Simulator" creates an archive for Simulator.

I've tried replacing -sdk with -destination, and it worked well.

Fastlane Carthage config script

desc "Build and package binary framework"
lane :build_package_framework do |options|
  if !options[:framework]
    raise "No framework parameter specified".red
  end

  framework = options[:framework]

  carthage(
    command: "build",
    no_skip_current: true,
    use_xcframeworks: true,
  )

  zip(
    path: "Carthage/Build/#{framework}.xcframework",
    output_path: "#{framework}.xcframework.zip",
    verbose: false,
  )
end

which is equivalent carthage build --use-xcframeworks no-skip-current with all platforms

Carthage Output

error: Multiple commands produce '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/Alamofire.framework' note: Target 'Alamofire-iOS' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/Alamofire.framework' note: Target 'Alamofire-watchOS' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/Alamofire.framework'error: Multiple commands produce '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/APICoreKit.framework' note: Target 'APICoreKit-iOS' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/APICoreKit.framework' note: Target 'APICoreKit-watchOS' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/APICoreKit.framework'error: Multiple commands produce '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/AFNetworking.framework' note: Target 'AFNetworking' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/AFNetworking.framework' note: Target 'AFNetworking.root-NSURLSession-Security-Serialization' (project 'Pods') has create directory command with output '/Users/MYNAME/Library/Developer/Xcode/DerivedData/SecurityKit-csytdjtnwyszdkfbdfemtegbbzis/Build/Intermediates.noindex/ArchiveIntermediates/SecurityKit-watchOS/IntermediateBuildFilesPath/UninstalledProducts/watchos/AFNetworking.framework'

Actual outcome

/usr/bin/xcrun xcodebuild -workspace /Users/MYNAME/code/kits/SecurityKit/SecurityKit.xcworkspace -scheme SecurityKit-watchOS -configuration Release -sdk watchos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO -archivePath /var/folders/x4/sx1zly890jv7cgr8z924nx940000gp/T/SecurityKit SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO

Expected outcome

When archive scheme, it should use -destination instead of -sdk

/usr/bin/xcrun xcodebuild -workspace /Users/P825658/code/kits/SecurityKit/SecurityKit.xcworkspace -scheme SecurityKit-watchOS -configuration Release -destination generic/platform=watchOS ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO -archivePath /var/folders/x4/sx1zly890jv7cgr8z924nx940000gp/T/SecurityKit SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO

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

1 participant