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: https://forums.developer.apple.com/message/134265#134265

This could be a good reference, except that I myself have not been able to create a compiled swift framework using Xcode 9: https://eladnava.com/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