Search code examples
ioscordovaionic-frameworkxcode8xcode9

ionic cordova xcode 9 build development team and conflicting provisionning profiles


I run a Ionic application started 2 years ago still being built using XCode7 and I decided to make a move to the latest version of XCode i.e. 9. I've come across numerous issues, read a lot and tried a fair few things but I'm still stuck in the middle of nowhere. When I build the app using XCode 7 everything is fine, I can build and distribute on the app store.

Here's my problem using XCode 9:

  • DEVELOPMENT_TEAM was needed so I added the build.json with development team number. The build now says I've got conflicting provisionning profiles. How can this be possible when XCode7 could make it?
  • Some say if I ever manage to build (which I don't for now) push notifications will also stop working because of some entitlements issues in xCode 9.

I'm really concerned and left with no answers. Ionic users, have you managed to move from XCode 7 to XCode 8 or 9? How? Caveats? Sample projects ?

Cordova CLI: 6.4.0 
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
ios-deploy version: 1.9.2 
ios-sim version: 5.0.13 
OS: macOS
Node Version: v7.10.0
Xcode version: Xcode 9.0.1 Build version 9A1004

Solution

  • In case you need an answer, here's how I fixed it.

    First, you have to know I can't and don't want to use automatic signing because I have loads of existing provisioning profiles, I'm using jenkins, can't risk to break something while there's not a lot of documentation on ionic / cordova / push notifications and automatic signing.

    1) You need to provide a build.json. you have to. really.

    ionic build ios --buildConfig build.json

    Here's my build.json.

    {
      "ios": {
        "debug": {
          "codeSignIdentity": "iPhone Distribution",
          "developmentTeam": "****",
          "packageType": "ad-hoc",
          "provisioningProfile" : "****"
        },
        "release": {
          "codeSignIdentity": "iPhone Distribution",
          "developmentTeam": "****",
          "packageType": "app-store",
          "provisioningProfile" : "***"
        }
      }
    }
    

    I had loads of problems because I build an ad-hoc version for my testers and everywhere on stackoverflow / internet blogs, it is written you have to use "iPhone Developer" even if you build for distribution. That wasn't the case for me. If you want ad-hoc builds, you need to set the code signing to "iPhone Distribution" AND add your provisioning profile funky string you can find in ~/Library/MobileDevice/Provisioning Profiles . Ex: ac073a34-****-****-****-623f0724c119. If you don't know which one is the one you're after, you can "grep" them with your app ID. This means you have to change this number in your build configuration every time you update your provisioning profile... You've got to love that.

    2) Push Notifications won't work out of the box

    Make sure your cordova push plugin is up to date. Mine is stuck in version 1 but the latest "version 1" seems to be ok.

    ionic plugin add [email protected] --variable SENDER_ID=${sender_id}
    

    STILL, the push notification capability is not "ON" in the generated xcode project. You have to switch it on MANUALLY which is a right pain when you build from jenkins. But it works so the workaround is somewhat "acceptable". If anyone knows how to get the plugin switching the capability "ON" without opening the xcode projet that would be great !

    3) When you generate your ipa you HAVE to provide an export.plist

    That was NOT required beforehand. With XCode 7, you could just xcrun with PackageApplication and job done. Well, now PackageApplication is NOT available and requires more work when exporting. Just as a reminder, I want to build ad-hoc ipa for my testers. This may be different with testflight.

    In my build script :

    cd platforms/ios
      xcodebuild \
          -target "${PROJECT_NAME}" \
          -scheme "${PROJECT_NAME}" \
          -configuration Release \
          -archivePath "build.xcarchive" \
          clean archive
    
      xcodebuild \
          -exportArchive \
          -archivePath "build.xcarchive" \
          -exportOptionsPlist "export.plist" \
          -exportPath "${EXPORT_DIRECTORY}"
    

    Export.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>method</key>
        <string>ad-hoc</string>
        <key>teamID</key>
        <string>*****</string>
        <key>provisioningProfiles</key>
        <dict>
            <key>YOUR_APP_ID</key>
            <string>PROVISIONING_PROFILE_FUNKY_STRING</string>
        </dict>
    
    </dict>
    </plist>
    

    I have multiple targets on the same projects with multiple environments and multiple provisioning profiles, I can tell you I'm not happy about providing such details while it was not required before. If anyone knows how to ease the pain, I'd love to hear from you.

    Thank you Apple, you're NOT making my life easier.