Dealing with "error: exportArchive: No "iOS In House" profiles for team" or error: exportArchive: No "adhoc " profiles for team

Below is a common error when trying to setup CI/CD using fastlane or raw XcodeBuild/Xcrun command

“error: exportArchive: No “iOS In House” profiles for team” or “error: exportArchive: No “adhoc In House” profiles for team

Fixing it :

1) Easiest way is to make a build archive in Xcode, Export using organizer and Saving it in a folder.

2) Go to the folder, open Export Options.plist and replicate the same in Fastlane - build_app or gym - export options

3) In case of XcodeBuild - Replace the same in Export Options.plist which is provided in XCodeBuild command and try again

4) Make a build, thank me

Fastlane Build Script

build_app(scheme: "Your scheme name",

    clean:true,

    skip_profile_detection:true,

    output_directory:"output path",

    codesigning_identity:"Copy this from xcode build settings - Code signing",

    export_method: "enterprise",

    export_options: {

        method:"manual",

        provisioningProfiles: { 

        "com.xxx.xxxxx" => "Copy this from xcode build settings - Provisioning profile"

      },

      teamID:"Your team ID",

      stripSwiftSymbols:false,

      signingCertificate:"iPhone Distribution",

      thinning:"<none>"

    },

)

Fixing the mysteriously missing Core Data objects

The below post helps you to identify and fix the the mysteriously missing Core Data objects. I have also provided a link, with a working project, where I demonstrate how objects are missing and how it can be fixed.

Checklist for the solution below

- You are getting `<x-coredata: UDID; data: fault>`, despite setting `fetchRequest.returnsObjectsAsFaults = false` and saving the managed object context properly

- Your Objects and Relationships are available in first run and is missing once you restart/relaunch the app Or sometimes few objects and relationships are randomly available and starts missing in subsequent runs

- You dont have any other errors while saving the managed object context

- The objects are missing where you dont have an inverse relationship and Xcode is also indicating a warning about missing inverse relationship

When does it happen

Most of the cases have similar pattern. Check if it suits you

- A has one to many relationship with B. B doesnt have any inverse relationship

- B’s objects are inserted first and saved to store

- A’s objects are created in context, B’s objects are fetched and is mapped to A

- When you save the context, it would appear A is saved, along with its relationship to B objects

- But when you fetch immediately from Store, you can see A’s relationship to B is missing and you will not be able to access B objects from A

Solution

There are 2 solutions.

1. B should have an inverse relationship to A. ( Recommended if its possible.)

(or)

2. Ensure that A object is first saved to store, as soon as its created.

- Now fetch A’s object and map it to existing B objects and save it to store.

- When you fetch/refresh A’s object, you will be able to access B objects despite not having an inverse relationship

Projects in this repo

There are 2 projects in my repo to demonstrate the above solution

1. OneToMany-NotWorking - to demonstrate why its not working

1. OneToMany-Working - to demonstrate how to make it working

Citation

Please provide citation to this repo in stackoverflow or wherever required.