Skip to content

XCFramework Support#90

Open
npamidisf wants to merge 7 commits intoCocoaPods:masterfrom
npamidisf:XCFrameworkSupport
Open

XCFramework Support#90
npamidisf wants to merge 7 commits intoCocoaPods:masterfrom
npamidisf:XCFrameworkSupport

Conversation

@npamidisf
Copy link

Adding changes to add support for building XCFrameworks. Also allowing users to pass custom flags via user options to be able support use cases like building swift frameworks with ABI Module stability and more needs

@npamidisf
Copy link
Author

@amorde is this repo still accepting prs?

Copy link

@AlexShubin AlexShubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Thank you @npamidisf! Would be also cool to have a parameter where I can put a list of frameworks that I want to build as XCFrameworks. In some cases, I can still want to use the old-school format for some old Objc libraries for example :)

end

Pod::Executable.execute_command 'xcodebuild', args, true
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a couple of additions to this function. Sometimes we can have references to the same dependencies through other dependencies (e.g. we can have RxSwift but also RxTest which requires RxSwift) which can lead to duplicates and errors then.

def build_xcframework(frameworks, build_dir, module_name)
  xcframework = "#{build_dir}/#{module_name}.xcframework"
  return if File.exist?(xcframework) 

  args = %W(-create-xcframework -output #{xcframework})

  frameworks.each do |framework|
    return unless File.exist?(framework) 
    args += %W(-framework #{framework})
  end

  Pod::Executable.execute_command 'xcodebuild', args, true
end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. thanks. will include

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello guys!

Congrats to this pull request! Awesome work! 😍😍
I was testing this fork within my setup, and after adding the changes provided by Alex, it works perfectly given those changes also prevent some issues with aggregated targets, given some of them won't produce any frameworks and those checks will allow to detect that and skip the XCFramework generation.

I was wondering if you're planning to merge this soon, given that after going further on the setup within my project, I did flag some other major issues happening on the last steps (copy phase) from Rome. It would be great if I could create a pull request after those changes gets merged back in master. 🙏 🙏 🙏

Again, great work! 🌟 🌟 This is a major step forward into actively support Rome.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@AlexShubin AlexShubin Jan 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking it out, @Ricowere! I'll add it as a suggestion. Also I don't think we're aware of merging plans, I'd gladly know it too :)

@npamidisf
Copy link
Author

Amazing work! Thank you @npamidisf! Would be also cool to have a parameter where I can put a list of frameworks that I want to build as XCFrameworks. In some cases, I can still want to use the old-school format for some old Objc libraries for example :)

Good idea!!

Comment on lines +66 to +69
def build_xcframework(frameworks, destination, module_name)
args = %W(-create-xcframework -output #{destination}/#{module_name}.xcframework)

frameworks.each do |framework|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def build_xcframework(frameworks, destination, module_name)
args = %W(-create-xcframework -output #{destination}/#{module_name}.xcframework)
frameworks.each do |framework|
def build_xcframework(frameworks, build_dir, module_name)
xcframework = "#{build_dir}/#{module_name}.xcframework"
return if File.exist?(xcframework)
args = %W(-create-xcframework -output #{xcframework})
frameworks.each do |framework|
return unless File.exist?(framework)

@orta
Copy link
Member

orta commented Jan 31, 2021

Hi folks, we've not had anyone actively maintaining Rome for a while, do you want to take over and help out? I can help get you access etc

@temoki
Copy link

temoki commented Feb 20, 2021

I just tried to build XCFramework using this branch and encountered the same problem as this URL.

xcframework does not contain internal frameworks
https://stackoverflow.com/questions/58805812/xcframework-does-not-contain-internal-frameworks

I was able to successfully build XCFramework by enabling the BUILD_LIBRARY_FOR_DISTRIBUTION flag in my podfile with the following statement.

plugin 'cocoapods-rome', { :pre_compile => Proc.new { |installer|
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
end

It would be nice if it could be built without the above description in the Podfile.

@temoki
Copy link

temoki commented Feb 20, 2021

When I built the app by incorporating the XCFramework built with #90 (comment) into an Xcode project, I encountered the same problem as the following URL.

Xcode 11 XCFramework "... is not a member type of ..." error
https://developer.apple.com/forums/thread/123253

@temoki
Copy link

temoki commented Feb 21, 2021

Finally, not adding the BUILD_LIBRARY_FOR_DISTRIBUTION flag and also adding the -allow-internal-distribution option when running -create-xcframework worked.

cocoapods-rome/post_install.rb#L70

#args = %W(-create-xcframework -output #{output})
args = %W(-create-xcframework -allow-internal-distribution -output #{output})

@xwal
Copy link

xwal commented May 28, 2021

Hi @npamidisf @AlexShubin @Ricowere ,will this PR be merged?

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

Successfully merging this pull request may close these issues.

6 participants