I am trying to build a crossplatform framework that can be embeded both in and iOS and a tvOS application.
This framework does NOT contain anything related to UI but is a wrapper around CoreBluetooth.
What I explored ?
It compiles when I set the base sdk to tvOS, and when I set the base sdk to iOS. But I do not know how to make it work for both
Do you know how I could have both at the same time ?
Thanks
Stan
You'll have to create two different targets in your xcodeproj, one for iOS, and one for tvOS.
Then simply add both target as Target Membership for your swift files.
Related
I met some tutorial which introduces how to integrate legacy Unity exported iOS project into Objective-C iOS project. Like:
https://www.youtube.com/watch?v=2PW7_CfIwY0
However, some of these tutorials are merge and hybrid two iOS projects into one, not a framework.
Is there a solution to integrate Unity build iOS project as a framework of a Swift iOS project?
I'm pretty sure you can't export a Unity project as an iOS framework. Your only option is to do the following:
Use this method to integrate your Unity build into an iOS project as a subview (it works for 2017.3.0f3! tested it myself)
Create an iOS framework out of the UIViewController containing the Unity view (this SO answer explains how to instantiate the VC from the framework)
That way, instead of getting a hybrid of two projects, it's one project integrated within the other as a framework
Previously to build a framework for particular platform(macOS, iOS), I used to maintain different projects in Xcode and build separately.
My code mostly depends on sqlite3.h and a wrapper class written in Swift.
Is there a way to maintain all the frameworks under one xcode project?
I searched but I didn't get any tutorials on the web.
Thank you.
yes of course xcode can handle this for a long time. you simply create your framework project and then add targets for iOS, macOS, tvOS and watchOS.
the plus sign below the target pane allows you to add more target. or just duplicate your existing target and change sdk and platform settings.
I am in the process of porting an all iOS + WatchOS 1 app written originally in Swift 1, to the latest Xcode 8, WatchOS 3, Swift 3.
My app has an embedded framework with some common functionality that used to compile and run file for both the watchkit extension target and the ios app target.
With Xcode 8 I can no longer seem to get this to work. When I try to import the framework in the watchkit extension code, I get the module not found error.
Is it still possible to compile and use one single embedded framework package on both the target iOS and WatchKit extension targets? In my framework I have the target platforms set to watchos, watchsimulator, iphoneos, iphonesimulator.
My gut says it's not possible anymore. Where originally all the code really ran on the phone itself, not that codes runs on the actual watch and the phone, you'd need to compile an embedded framework specifically for each.
Short version: You can't. Create a duplicate target and set it to use the watch SDK.
Longer version from Apple's docs: https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/iOSSupport.html#//apple_ref/doc/uid/TP40014969-CH21-SW1
including:
NOTE
After you create a separate framework target for your WatchKit
extension, you must manage the contents of that framework separately
for both iOS and watchOS. If you add files to the iOS version of the
framework, remember to add them to the watchOS version.
Since Xcode 11 you can use Swift Package Manager to do this without duplicate targets. Have tested in Xcode 12 beta6 at least and it is another option to look at that didn't exist when the question was asked or I initially answered (and it doesn't meet the detailed requirements of the question as it needs newer Xcode).
I have very simple requirement for my iOS SDK
-Support iOS 7 and above.
-Include some swift code to my SDK
Problems:
-With iOS 8, Xcode allowed us to develop cocoa touch frameworks, but they can only be run on iOS 8 and above.
-If I create a static library, I cannot include swift code.
-I was using using Real Framework, but Real Framework does not get installed with Xcode 7.
So, What does a poor developer do ?
You can always have an alternative distribution method for your SDK for users that are targeting iOS 7.
You can offer an SDK in a single concatenated file, that is simply merging all your project source files, which user can drop into project tree and compile together with all the other source files. This applies only when you have either Swift-only or Objective-C only SDK
If SDK user uses workspaces, he may embed your SDKs .xcodeproj directly in his project
Anyway both methods require source code distribution as the user needs to compile the code from within his project. Dependency maintenance is also more difficult.
For a reference you can check how it is done in:
https://github.com/SwiftyJSON/SwiftyJSON
It is a Swift library, but integration with iOS 7 based projects is the same.
I could not find any solution for this. I compromised:
I am NOT using swift code.
I am distributing static library (.a file and a .h header file) instead of a framework. (this is to support iOS 7)
I'm adding a 'Cocoa Touch Framework' target to an existing project on XCode 6. Will I be able to use the built framework on older iOS versions? (iOS 6 & 7)
As far as I know you can work around and support iOS7 with dynamic libraries.
The application must weak link against the framework. To do so, in
your application target’s “Link Binary With Libraries” Build Phase,
designate the framework as “Optional”. This will weakly link against
the framework.
Then, you need to follow the guidelines provided by apple.
You can have more information and a sample project in this blog article.