1

I want to build an app for iPhones and Macs. A big part of the logic can be used as a library.

I know that I can build 2 targets with the same source code, so I've been thinking about building an iOS static library and a Mac framework.

Based on this tutorial, I know I could build a Lib.framework to work on iOS devices and simulator (a fat lib).

So my question here is: Can I create a framework that works in iOS AND Mac OS at the same time?

You import one file and that file has the static lib for iOS, the static lib for iOS simulator and the framework for Mac OS. Can it be done?

EDIT

The said "Duplicated question" doesn't have an accepted answer, its closed because was considered to broad and the 2 answers are so outdated i can't use as research.

So, again, my problem: Merge iOS and Mac OS architectures.

Digging in lipo's manual I found that that I can merge 2 static libraries as one using the command lipo --create $(first).a $(second).a --output $(output).a

At the same time I found that a framework is basically a bundle folder with the headers (*.h) and a static library so i tried to merge the iOS static library generated and the Mac OS static library, but i get this error:

fatal error: lipo: libIOS.a and libMac.a have the same architectures (x86_64) and can't be in the same fat output file

It seems that iOS on iPhones 5S and the newer ones use x86_64 architecture so the Mac lib can't be merged.

Any ideas?

Nicos Karalis
  • 3,724
  • 4
  • 33
  • 62
  • I found really annoying when people just yell `duplicated` and forget to read the actual answer. The linked question is from 2011 and the links provided as answer are from 2009, even if the links are still online there are so much things that changed. Like for instance, now we can build an dynamic library for iOS without workarounds and this would be amazing IF i could merge it – Nicos Karalis Dec 04 '14 at 21:46
  • how is that question relevant? I don't have problems with building the libraries, i have problem `merging` them. – Nicos Karalis Dec 04 '14 at 22:02
  • This is old as well but might help: http://www.blackdogfoundry.com/blog/creating-a-library-to-be-shared-between-ios-and-mac-os-x/ – Display Name is missing Dec 04 '14 at 22:28
  • I've seen that tutorial before, if I follow it I'll end with 2 products, one for Mac one for iOS, I want to merge them, to distribute just one product for both platforms – Nicos Karalis Dec 04 '14 at 22:42
  • I'm not sure that's even possible outside of the very back-end stuff since iOS uses ARM processors and OSX uses Intel. http://loumiranda.com/2014/05/30/will-apple-make-universal-apps-work-on-ios-and-os-x/ – Display Name is missing Dec 04 '14 at 22:44
  • The old iPhones (<5) have arm and the new ones have 64 bits, as stated by `lipo` when reporting a x86_64 architecture inside iOS lib – Nicos Karalis Dec 04 '14 at 22:48

0 Answers0