Build error with XCode 9.0 of a Ionic project - ios

I have a problem building my ionic project on iOS with xcode, the sources get compiled correctly (or atleast it seems so) but when "Apple Mach-O Linker" try to link my obj files, I get an error saying 256 duplicate symbols for architecture arm64 and then I do not manage to understand the logs (logs below) since it refer to cordova generated files from the typescript ionic project
Here is what i tried :
Creating a new ionic blank project to see if it was a problem with XCode configuration itself (it works with a blank project)
Cleaning up the whole DerivedData folder
Pod deintegrate and install
cordova clean ios && cordova platform remove ios && cordova platform add ios
Opening explicitely .xcworkspace file
Changing enable bitcode from YES to NO
Changing the build path to somewhere else than DerivedData
Changing "Build Active Architectures Only" to YES
None of them worked and I feel like i'm out of solutions and energy, is there anyone with other solutions or ideas ?
here is the error log : https://codepaste.net/d2qzh2
I didn't put the whole log there (only the beginning, the end, and a small part at the middle because the whole middle is kind of the same)
here is my package.json that may help aswell : https://codepaste.net/4ckbha
Thanks for your time
UPDATE
Found out that my problem isn't linked to console (even tho i shouldn't have console) but to cordova-plugin-add-swift-support so that when cordova platform add ios build the xcode project, it build it with swift conversion, and then i have the same problem described upper, followed all of the answers on the possible duplicate question but nothing worked out

Managed to fix it, I had two plugins colliding with each other, my solution to find the problem was to create a blank project and re-add my plugins one by one until i see which one was in fault and then do the same backward to find the other one in fault
the two plugins were ionic-deploy and cordova-plugin-ionic which is obvious now that i think of it

Related

Regarding Header 'RealmSwift-Swift.h' not found error

I've updated my Xcode to the Xcode 10.0 beta version and tried to run a project with realmswift in it, now i'm facing an error where it says:
Header 'RealmSwift-Swift.h' not found
I noticed this after trying out the "Conversion to Swift 4.2" button (which failed for me). When I switched to another target where I didn't run this yet, the project built without problems. And after cleaning the project properly, the failing target worked again.
Please note that according to the Release Notes this beta has several "known issues" regarding cleaning, including this one (which has the workaround for it listed, too):
So you might want to try deleting the DerivedData folder manually on top of cleaning in Xcode.

ionic app archive failing in xcode 7.2 due to ‘Cordova/CDVViewController.h’ file not found

I am developing an ionic app for iOS and it is building fine, but when I archive it in xcode, it is throwing "‘Cordova/CDVViewController.h’ file not found" error in xcode 7.2.
I have tried usual suspects such as solution suggested in https://forum.ionicframework.com/t/cordova-cdvviewcontroller-h-file-not-found-in-xcode-7-1-beta/32232, but nothing worked. I have also tried archiving in xcode 7.1, 6.4 but the same error exists. I am using ionic 1.2.4.
Some of my project screenshots (if it helps)
let me know if you need more info.
2 things to try
1st)
you have screen shotted your header search paths i don't see a path to Cordova
try adding $(SRCROOT)/WhereCordovaIS to the header search paths
also do the same for Library Search Paths
2nd)
In the Cordova Lib make sure the headerFiles that are missing 'CDVViewController.h' is included in the 'copy files build step' in BuildPhases
is in the copy
Hi #David I tried your answer. Didn't work. However, I tried ionic's weather app and it worked. So I thought the issue might be with my environment. I cut out js, css and views folder and put it in a fresh repo and it worked like a charm.

Error with Google Play Game Service on iOS

I am getting this error:
ERROR: GPGSAppController.mm GIDSignIn.h File not found error
I am using Google Play Game Service plugin for Unity for leaderboard and Achievements, and every thing is working fine in android but when I build to IOS and try to run my project to an iOS device I keep getting this error and I couldn't find a solution to it for hours now.
I tried to deleted everything related to Google Play service (After creating a back up of course) and the app installed and worked ok, except it was a bit laggy but that is a another issue. So I'm sure the problem comes from Google Play Service, but I have no clue how to fix it. Again I'm new to Xcode and iOS development in general and even Mac.
I also get this message after building the project in Unity:
TO FINISH CONFIGURING THE EXPORTED XCODE PROJECT
Add these frameworks:
AddressBook.framework
AssetsLibrary.framework
CoreData.framework
CoreTelephony.framework
CoreText.framework
Security.framework
libc++.dylib
libz.dylib
Add the following bundles and frameworks from the Google Plus
and the Google Play Games C++ SDKs. These can be downloaded from
https://developers.google.com/games/services.
GoogleOpenSource.framework
GoogleSignId.bundle
GoogleSignId.framework
gpg.bundle
gpg.framework
Note: Make sure the bundles are copied to application. This can be
verified under Build Phases/Copy Bundle Resources.
Add the '-ObjC' linker flag. To do this, select the top-level project
object, select the 'Unity-iPhone' build target, then go to the
Build Settings tab. Search for Other Linker Flags and add
the '-ObjC' flag to that list.
** Note: To run in the simulator, use Unity 4.6.8 or greater.
ios_instructions on plugin repository
But I have no idea how to do any thing above as am not familiar with iOS development. Any help is appreciated.
#aimozs answer was right for indicating where to add required files, a few google search gave me the answers;
From instructions (didn't work for me, scroll down)
AddressBook.framework
AssetsLibrary.framework
CoreData.framework
CoreTelephony.framework
CoreText.framework
Security.framework
libc++.dylib
libz.dylib
These can all be located directly when linking frameworks. (In my case, libc++.dylib and libz.dylib were already linked, and I couldn't find them somehow, but regenerating your xcode project should add these two again.
GoogleOpenSource.framework
I've found it here:
https://developers.google.com/+/mobile/ios/getting-started#step_1_creating_the_console_name_project
GoogleSignId.bundle
GoogleSignId.framework
Found them in:
https://developers.google.com/identity/sign-in/ios/sdk/
(I grabbed latest version Google Sign-In SDK 3.0.0)
gpg.bundle
gpg.framework
I found them here:
https://developers.google.com/games/services/downloads/sdks
(Grabbed Play Games C++ SDK Version 2.1)
Also, the following part of the message seemed important:
Make sure the bundles are copied to application
I tried to copy bundle files to root of the project, but I still get the same error.
Solution: CocoaPods and the podfile!
I saw the PodFile in xcode project directory!.
Here you go; make sure you followed these steps:
https://github.com/playgameservices/play-games-plugin-for-unity#ios-setup
Then see https://cocoapods.org/
sudo gem install cocoapods
pod repo update
pod install
open Unity-iPhone.xcworkspace
Way better than manually copying files everywhere! ;)
Note: I also had to disable bitecode because I was having a linker error concerning GoogleOpenSource:
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE)
It doesn't seem to be compiled with bitcode enabled, solution in here: how to ENABLE_BITCODE in xcode 7?
Build, enjoy and focus on making awesome games!
Linked questions
There's also a small discussion here:
http://forum.unity3d.com/threads/googleplus-googleplus-h-file-not-found-gpgsappcontroller-mm-xcode.294398/
A similar issue on UnityAnswers:
http://answers.unity3d.com/questions/1098655/gpgsappcontrollermm-gidsigninh-file-not-found-erro.html
Im going through that aswell, and for #1 it has to be done in xcode, here's a screenshot of how to add those libs
And that is for #3
Hope that helps :) and I'll get back to you about #2 when I've found out about it ;)

Xcode 7 - Code coverage data generation failed

When I run my tests I get an error:
Code coverage data generation failed.
Unable to retrieve the profile data files from 'UIDevice'.
On console was printed warning:
Timed out waiting 120 seconds for simulator to boot, current state is 1.
What is the reason?
If you are integrating your project with a 3rd party dynamic framework, you may need to add a path in your build settings. Look for ->Build Settings->"Runpath search paths" and make sure it includes the path to the framework.
I was just seeing this exact issue myself after setting up my a project to use a framework my team has been working on. After updating this specific setting, the problem went away. In my case, the path was identical to one I already had to set for the "Framework search paths" setting.
I solved this problem, just like I solve most of those XCode Problems:
delete your projects files in your DerivedData (Xcode>Preferences>Locations>DerivedData→ to jump there in finder)
Product>Clean
(keep alt-Button pressed) Product>Clean Build Folder
Quit XCode
Restart XCode
Remove your app from your device / simulator
Try again.
In case it still doesn't work, use another simulator / device for a few runs. Sooner or later it will work again on the original one again.
If you are using cocoa pods, check this thread on the Cocoapods repository:
https://github.com/CocoaPods/CocoaPods/issues/5385#issuecomment-226269847
This fixed my problem:
Copying #dfleming response:
For some reason, it appears that CocoaPods is not adding the "[CP]
Embed Pods Frameworks" build phase to the UI Tests target when
generating the project workspace.
I manually added this in and the UI Tests were runnable again.
This build phase should run the following script: (Replace
{YourProject} with your project name)
"${SRCROOT}/Pods/Target Support
Files/Pods-{YourProject}UITests/Pods-{YourProject}UITests-frameworks.sh"
I experienced exactly the same error and eventually got it working, these are the steps I took.
Tried restarting Xcode and the simulator, after cleaning and deleting the app, that never worked.
Then I restarted the Mac as suggested, but that still didn't work.
Then I chose a new device to test against in the simulator, was previously using 5s and switched to 6, and that worked.
Interestingly, when I switched to the iPhone 6 simulator, it showed the Apple logo with a loading bar, before running the app and working.
When switching back to the 5s simulator it did exactly the same, with the Apple loading bar, which it hadn't done before, and then the 5s worked.
So it looks to be a simulator issue, and switching to a different device worked. Resetting the content and settings may be the solution for a non-working device.
Cocoapods link_with method can cause this issue!
I was getting the exact same error on xcode 7.2 - no number of simulator or device resets seemed to clear it up. After completely rebuilding my UITest targets though things worked fine. After spending a lot of time in a massive git diff of the .pbxproj file I found a solution for my project. Im not sure if it addresses the root cause for everyone who is seeing this error but it definitely clears things up for me.
From the project info below "deployment target", "Configurations" will list all the possible configurations for your application. Expand the configuration you are trying to run and you should see a list of all your targets. In my case cocoapods had automatically added a base configuration for the UITest target:
Set this to none in the dropdown.
Next in the menu to the left select your UITest target then build phases You will need to remove check pods manifest.lock link binary with libraries emebd pods frameworks and copy pods resources.
Finally go to your pod file and check for any mentions of your UITest target or targets. In my case I had been specifying at the top of my podfile:
platform :ios, '8.4'
use_frameworks!
link_with 'My App', 'My UITesting Target'
pod 'A Pod', '~> 1.0'
Instead the podfile should list specific dependencies for each target:
platform :ios, '8.4'
use_frameworks!
target 'My App', :exclusive => true do
pod 'A Pod I want to use in my app', '~> 1.0'
end
Assuming you weren't using any pods in your UITests the target should build again without errors and tests will run!
My understanding of root of this problem is that each UITest target builds two separate bundles, one for the app and one for the UITest controller. Unfortunately cocoapods link_with logic modifies all the specified targets to expect the pods.framework in their bundle. The build phase scripts add the framework to the app bundle but not the UITest controller bundle, so then when you launch your tests that UITest controller bundle appears to be missing frameworks and xcode aborts the installation.
If you were using pods in your UITests you should be able to specify these in the same way:
target 'My UITesting Target', :exclusive => true do
pod 'Another Pod I want only for UITesting', '~> 1.0'
end
And when you run pod install everything should link up correctly.
This problem can also appears when you use Cocoapods with a framework where some dependencies are missing.
For example if you are using Framework A, and this framework depends of Framework B but in the Podspec of Framework A the dependency is not declared.
One of the reasons this can happen is if the host application that the test target is testing is not linked to the right dependencies. For example, if you have are testing a framework, make sure the host app is linked to those frameworks and also embedded.
My problem was caused by incorrect deployment version of unittest target. Tested App deployment version was 7.0, but the unittest's was not set up correctly automatically. It was set to 10.0, while my simulator's version was 8.4. Change the UT target's deployment version to 8.0 in build settings and then all the problems disappeared.
I tried a bunch of these solutions with no luck. I turned off the Code Coverage option in my Scheme's Test section, which suppressed the error but Tests would not run. Then I noticed quite a bit of stuff in NSLog console. Somewhere in there, it mentioned reference to a framework that I was no longer using and trying to load.
I searched the app for it, and Build Settings -> Other Linker Flags was trying to load the framework that wasn't there anymore.
I removed:
-framework 3rd_party_libname
Then tests worked again. This was confusing, but please check for NSLog msgs. I was using XCode 8.3
One or more of your simulators has gotten stuck. The only thing that always works to fix this for me is to reset the simulator content and settings from the Simulator menu.
Note: this will delete all app data from the simulator.
After a long time trying to figure this out, it turned out that I had to create a brand new test target.
Then after rebooting the device the problem no longer resurfaced.
In my case, I had added Swift files to a framework that was (until then) purely Objective-C. The test bundle did not have any Swift code in it.
Once I added a Swift file to the test bundle, Xcode automatically updated some project settings and the error went away.
You should keep the Swift file in the test bundle, even though it may not contain any code. Either Xcode or Cocoapods evidently use the existence of Swift files in the test bundle to determine whether to run the tests in "swift mode".
The root cause is probably the simulator failure. Issues with the simulator are common, especially on first launch.
If the problem occurs even after successful simulator launch and connect, please post the details of the error.
To get the simulator to launch, I often have to cancel the first run (after launching Xcode cleanly), and try re-running a few times.
If this is repeatable, happens on multiple projects, and persists after relaunch and cleaning of the projects, consider submitting a defect to Apple if the Stack Overflow community cannot help.
I had this same problem but it was due to having a test target and renaming the application's target. Make sure you have a valid Host Application set.
Choose the test target on the project page
Under the General tab there should be a Host Application select box
Choose the target you want to test against
I also faced same issue :
Tried following things for different projects :
1.For project where i had some third party frameworks, The problem was that test bundle can't find the framework at runtime. For this update test target's Runpath Search Paths build settings by adding $(PROJECT_DIR)/Frameworks (assuming you keep your frameworks at that location)., It fixed my problem for this project
You can look for it at below location :
Project file -> Test target -> Build Settings -> Runpath Search Paths
In other workspace, When I changed my testing device to some other simulator or change the device itself. it helped.
Restart the xcode or your mac system.
hope it will help u
Carthage users:
This happened to me after I added a new framework to my Cartfile.
I ran carthage update but forgot to drag the .framework file from Finder into the Embedded Binaries section of my app target!
Once I did that, the problem went away.
(Note this is a specific case of the general problem mentioned by #Mustafa above.)
I was having this problem on Xcode 8.3 on Sierra 10.12.4
I opened the Keychain Access application on my Mac
After a few seconds, I got several system pop-ups asking for my password, to grant permissions to Keychain items.
I entered my password into the pop-ups, and then my tests starting working.
Steps that worked in my case
Delete the scheme and clicking Manage Scheme->Auto generate scheme resolved the issue in my case.
Issue was caused by installing the certificate in the simulator and in the keychain
Using Xcode 9.1 with multiple build targets and standard compiler we were working on UI tests and I started seeing this problem. So, you will probably hate me for this answer, and I fully expect it to be downvoted, BUT this actually worked for me: I had to completely remove Xcode and my project from my machine to make this error disappear.
I tried every single suggestion in this thread, some multiple times, tried clearing cache files, deleting derived data, tinkering with build settings, updating podfiles, cleaning, rebuilding after each attempt, cleaning the simulator, manually recreating the simulators in 'manage devices'. After hours and hours of frustration it was still a complete mystery why this machine was failing to build our UI test. It seemed to work fine on other machines and on our CI. In addition to the items in this thread I manually modified the pbxproj file to set all options related to code coverage to "NO".
Finally, I was 1 step away from reformatting the entire machine. I decided to completely remove Xcode following the suggestions here: Stackoverflow: How to completely uninstall Xcode.
Specifically, I trashed our workspace, quit all programs, deleted all of the files listed, cleared content and settings from the simulator, deleted the simulator, turned the machine off for 20 minutes, came back, reinstalled Xcode, cloned the repository, and voila! No error.
Hope that solves the issue for someone. It's the 'nuclear' option, and you should never ever have to do this, but like I said, this is the only thing that worked for me.

Could not inspect the application package when using device

I’m getting this error whenever I try to run my app on a device:
"App Installation Failed
Could not inspect the application package."
I realize that this can mean a million things and I have done days of research but nothing has worked yet. It works on the simulator.
What I’ve tried:
Renaming “Resources” folder in the Google pod (only place it existed)
Renaming “Resources” in Finder for Google and changing the path in the pods resource file
Delete derived data (through projects window and deleting the folder directly)
there are no weird characters in the product name (there is a space)
delete derived data, delete app, restart phone, cmd+shift+K, quit Xcode, restart computer
all software is up to date
there are no sample projects from third parties
the “capabilities” in the app match the entitlements in the app id
Other info:
Xcode 6.4
application supports iPhone and iPad (min version latest 8.4)
works every time on the simulator
always fails on the device (tested iPhone 6 and iPhone 5)
builds with out error
there is no run script printed (in “report navigator”) but there is for
the build (again no error)
valid architectures: arm64, armv7, armv7s, x86_64, i386
build valid arch only: Debug-Y, Release-N
This was working fine before and I did a bunch of code changes (not settings) before this happened out of the blue.
Odd but has been happening:
I’ve noticed that no matter how many times I switch the provisioning profile, it always switches back to automatic (kind of annoying but it isn’t my issue)
Fixed it myself. I was importing a framework in my bridging header that I previously removed and Xcode gave me no error I guess because I didn't call the framework anymore?
Steps:
remove the unused/nonexistent framework for bridging header
cmd+shift+k
quit Xcode
find your project's build folder and trash the contents of the Intermediates and Products folders
open your project and run
This may be overkill but it works now. I hope this helps.
For future reader:
Same issue, but different problem.
My problem in Cocoapods configuration.
I have update Cocoapods to latest version in main project, and in this version some configuration path has changed.
So, i need to make sure all my dynamic frameworks that use Cocoapods to be updated in same version to solve this issue.
Note:
My latest Cocoapods version is 1.2.1
Xcode v8.3.2
update -> pod update
In my case it was an accidentally included framework. Just had to remove it.

Resources