I am creating an iOS version of an existing OSX app and am wondering what the best practices are for sharing code between the two. The code in question only depends on the foundation framework and the Sqlite dynamic library, so it should compile and run fine on both platforms.
It seems to me there are three possible options:
Is there any reason one of the above approaches may be better than the other two? If not, option 2 seems to be the simplest by far.
To develop iOS apps, you need a Mac computer running the latest version of Xcode. Xcode is Apple's IDE (Integrated Development Environment) for both Mac and iOS apps. Xcode is the graphical interface you'll use to write iOS apps.
With Flutter and Codemagic, you can build and distribute iOS apps without buying a Mac computer yourself. In this post, we will walk you through how you can create a Flutter app on Linux or Windows and use Codemagic CI/CD to set up code signing for your iOS project and release the application to the App Store.
Non-native platforms, like Flutter or React Native, won't make iOS builds without Mac either. Storyboards can be edited only in Xcode, so development without Xcode means development without Storyboards. Alternative IDEs for iOS development require Xcode. You don't need to run it, but you should have it installed.
You're in luck – developing an iOS app is not hard. In fact, there are numerous tools that make developing your own iOS app easy and fun. Armed with a little knowledge and these tools, you too can learn to code iOS apps! This tutorial series will teach you how to make an iOS app from scratch.
I have done this and took the 3rd approach; a separate static library. The reason I chose that approach was because it can be kept within its own git repo and shared with other projects later on.
One thing to overcome, however, is determination of the platform you are compiling for. I solved this using the following code fragment which defines SYSINFO_IOS
or SYSINFO_OSX
which are then used within the library source/header files:
#import <TargetConditionals.h>
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
#define SYSINFO_OSX 1
#else
#define SYSINFO_IOS 1
#endif
This fragment should be in its own header file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With