I already read a lot of hints how to add an existing framework to Xcode 4, e.g.:
http://www.thinketg.com/Company/Blogs/11-03-20/Xcode_4_Tips_Adding_frameworks_to_your_project.aspx
But my question is very special.
I want to add a library that has the following structure:
build -> Debug-iphoneos -> library.a
build -> Debug-iphonesimulator -> library.a
build -> Release-iphoneos -> library.a
build -> Release-iphonesimulator -> library.a
If I want to build my project to test it on a simulator, I have to copy the library from the folder "Debug-iphonesimulator" to my project. If I want test it on the device, I have to copy the library from the folder "Release-iphoneos". That's very cumbersome!
Is the a good way to integrate all librarys in my project?
Thank you very much!
A first step is to create universal static library with the lipo command
lipo -create "${PROJECT_DIR}/build/${BUILD_STYLE}-iphoneos/libYourLib.a" "${PROJECT_DIR}/build/${BUILD_STYLE}-iphonesimulator/libYourLib.a" -output "${PROJECT_DIR}/build/libYourLib-${BUILD_STYLE}.a"
After that create 2 different target (for debug and release) and add the correct .a in each.
There is another simple way. Provide the path of .a file in other linker flag with the corresponding target.
Suppose you are building your application for device it should link to device version of .a and when you are building your application for simulator it should link to simulator version on .a
Here is how you should provide the other liker flag:
../../../testApp/DerivedData/testApp/build/Products/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/testApp.a
Related
I just created a new project, and installed some pods. When I try to build, I get these two errors:
Showing Recent Issues
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/Demo-eobcppugxuuucmefyvotwbqadppx/Build/Intermediates.noindex/Demo.build/Debug-iphonesimulator/Demo.build/Objects-normal/arm64/AppDelegate.stringsdata':
1) Target 'Demo' (project 'Demo') has compile command for Swift source files
2) Target 'Demo' (project 'Demo') has compile command for Swift source files
Showing Recent Issues
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/Demo-eobcppugxuuucmefyvotwbqadppx/Build/Intermediates.noindex/Demo.build/Debug-iphonesimulator/Demo.build/Objects-normal/arm64/SceneDelegate.stringsdata':
1) Target 'Demo' (project 'Demo') has compile command for Swift source files
2) Target 'Demo' (project 'Demo') has compile command for Swift source files
Turns out I had duplicate swift files in targets -> Build Phases Deleted the ones that where duplicates, and all ok
I had the same problem but in my case, I have same name for two swift files. The solution for that is Go to Targets -> Build Phases -> Compile Sources, and check whether you have the same named Swift files, and remove any one from there.
Another issue of this error is under Targets -> Build Phases -> Copy Bundle Resources, if there are same named bundled resources, remove any one from that.
For me it was a view from an app extension, which was named the same as a view from my main app. Renaming the view from the extension solved the issue.
I tired to follow these instructions here https://github.com/MailCore/mailcore2/blob/master/build-mac/README.md but I didnt understand or dont know how to implement it in my swift app.
I know how to set up the session etc but how to install mailcore2 library onto my app is what im having problems with.
One of the things that worked for me without pods nor carthage was to download the mailcore2 library and copy the whole mailcore2 folder to the project folder. then follow this steps:
Go to Build Phases from your build target, and under 'Link Binary With Libraries',
Add libMailCore-ios.a
Add CFNetwork.framework
Add Security.framework
Set 'Other Linker Flags' under Build Settings:
-lctemplate-ios -letpan-ios -lxml2 -lsasl2 -liconv -ltidy -lz -lc++ -lresolv -stdlib=libc++ -ObjC
Make sure to use LLVM C++ standard library. Open Build Settings, scroll down to 'C++ Standard Library', and select libc++.
In Build Phases, add a Target Dependency of static mailcore2 ios.
For Swift - If you are using Mailcore in a Swift project you also need to complete the following steps:
* Create a new header file in your project and name it Project-Name-Bridging-Header.h.
* Remove any template code from the file and add #import
* In your target settings search for Objective-c Bridging Header and add a link to your bridging header. (Project-Name-Bridging-Header.h)
* You do not need to import Mailcore in any of your classes as the bridging header takes care of this automatically.
ERROR ITMS-90206: "Invalid Bundle. The bundle at 'app.app/PlugIns/OneSignalNotificationServiceExtension.appex' contains disallowed file 'Frameworks'."
ERROR ITMS-90206: "Invalid Bundle. The bundle at 'app/PlugIns/OneSignalNotificationServiceExtension.appex' contains disallowed file 'Frameworks'."
in my app project
Always Embed Swift Standard Library = No
Embedded Content Contains Swift = Yes
in my target
Always Embed Swift Standard Library = Yes
Embedded Content Contains Swift = Yes
in OneSignalNotificationServiceExtension
Always Embed Swift Standard Library = No
Embedded Content Contains Swift = NO
when I try to change OneSignalNotificationServiceExtension to YES it displays error that import OneSignal is not No such module 'OneSignal
OneSignal is written in Swift and should be imported with the use_frameworks!
OneSignalNotificationService target -> Build Phases -> run script :
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi
In General settings of your build target, you have Frameworks and libraries listed for each target. Corresponding to each framework is a setting "Embed and Sign" or "Do not embed". Keeping it "Embed and Sign" in app target and "Do not embed" in every other target where the framework is linked solves the problem.
I created a Swift library with swift package init --type library and generated an Xcode project with swift package generate-xcodeproj.
Now I'm trying to run the Test scheme in Xcode. It prints following error:
Module '<title>' was not compiled for testing
However when I run swift build and swift test in terminal, it works fine.
I have ENABLE_TESTABILITY set to YES in all of the targets. I didn't change anything in the project except this. How can I make Xcode perform unit testing?
You need to set the "Enable Testability" to Yes in build setting over your "Main Target"
I was having this issue today, it seems like #testable cannot be used with projects generated by Swift Package Manager.
Removing #testable from my import statements solved this issue. Of course, this means we can only test the public interface of our modules.
Xcode -> Product -> Scheme -> Edit Scheme
Select the Info tab.
Set the following -
Build Configuration: Debug
Add a check mark to Debug executable
Tested with Xcode 12.4(12D4e) and iOS 14.1 deployment target.
i have build a XYZ.framework package for iOS with the folowing folder-structure:
ls XYZ.framework
XYZ -> Libraries/libxyz.a
Headers -> Home/Headers
Home -> SDKs/Current
Libraries -> Home/Libraries
SDKs
ls XYZ.framework/SDKs
4.2
Current -> 4.2
ls XYZ.framework/SDKs/Current
Headers
Libraries
It works fine with one .a library file.
But how to include more than one .a library file?
0) iOS does not allow you to publish dynamic libs at this time (unless that's a recent change)
1) set up your framework's project to include the dependencies
2) add the depends to the build invocation (target dependencies) and link phase.
3) if your framework creates no objects (e.g. exports no symbols, or compiles no files), then you may need to add a dummy file with something such as an inline function (or the image's constructor/destructor).
4) then link to the static depends to produce the final image. this step should merge all images.