I made a custom framework from a xcode project with "example.com.a" bundle identifier using lipo -create
command by joining simulator and iphone architecture frameworks. So it has a bundle identifier "example.com.a" in it's info.plist
file by default. I am able to use this framework in my app and my app installs on device without any error
Now when i try to change the bundle identifier of the custom framework to something like "myapp.custom.framework" by manually editing the info.plist inside the framework folder instead of xcode project .
By doing this I am unable to install the .ipa in the device. It shows "Unable to install the app".
So my question is
1) Is manually changing the bundle identifier or adding keys to custom framework's info.plist affects the custom framework functionality ?
2) For changing the bundle identifier of custom framework do we need to change it in the main xcode project? Right now i am changing and adding keys in the info.plist which is there in framework folder.
CodePudding user response:
After long research and trial i found that if we change the bundle identifier in info.plist inside the custom framework folder, it will create error while adding in a sample project, instead we need to change the bundle identifier from the XCode project and then generate iPhone and Simulator .framework
and use lipo -create output
to combine them and create a universal library.
Following are the steps :
To build and distribute universal/fat frameworks: In the framework project:
- Build xcode framework project for simulator and build for device, this will produce two frameworks in the derived data folder.
In Terminal:
2. Find the derived data path for the project. Look for the folder Build->Product
s. Inside it should be '-iphoneos' and '-iphonesimulator'. Inside each is a .framework folder. Copy one of those to some nice folder. From each of those .frawework folders, copy the binary that is in there to one folder.
3. In terminal run the command lipo -create -output <outputName> <binaryFromiphoneos> <binaryFromiphonesimulator>
. This will create a fat binary with all architectures for both simulator and devices. Replace the one in the copied .framework directory with the newly generated one preferably inside the folder of iPhone platform framework.
- Run
lipo -info <framework path>
in terminal to know about the architecture of the framework
To use the framework in another app:
- Select the
Project
in the Project Navigator, select the target, and selectGeneral
tab. - drag the .framework folder onto where it says 'Add embedded binaries here'.
- In the build settings of the target, add the path to the .framework folder to 'Framework Search Paths'.
- Import files in your source code using #import
<frameworkName/frameworkName.h>