Skip to content

JayMehta711/XCFrameworkCreateExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XCFrameworkCreateExample

Build xcframework using Aggregated Targets in xcode.

Aggregated Targets

Aggregated Targets is used when we need to build multiple targets together somehow.

Screenshot 2022-12-21 at 3 04 06 PM

you can give name like "AggregatedFramework" Change the scheme to "AggregatedFramework" Scheme and then edit scheme. Choose Run tab from the left panel then change the build configuration to release.

Screenshot 2022-12-21 at 3 07 58 PM

Go back and choose "AggregatedFramework" from the targets then choose Build Phases then click on the little + to add a dependency, and choose Grocerybag Framework Target.

Screenshot 2022-12-21 at 3 09 58 PM

Then click on the other + above Target dependancies word to add a New Run Script Phase Screenshot 2022-12-21 at 3 11 43 PM

You can rename the script to what it will do, for example "Create Aggregated Framework" Screenshot 2022-12-21 at 3 20 35 PM

Start typing in the script area or copy past from this sample project.

Screenshot 2022-12-21 at 3 26 06 PM

After script part ready choose the AggregatedTarget and run you project. Once it builds successfully check your project directory, you should be able to see a new directory named xcframework which contains your framework and if you look inside you should see both simulator and iphone architectures are in there.

if you received below error while build framework. "No 'swiftinterface' files found within ..." Screenshot 2022-12-21 at 3 33 08 PM

Please follow below steps:

Project target-> Build settings-> BUILD_LIBRARY_FOR_DISTRIBUTION = YES Project target-> Build settings-> Skip Install = NO

Or

Select Framework from target like "Grocerybag" goto Build settings-> BUILD_LIBRARY_FOR_DISTRIBUTION = YES

and then again come back to AggregatedFramework tagrget and try to build. Screenshot 2022-12-21 at 3 40 47 PM

OUTPUT:

Screenshot 2022-12-21 at 3 42 31 PM

Now you can darg and drop framework in your project and import when you needed. Check below image for reference:

Screenshot 2022-12-21 at 3 47 02 PM

For further learning you can check below Apple video: https://developer.apple.com/wwdc19/416

About

Build xcframework using Aggregated Targets in xcode

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages