Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Simulator Need to compile arm64 with simulator libs #208

Closed
danoli3 opened this issue Jan 13, 2022 · 9 comments
Closed

iOS Simulator Need to compile arm64 with simulator libs #208

danoli3 opened this issue Jan 13, 2022 · 9 comments

Comments

@danoli3
Copy link
Member

danoli3 commented Jan 13, 2022

This involves also changing to use apple's new requirement of .frameworks to encapsulate and name the libraries !

Which in turn involves changing core templates in iOS / tvOS !

@danoli3 danoli3 self-assigned this Jan 13, 2022
@danoli3
Copy link
Member Author

danoli3 commented May 6, 2022

Also BITCODE is required now

@ofTheo
Copy link
Member

ofTheo commented Sep 16, 2022

I think this is a big priority now as we're starting to see issues on the forum with people getting errors when using the simulator.

Probably another option which might be a bit less work would be to separate out the libs for iOS Device and Simulator by folder and then link to them based on target.

eg:
libs/ios/device/opencv.a
libs/ios/simulator/opencv.a

Upside is it would be backwards compatible.
Downside is it might not work for catalyst apps?

@danoli3
Copy link
Member Author

danoli3 commented Nov 10, 2022

catalyst binaries could also live in their own folder under that idea
libs/ios/catalyst/opencv.a

probably best to look at converting to the new framework style though as another issue

@danoli3
Copy link
Member Author

danoli3 commented Jul 29, 2023

Apple no longer requires BITCODE :D

Okay massive progress here!
Due to the CMake overhaul of dependancies and finalising Patching dependancies on the Android / Massive Apothecary changes PR ! Branching off that I have successfully got many dependancies building with support for the targets:

  • iOS arm64
  • iOS arm64 (simulator)
  • iOS x86_64 (simulator)
  • iOS x86_64 (Mac Catalyst)
  • iOS arm64 (Mac Catalyst)
  • macOS arm64
  • macOS x86_64
  • tvOS arm64
  • tvOS x86_64 (simulator)
  • tvOS arm64 (simulator)
Screenshot 2023-07-29 at 12 56 32 pm

Furthermore, I have code that will be able to merge these into the new framework system to allow different lib types in the same fat lib. These can even include multiple platforms in one, or separated we can decide later

@danoli3 danoli3 moved this from TODO to IN PROGRESS in Operation Update Dependancies Jul 29, 2023
@ofTheo
Copy link
Member

ofTheo commented Jul 29, 2023 via email

@kritzikratzi
Copy link
Contributor

kritzikratzi commented Dec 4, 2023

hi!

@danoli3 do you have any code you want to share yet?

i just discovered your notes while trying to solve the same issue with a different approach (generate fat somelib_iphoneos.a and a fat somelib_iphonesimulator.a, then change coreof.xconfig to link to somelib_${PLATFORM_NAME}.a.

happy to share my changes, but they're not in a usable state (in the middle of looking into curl+openssl)

@kritzikratzi
Copy link
Contributor

kritzikratzi commented Dec 7, 2023

well, so things slowly start to work on my end. here is my current diff:

openFrameworks

the only change is adding ${PLATFORM_NAME} to all libs in coreof.xcconfig:

	 //------- Libraries
	 LIB_OF = "$(OF_PATH)/libs/openFrameworksCompiled/lib/ios/libofxiOS_${PLATFORM_NAME}_${CONFIGURATION}.a"
	-LIB_FREEIMAGE = "$(OF_PATH)/libs/FreeImage/lib/ios/freeimage.a"
	-LIB_FREETYPE = "$(OF_PATH)/libs/freetype/lib/ios/freetype.a"
	-LIB_TESS = "$(OF_PATH)/libs/tess2/lib/ios/tess2.a"
	+LIB_FREEIMAGE = "$(OF_PATH)/libs/FreeImage/lib/ios/freeimage_${PLATFORM_NAME}.a"
	+LIB_FREETYPE = "$(OF_PATH)/libs/freetype/lib/ios/freetype_${PLATFORM_NAME}.a"
	+LIB_TESS = "$(OF_PATH)/libs/tess2/lib/ios/tess2_${PLATFORM_NAME}.a"
	 //LIB_BOOST_SYSTEM = "$(OF_PATH)/libs/boost/lib/ios/boost_system.a"
	 //LIB_BOOST_FS = "$(OF_PATH)/libs/boost/lib/ios/boost_filesystem.a"
	 //LIB_BOOST = $(LIB_BOOST_SYSTEM) $(LIB_BOOST_FS)
	-LIB_CURL = "$(OF_PATH)/libs/curl/lib/ios/curl.a"
	-LIB_URIPARSER = "$(OF_PATH)/libs/uriparser/lib/ios/uriparser.a"
	-LIB_PUGIXML = "$(OF_PATH)/libs/pugixml/lib/ios/pugixml.a"
	+LIB_CURL = "$(OF_PATH)/libs/curl/lib/ios/curl_${PLATFORM_NAME}.a"
	+LIB_URIPARSER = "$(OF_PATH)/libs/uriparser/lib/ios/uriparser_${PLATFORM_NAME}.a"
	+LIB_PUGIXML = "$(OF_PATH)/libs/pugixml/lib/ios/pugixml_${PLATFORM_NAME}.a"
	 
	 
	 MISC_FLAGS = "-ObjC"

Apothecary

It's a bit more involved. Mostly I add two new functions to the main apothecary scripts:

  • ios-build is more or less a replacement for ios_configure.sh. it manages the combinations of platforms+architectures and takes care of combining the results into two fat libs (one for iphoneos and one for iphonesimulator). when calling it you provide a callback that builds for a single specific architecture, the function takes care of the rest.
  • ios-copy copies the library files into the result folder.

Well, here is the patch:
arm64_sim.patch
It should apply cleanly on 135a503

There are some nonsense changes, and i haven't updated all formulas yet, but everything that is needed for ios should build.

ps. just a little heads up... maybe freeimage does not build. it's the first one i did, and ios-build is based on the freeimage script. over time i may or may not have modified ios-build so much that freeimage doesn't build anymore. well, the work is not done yet, what can i say :)

@kritzikratzi
Copy link
Contributor

@danoli3 are you still working on this?

my changes seem to work (i still have issues with sound streams in the simulator, but that seems unrelated).

i'm happy to clean up my changes and make a PR, but i don't really to want to waste my time (or yours) if there's already a better solution

@danoli3
Copy link
Member Author

danoli3 commented Mar 22, 2024

Completed

@danoli3 danoli3 closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

3 participants