Xcode Tips and Tricks - Part 4: Workspaces and | Ray Wenderlich

Find out how to manage project dependencies with workspaces. You'll also create a reusable framework for a checkbox control.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3199-xcode-tips-and-tricks/lessons/4
1 Like

Great tutorial!
Question, though - why do you put the whole framework project inside another project as opposed to compiled .framework file alone?

I understand that way it can be build and changed within Xcode, but would you actually do it for production code?

@bayzat
Compiled swift frameworks have been a bit dicey so far. Ref: Building a Framework (sim and deviā€¦ | Apple Developer Forums

This could be a good reference, except that I myself have not been able to create a compiled swift framework using Xcode 9: Publish a Universal Binary iOS Framework in Swift using CocoaPods

Iā€™ve just tried it and it worked: One project is a framework project. Iā€™ve built it and moved output (.framework file) to another project, then followed with instructions from your tutorial and everything builds and runs just fine.
Iā€™m on Xcode 8 though, maybe thatā€™s the reason?

@bayzat - oh well done! In that case, yes, go with the compiled framework as a preference. Iā€™ll have another go when the real Xcode is released

1 Like

Iā€™ve followed the steps up to adding the Checkbox project to the Xcoder project and the Checkbox framework to Embedded Binaries. All works as expected.

Then you say that symbols in the Checkbox project need to be marked ā€˜publicā€™. However my experience is that this code also builds and runs on both Simulator and iOS devices, even without declaring these items ā€˜publicā€™. Is this an artifact of running in the Xcode debugger, and an Ad Hoc/App Store built app would fail?

@stevecaine - have you tried resetting the simulator and removing the app from the iOS device, then doing a clean build and run? I suspect the app will fail at that point.

Symbols from other modules do need to be marked public, otherwise they canā€™t be accessed outside of that module. For example, if youā€™ve ever used a class in a Source Files folder in Playgrounds, you would have to add public to everything in that file that youā€™re referring to in the actual playground.

Ah, excellent suggestion. I will remember that for the future. Unfortunately in this case it didnā€™t change anything.

I believe you when you say the symbols need to be made public; unfortunately in my case the compiler isnā€™t enforcing that so I know ā€“ at this early stage ā€“ just where to make those changes.

And when I repeat the tutorial from scratch I run into a different problem: adding Xcoder files to a new Checkbox project does not copy those files even though (twice) I have made sure the ā€˜Copy itemsā€™ checkbox is checked.

I will wait until Xcode 9.0.1 is released before returning to this task. These inconsistent results from Xcode are just making this an exercise in frustration.

Thanks again for this tutorial; itā€™s been very enlightening. The issues Iā€™m running into are Xcodeā€™s, not yours.

Thanks so much for this! I have not created my own framework until today, and this video came in very handy!

Also, I came across a Stack Overflow post that explains how to work around the issues with linking the framework in Xcode 9. Hopefully this will help you.

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.

Excellent Tutorial ! Except you donā€™t explain copy if needed when adding files.

@caroline Can you please help with this when you get a chance? Thank you - much appreciated! :]

Thank you :blush:

Also, thank you for your feedback. Youā€™re right, I didnā€™t explain that. I tend to automatically check that because I always check copy if needed!

To me the the Definition of the action is unclear. It should read ā€œBesides making references , Copy source files to destination if they are not already thereā€ . To the casual Xcoder it is ambiguous. Just my gripe

1 Like

Good one! The challenge canā€™t really be followed if you create your project with User Interface as ā€œSwiftUIā€ (Xcode 11), which is a new option since the video was created. So the tutorial went off the rails at 13:00 because I had this selected from an earlier tutorial. Took me a while to figure this out.

1 Like