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

Support xcframeworks #2801

Closed
wants to merge 11 commits into from
Closed

Conversation

tmspzz
Copy link
Member

@tmspzz tmspzz commented Jun 5, 2019

Implement support for #2799

This feature involves:

  • supporting creation of xcframeworks in build
  • supporting creation of archives with xcframeworks
  • supporting binary xcframeworks
  • avoiding xcframeworks in copy-frameworks
  • dSYMs ?

@tmspzz tmspzz mentioned this pull request Jun 5, 2019
@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

@ikesyo @mdiep @jdhealy @NachoSoto can anyone please give a first review pass?

The review path should be: build command -> archive command -> bootstrap with binary in Carfile

@ikesyo
Copy link
Member

ikesyo commented Jun 6, 2019

I don't take a deeper look yet, but I think that the XCFrameworks should not be in Carthage/Build/$platform because the format supports bundling frameworks for multiple platforms. Those should be placed directly in Carthage/Build or Carthage/Build/XCFrameworks.

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

The way I implemented it, the .xcframework created by Carthage contains platform+platformsimulator, never multiple platforms.

@NachoSoto
Copy link
Contributor

The way I implemented it, the .xcframework created by Carthage contains platform+platformsimulator, never multiple platforms.

I haven’t looked at the code yet, but I would expect the Xcode command to generate these for all platforms? If not, we probably do need to change that, as the main advantage of this is to be able to finally get rid of copy-frameworks (http://www.openradar.me/radar?id=6409498411401216) and to support #2799.

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

@NachoSoto

I haven’t looked at the code yet, but I would expect the Xcode command to generate these for all platforms?

It does, just it doesn't combine tvOS and watchOS in the same .xcframework. It combines tvOS + tvSimualtor in one xcframework bundle where inside there are 2 separate framework bundles each for slices for the correct architecture. They are not fat binaries anymore.

So there radar problem is solved.

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

@ikesyo I think that technically you are correct, I imagine the format would support placing all platforms in one .xcframework . If one did that then it wouldn't make sense to go with Carthage/Build/$platform.

I didn't go that way since I'm not sure how this is expected to be used. However the platform specific .xcframeworks could be just repacked in another .xcframework in the end if we wanted to do so.

@tmspzz tmspzz closed this Jun 6, 2019
@tmspzz tmspzz reopened this Jun 6, 2019
@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

So this is the current structure on disk, just use your imagination for the other platforms 😄

Screenshot 2019-06-06 at 11 08 18

@ikesyo
Copy link
Member

ikesyo commented Jun 6, 2019

It will be okay as a first step 😃

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

I'm not sure what else is supposed to happen to support Catalyst ? Can anyone point me to more documentation? https://developer.apple.com/documentation/uikit/creating_a_mac_version_of_your_ipad_app

@mdiep
Copy link
Member

mdiep commented Jun 6, 2019

My guess for Catalyst is that the XCFramework needs to contain both iOS and macOS versions so that the correct platform can be chosen.

@samrayner
Copy link

samrayner commented Jun 6, 2019

It's a bit more complicated than that unfortunately. With some help from @owensd on Twitter I managed to rebuild my app's dependencies and get things running.

A ios-x86_64-uikitformac build is required, done against the My Mac destination (-destination generic/platform=macOS) and included alongside the iphoneos13.0 and iphonesimulator13.0 SDK builds. A regular x86 Mac framework in the xcframework won't help with Catalyst.

I assume this can be done through the command line but I couldn't figure it out so here are my manual Xcode steps. As usual with these things I'm not sure all of them are required but they got things working.

  • Open dependency workspace or project from Carthage/Checkouts
  • Edit scheme and set Run build configuration to Release
  • Edit Build Settings:
    • Base SDK = iOS (in case framework base is macOS)
    • Supported Platforms = iOS (in case framework supports native macOS builds)
    • Build Libraries for Distribution = YES (recommended in Xcode 11 release notes)
    • Supports UIKit for Mac = YES
    • Derive UIKit for Mac Product Bundle Identifier = YES
  • Adjust codesigning as required
  • Ensure the Mac device checkbox is checked in General > Deployment Info
  • Run against My Mac
  • Copy the framework and dSYMs from Build > Products > Release-uikitformac in DerivedData
  • xcodebuild -create-xcframework -framework ios.framework -framework sim.framework -framework uikitformac.framework -output output.xcframework

I'm sure there's a way to maintain a framework's native macOS support while also offering UIKit for Mac support but I'm not sure how. I guess you would need two Mac build destinations?

Hope that helps.

Screenshot 2019-06-06 at 13 24 44

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

@mdiep just tried that, didn't work :(

@samrayner thanks for all the information. I'll see what I can make of it

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

There are 2 issues to solve:

  • build iOS schemes with macosx sdk, this produces the Release-uikitformac build that we want
  • repack all .xcframeworks in a new one

@tmspzz
Copy link
Member Author

tmspzz commented Jun 6, 2019

example build command:

xcrun xcodebuild -workspace /Users/tommaso/Code/lab/Alamofire/Alamofire.xcworkspace -scheme Alamofire\ iOS -configuration Release -sdk macosx ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath ./here SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO

@samrayner
Copy link

FYI, thread: https://twitter.com/samrayner/timelines/1136688278529290241

@tmspzz

This comment has been minimized.

@DavidBrunow
Copy link
Contributor

I don't think it makes sense to merge this to master until Xcode 11 is out of beta. The latest beta changed the naming convention of "uikitformac" to "maccatalyst" which breaks this implementation and we don't know what other changes are coming in the future.

@stale
Copy link

stale bot commented Aug 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@nancy-gomez
Copy link

Catalina GM and Xcode 11 GM have been out, and it seems quite a few PRs exist to enable the ability to build .xcframeworks for catalyst support. So, curious to know what the hold up is? 🤔😢

This was referenced Oct 10, 2019
@stale
Copy link

stale bot commented Nov 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 8, 2019
@stale stale bot removed the stale label Nov 11, 2019
@boobesh-s
Copy link

When this support will be available?

@ddaddy
Copy link

ddaddy commented Apr 28, 2020

Is there still no Mac Catalyst support in Carthage?

@eltonf
Copy link

eltonf commented Apr 28, 2020

I've been begrudgingly moving all of my Carthage frameworks to CocoaPods and to SPM when available. I love Carthage but not supporting Mac Catalyst is becoming a non-starter for me.

@lilpit
Copy link

lilpit commented Aug 21, 2020

adding XCFramework support would be the best way to fix this -> #3019 introduced by Xcode 12 betas

@tmspzz tmspzz closed this Oct 10, 2020
@tmspzz tmspzz deleted the feature/xcframeworks branch October 10, 2020 15:07
@chrisballinger
Copy link

For anyone else who was watching this issue, it looks like xcframework work has continued in this other PR: #2881

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet