Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a dylib for iOS simulator

I have an ObjectiveC project project that I've managed to create a universal static library using Ray Wenderlich's excellent article here:

https://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial

Which allows you to do it all from within Xcode. I also want to create a dylib for iOS Simulator using the same project.

I came across this link for extracting a slice from the universal static library, and creating a dylib:

https://pewpewthespells.com/blog/convert_static_to_dynamic.html

Except that it doesn't specify the options for creating a dylib for simulator (the default is for OSX), and I'm having trouble finding exactly what the right options are for targeting iOS Simulator.

I'm assuming that if I do have the right options, I could add this to the end of the script (from Ray's article). Any clues as to what I could do?

like image 495
Dave Nottage Avatar asked Jun 04 '26 20:06

Dave Nottage


1 Answers

I've managed to sort this one out myself (eventually) :-) The trick was to:

Add another target in Xcode, by using File|New|Target, and select Library from the OSX/Framework & Library items.

In the Build Settings for the new target:

In the Architectures section, since this dylib destined for just i386 simulator, in I added i386 to the Architectures item, and removed the others, and did the same for Valid Architectures

I set the Base SDK to iOS9.3

I changed the Supported Platforms to iOS

Since I didn't want the dylib put on the Mac, in the deployment section I set Skip Install to Yes

So that the install name doesn't have a specific path, in the linking section, I changed the Dynamic Library Install Name Base to @rpath

I also didn't want Xcode to add a prefix to the dylib, so in the Packaging section I removed the Executable Prefix value

I may have above and beyond with a couple of the settings, however the result is what I desired.

like image 119
Dave Nottage Avatar answered Jun 07 '26 11:06

Dave Nottage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!